2010-03-27 13:46:20     trouble getting started with SPI on BF537-STAMP

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

2010-03-27 13:46:20     trouble getting started with SPI on BF537-STAMP

Hugh Shane (UNITED STATES)

Message: 87758   

 

I am developing an application that needs to communicate over the SPI bus with an Analog Devices ADIS16355 inertial sensor. I fully understand how the sensor works, how the SPI bus works and how I need to configure the SPI bus to communicate with the sensor (SPI mode, clock speed, etc.) However, I have no experince with Linux devices drivers and am having trouble figuring out the steps I need to take to build and install a properly configured SPI controller driver. (Based on what I've read, I do not believe that I need to build a protocol driver.) I've studied   docs.blackfin.uclinux.org/doku.php?id=spi and the documents to which it points but am still confused.

 

Here's what I've done so far: (1) Using the make config system I've enabled SPI support:SPI controller driver for ADI Blackfin5xx. (2) Following the example given in the above documentation I've added the following to ./arch/blackfin/mach-bf537/boards/stamp.c

 

static struct bfin5xx_spi_chip adis1635x_imu_info = {

    .ctl_reg = 0,              /* Blackfin-specific fields in SPI_CTL MMR; default = 0 */

    .enable_dma = 0,           /* Use DMA to transfer to the device; default = 0 */

    .bits_per_word = 16,       /* How many bits per word to transfer at a time (8 or 16); default = 8 */

    .cs_chg_udelay = 9,        /* How long to delay when changing the chip select between words; default = 0 */

};

 

 

    {

        .modalias = "adis1635x_imu",

        .max_speed_hz = 2000000,

        .bus_num = 1,

        .chip_select = 1,

        .platform_data = NULL,

        .controller_data = &adis1635x_imu_info,

        .mode = SPI_MODE_3,

        //.irq = GPIO_IRQ(31), // TBD

    },

 

 

What steps do I need to take next? For instance, under the Kernel Driver section of the above documentation, some code snippets are provided that illustrate how to register the SPI driver and probe SPI device. But no mention is made of exactly which files need to be modified or added.

 

TIA

 

Hugh

QuoteReplyEditDelete

 

 

2010-03-27 15:02:20     Re: trouble getting started with SPI on BF537-STAMP

Mike Frysinger (UNITED STATES)

Message: 87760   

 

you need to write your own SPI driver kernel module.  you arent going to modify anything in the kernel to write your own driver.

 

please review the module documentation:

  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:modules

 

as for specific examples of SPI drivers, simply search drivers/ for flies that contain 'struct spi_driver'.  there will be plenty.

QuoteReplyEditDelete

 

 

2010-03-27 15:03:42     Re: trouble getting started with SPI on BF537-STAMP

Mike Frysinger (UNITED STATES)

Message: 87761   

 

although, i see you're trying to use an ADI part (ADIS16355).  usually we write drivers for ADI parts and merge them to the tree ourselves for people to use.  can you describe your needs/timeline/etc... ?

QuoteReplyEditDelete

 

 

2010-03-27 15:21:29     Re: trouble getting started with SPI on BF537-STAMP

Hugh Shane (UNITED STATES)

Message: 87762   

 

I'm developing a Master's thesis at the University of Colorado Colorado Springs relating to use of MEMS IMUs for navigation in GPS-denied enviroments. I want to use the BF537-STAMP to acquire data from the ADIS16355 for subsequent desktop analysis. I need to begin my data collection effort no later than early this summer. I'm also a researcher with the MITRE Corporation and have a number of DoD customers who are interested in this technology should my research yield good results.

 

If A/D were to develop a driver for the IMU I'd be happy to be your beta tester

 

Hugh

QuoteReplyEditDelete

 

 

2010-03-27 15:30:02     Re: trouble getting started with SPI on BF537-STAMP

Hugh Shane (UNITED STATES)

Message: 87763   

 

Why not use the spidev driver? Because it's synchronous?

QuoteReplyEditDelete

 

 

2010-03-27 19:20:45     Re: trouble getting started with SPI on BF537-STAMP

Mike Frysinger (UNITED STATES)

Message: 87764   

 

spidev can support sync or async devices

 

devices that fit into existing frameworks get kernel drivers.  if you just wanted to read/write a data stream, then maybe spidev would be sufficient.  i'm not familiar with the part, so we'd have to review things to figure out the best place for it.

QuoteReplyEditDelete

 

 

2010-03-28 23:58:16     Re: trouble getting started with SPI on BF537-STAMP

Sonic Zhang (CHINA)

Message: 87777   

 

The IIO Linux driver for ADIS16355 has already been done in SVN trunk head. Check out the source code at   blackfin.uclinux.org/gf/project/linux-kernel/scmsvn/?action=browse&path=%2Ftrunk%2Fdrivers%2Fstaging%2Fiio%2Fimu%2F

 

You can also track driver develping status of ADI peripherals at   docs.blackfin.uclinux.org/doku.php?id=adi_peripheral_drivers

QuoteReplyEditDelete

 

 

2010-04-06 23:32:01     Re: trouble getting started with SPI on BF537-STAMP

Hugh Shane (UNITED STATES)

Message: 88155   

 

OK, so I've followed the instructions in   docs.blackfin.uclinux.org/doku.php?id=developing_with_blackfin_live_sources and should have everything I need to build a kernel from the trunk. How do I configure the kernel build to include the device driver for the ADIS16355? When I run make xconfig I don't see this option.

QuoteReplyEditDelete

 

 

2010-04-06 23:46:10     Re: trouble getting started with SPI on BF537-STAMP

Mike Frysinger (UNITED STATES)

Message: 88156   

 

the driver is only in svn trunk, and under the staging IIO area

QuoteReplyEditDelete

 

 

2010-04-07 07:12:54     Re: trouble getting started with SPI on BF537-STAMP

Hugh Shane (UNITED STATES)

Message: 88187   

 

Yes, I can see the driver code in uclinux-dist/linux-2.6.x/drivers/staging/iio/imu. But what steps do I need to take to have it incorporated into the kernel build?

QuoteReplyEditDelete

 

 

2010-04-08 21:37:37     Re: trouble getting started with SPI on BF537-STAMP

Mike Frysinger (UNITED STATES)

Message: 88234   

 

enable it in the kernel config like any other driver

QuoteReplyEditDelete

 

 

2010-04-09 00:20:43     Re: trouble getting started with SPI on BF537-STAMP

Hugh Shane (UNITED STATES)

Message: 88238   

 

OK, I found it in

 

Device Drivers -> Staging drivers -> Exclude Staging drivers from being built (unselect) -> Industrial I/O support -> Analog Devices ADIS16350/54/55/60/62/64/65 IMU SPI driver

 

Whew! Not for the uninitiated.

Attachments

    Outcomes