2009-02-05 12:30:16     spidev not working

Document created by Aaronwu Employee on Aug 13, 2013
Version 1Show Document
  • View in full screen mode

2009-02-05 12:30:16     spidev not working

Izhar Eyal (ISRAEL)

Message: 68923   

 

Hi All,

 

We have tried using spidev  with an SPI device. we are using the standard ezkit.c file for the BF561 and only modifications made where:

 

max_speed = 1500000 (1.5MHz)

 

bits_per_word = 16

 

chip_select = 7  (for PF7 as slave select)

 

than we tried running spi_test with some minor modification which are:

 

mode: mode 3

 

bits_per_word: 16

 

instead of do_msg() we made a new function that receives data into buf[] and sends it the same way as do_msg.

 

from my understanding do_msg only sends 0xaa which is not really a good test for us.

 

buf[0] = 4a;

 

buf[1] = 01;

 

//we would like to send 4a01 as a 16bit word.

 

we see that running spi_test does nothing to the SPI device, while a cpld logic that we have written with the same parameters shows that the SPI device is working when the same word is written.

 

on the scope we can see that for some reason PF7 is not toggling.

 

Some more info: we have the GPIO driver and SPORT0 driver also installed.

 

 

 

Any ideas?

 

could it be that the GPIO driver blocks the PF7 from toggling?

 

 

 

Thanks

 

 

QuoteReplyEditDelete

 

 

2009-02-05 14:03:13     Re: spidev not working

Mike Frysinger (UNITED STATES)

Message: 68928   

 

look at the spi test code in linux-2.6.x/Documentation/spi/ instead

QuoteReplyEditDelete

 

 

2009-02-05 14:14:12     Re: spidev not working

Izhar Eyal (ISRAEL)

Message: 68929   

 

Hi Mike, thanks for the reply,

 

I've looked at the documentation/spi directory already. the source code there is exactly the same as the user/blkfin-test/spi-test

 

we really have no other ideas here...

QuoteReplyEditDelete

 

 

2009-02-05 14:18:08     Re: spidev not working

Mike Frysinger (UNITED STATES)

Message: 68930   

 

post the exact changes you've made to the ezkit file

 

are you actually using a bf561-ezkit or is it your own board ?  we've never tested SPI on the bf561-ezkit due to lack of proper pin outs.

QuoteReplyEditDelete

 

 

2009-02-06 03:29:44     Re: spidev not working

Izhar Eyal (ISRAEL)

Message: 68953   

 

I'm attaching the files i'm using (spi_test.c, ezkit.c).

 

we are using our custom board which is almost identical to the ezkit so the bsp should be almost the same.

 

we do not have the ad1836, but we are intending to use the SPORT0 for audio (the ad1836 seems to be using both spi & sport0).

 

Here are the changes made(marked by comment stars):

 

ezkit.c:

 

 

 

static struct bfin5xx_spi_chip spidev_chip_info = {

 

.enable_dma = 0,

 

.bits_per_word = 16,           //************************ changed from 8bit to 16bit

 

};

 

 

 

static struct spi_board_info bfin_spi_board_info[] __initdata = {

#if defined(CONFIG_SND_BLACKFIN_AD1836) \

|| defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)

{

.modalias = "ad1836-spi",

.max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */

.bus_num = 0,

.chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,

.controller_data = &ad1836_spi_chip_info,

},

#endif

#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)

{

.modalias = "spidev",

.max_speed_hz = 1500000,     //***************************  changed to 1.5Mhz

.bus_num = 0,

.chip_select = 7,                          //*************************** changed to PF7/SPISS7

.controller_data = &spidev_chip_info,

},

#endif

};

 

this entire code section(there are more lines in the file) was placed in comments:

static struct gpio_keys_button bfin_gpio_keys_table[] = {

{BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},

{BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},

{BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},

{BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},

};

 

 

spi_test.c was changed a lot, please see the file.

major changes: application now receives different swiches:

-b sets the bits per word

-w receives the data to be send by spi

 

than function write_msg() is called.

 

under uClinux we run:

root: /> spi_test -b 16 -w 4a01 /dev/spidev0.7

 

output:

SPI Test App

setting BitsPerWord

set BitsPerWord to 16

set Data to be sent to: 4a 01

/dev/spidev0.7: spi mode 3, 16 bits per word, 1500000 Hz max         (this is the dumpstat() output)

sending data now

 

have anyone tested 16bit words? we still don't see the CS toggled.

 

 

 

 

 

 

 

 

 

spi_test.c

ezkit.c

QuoteReplyEditDelete

 

 

2009-02-08 03:13:11     Re: spidev not working

Izhar Eyal (ISRAEL)

Message: 69038   

 

Still no go....I'm gonna try the bitbang driver today......any ideas? please...

QuoteReplyEditDelete

 

 

2009-02-11 03:14:40     Re: spidev not working

Izhar Eyal (ISRAEL)

Message: 69233   

 

The bitbang driver cannot be run on the spi pins, only on gpio pins.

 

Can anyone please look at the above code and see if we are doing something wrong?

 

Mike, after I solve these issues here, how do I submit the spi_test file to the uClinux dist. I think it's about time this file be updated to something more helpful to everybody. thanks.

QuoteReplyEditDelete

 

 

2009-02-11 03:48:27     Re: spidev not working

Michael Hennerich (GERMANY)

Message: 69234   

 

Did you try SPI SSEL other than SSEL7 (aka. PF7)?

Do they toggle?

 

I'll do a quick check here on an EZKIT - to see if SSEL7 behaves accordingly.

 

-Michael

 

QuoteReplyEditDelete

 

 

2009-02-11 04:03:29     Re: spidev not working

Izhar Eyal (ISRAEL)

Message: 69235   

 

good point, I haven't tried any other SPISS pins, I will try to change... thanks for helping, please let me know how things went on the ezkit.

QuoteReplyEditDelete

 

 

2009-02-11 05:26:13     Re: spidev not working

Michael Hennerich (GERMANY)

Message: 69264   

 

>I'll do a quick check here on an EZKIT - to see if SSEL7 behaves

>accordingly.

 

SSEL7 (aka. PF7) works absolutely fine.

Are you sure that PF7 is connected to an input on your CPLD?

 

root:/> while :;do cat /etc/rc > /dev/spidev0.7;done

 

Also try setting bits_per_word=8 to see if this makes a difference.

 

 

#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)

static struct bfin5xx_spi_chip spidev_chip_info = {

.enable_dma = 0,

.bits_per_word = 8,

};

#endif

 

 

With bits_per_word=16 I get errors like this:

 

root:/> while :;do cat /etc/rc > /dev/spidev0.7;done

cat: write error: Input/output error

cat: write error: Input/output error

cat: write error: Input/output error

 

I assume this is due to the fact that the spidev uses default 8-bit transfer sizes.

 

 

-Michael

 

QuoteReplyEditDelete

 

 

2009-02-11 12:32:28     Re: spidev not working

Mike Frysinger (UNITED STATES)

Message: 69272   

 

there is no spi test code in the dist.  it comes from the kernel.

Attachments

Outcomes