Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

MontaVista Linux SPI Driver

From Texas Instruments Wiki
Jump to: navigation, search


  • Serial interface
  • Synchronous
  • Master-slave configuration
  • Data Exchange - DMA/PIO

SPI H/W Architecture

SPI hardware architecture.jpg

SPI Driver Architecture

Spi driver architecture.jpg

OMAP-L137 EVM does not contain a SPI based audio codec. The reference to 'SPI Codec' above are meant to serve as an example.

Testing SPI driver

  • Use the MTD interface provided for SPI flash
dd if=/dev/mtd0 of=test.img bs=16k count=1
md5sum test.img
flash_eraseall /dev/mtd1
cp test.img /dev/mtd1
dd if=/dev/mtd1 of=test.img bs=16k count=1
md5sum test.img 
  • /dev/spi interface not supported in MontaVista Pro 5.0 kernel

Porting for custom hardware

  • drivers/spi/davinci_spi_master.c implements core SPI master functionality.
    • This file is generic, should not need to modify this.
  • board specific customizations in arch/arm/mach-da8xx/spi.c
  • Modify device array da8xx_spi_board_info0 to change information on slaves connected to SPI0. Use da8xx_spi_board_info1 for SPI1. When adding new slave devices, ensure that num_chipselect member of the platform data for the corresponding SPI master (da8xx_spi_pdata0 or da8xx_spi_pdata0). Note: The SPI master is only capable of interfacing with one slave in DMA mode. In PIO mode, it can interface to any number of slaves.
    • Each member is of type spi_board_info defined in include/linux/spi. Each element of the device array represents one slave device.
      • modalias used to match slave device to slave driver. Note that this is not the SPI master driver. Each slave needs to have its own driver. Example, SPI flash will have a MTD driver, SPI codec will have an ALSA driver etc.
      • platform_data used by slave driver
      • controller_data used by SPI master driver for slave specific information (of type davinci_spi_config_t). This is used to take care of specific requirements of communicating with a given slave.
      • bus_num 0 for SPI0, 1 for SPI1
      • chip_select chip select number for this SPI slave
      • max_speed_hz SPI bus speed.
  • Some of SPI chip selects can be driven by GPIO. Define chip_sel array in platform data for SPI master. da8xx_spi_pdata0 for SPI0 and da8xx_spi_pdata1 for SPI1.
    • If chip_sel[n] = DAVINCI_SPI_INTERN_CS, use IP chip select. If equal to GPIO num, use specified GPIO for chip select.
    • GPIO num = (16 * bank number) + (gpio num)
  • Ensure all pins required for SPI operation are muxed correctly (especially if using GPIO for CS)
    • use da8xx_evm_pinmux_override in arch/arm/mach-da8xx/board-evm.c to specify pin requirements.
    • See evm_spi1_pins as an example.