2009-12-12 08:29:42     spidev return wrong bits_per_word value

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

2009-12-12 08:29:42     spidev return wrong bits_per_word value

Øyvind Kaurstad (NORWAY)

Message: 83429   

 

Hi,

 

I've started experimenting with the spidev driver (2009R1) kernel and toolchain. The device I am using it with, is an A/D-converter which needs 16 bits per transfer, so in my board setup file I have this:

 

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

static struct bfin5xx_spi_chip spi_adc128s022_chip_info = {

    .enable_dma = 0,

    .bits_per_word = 16,

};

#endif

 

and this:

 

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

    {

        .modalias = "spidev",

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

        .bus_num = 0,

        .chip_select = 4,

        .controller_data = &spi_adc128s022_chip_info,

    },

#endif

 

Using the full duplex spidev IOCTL call, this sems to work, but if I issue the SPI_IOC_RD_BITS_PER_WORD ioct call, it returns 8, not 16. If I explicitly set the word length with a SPI_IOC_WR_BITS_PER_WORD call, then subsequent reads returns this value.

 

This is not a very important issue, since it does work, but I am puzzled why the wrong value is returned.

 

Regards

 

-Øyvind

QuoteReplyEditDelete

 

 

2009-12-12 08:38:43     Re: spidev return wrong bits_per_word value

Mike Frysinger (UNITED STATES)

Message: 83431   

 

the Blackfin SPI driver manages the bits_per_word behind the back of the common SPI code.  so SPI_IOC_WR_BITS_PER_WORD wont actually change the size as seen by the Blackfin driver.  we'll have to fix this.

QuoteReplyEditDelete

 

 

2009-12-12 09:56:42     Re: spidev return wrong bits_per_word value

Øyvind Kaurstad (NORWAY)

Message: 83432   

 

Thanks! That explains the behaviour.

 

However, it is still possible to alter this value *per transfer* if using the full duplex ioctl-call SPI_IOC_MESSAGE to the spidev-driver and setting the bits_per_word value in the message itself.

 

Regards

 

-Øyvind

QuoteReplyEditDelete

 

 

2009-12-12 10:03:27     Re: spidev return wrong bits_per_word value

Mike Frysinger (UNITED STATES)

Message: 83433   

 

per-transfer should work fine.  the driver checks that field.

Attachments

    Outcomes