2009-04-01 14:00:49 SPI SLAVE SELECT Expansion using GPIOs
Ashish Gupta (INDIA)
Message: 71977
SPI SLAVE SELECT Expansion using GPIOs
Hardware Scheme
We need 7 SPI SLAVE SELECT lines for our design for accessing various peripherals like SDCARD, LCD (ADI LCD Extender), TouchScreen controller (ADI LCD Extender) and SPI-GPIO expansion chips (). Since most of the SPISEL lines of BF527 processor are multiplexed with some other important functions like PPI (SPISEL2, SPISEL3, SPISEL6, SPISEL7) and ethernet (SPISEL4), we plan to use 3 GPIOs alongwith a 3:8 decoder to derive 8 lines to be used as SLAVE SELECTS. Three GPIOs PH10:PH9:PG1 are used as inputs to the 3:8 decoder to select one (out of 8) SPI slave device connected to the eight outputs of the decoder.
Software Approaches to handle the SPISEL Expansion
First approach:-
Develop a common driver code “custom_spidecoder.c” which provides API’s for these drivers (LCD, MMC/SD, touchscreen) to select the appropriate chip select. The steps to communicate with the slave device are in this order:-
1. custom_spi_cs_low(XX_CHIP_SELECT)
This function will drive the GPIO pins PH10:PH9:PG1 appropriately in order to enable the chip connected to "XX_CHIP_SELECT" and the device chip select info will be provided in the platform file for all SPI slaves, i.e. “linux-2.6.x/arch/blackfin/mach-bf527/boards/our_board.c”.
2. spi_write or spi_read
3. custom_spi_cs_high(XX_CHIP_SELECT)
So we will have to modify the existing SPI slave drivers for LCD, MMC/SD, touchscreen, GPIO-Expansion chips (all currently supported by the blackfin uClinux dist) use the new API.
Second Approach:-
modify the standard Linux SPI driver. We feel this approach is not good as it deviates from standard driver model and platform dependency.
Questions: -
Q1. Is there any existing mechanism in the SPI Driver to support something like this?
Q2. Of the two approaches, which one is better architechture-wise.
Note: We have provided support for expansion so that two new SPI SLAVE devices can be interfaced externally. So it would be nice if the the SPI SLAVE select mechanism allows easy inteegration of existing device drivers for new devices.
Looking forward for your comments
regards
Ashish Gupta
QuoteReplyEditDelete
2009-04-01 14:12:06 Re: SPI SLAVE SELECT Expansion using GPIOs
Mike Frysinger (UNITED STATES)
Message: 71978
the Blackfin SPI bus driver in svn trunk already supports using GPIOs as chip selects
QuoteReplyEditDelete
2009-04-11 06:05:18 Re: SPI SLAVE SELECT Expansion using GPIOs
Ashish Gupta (INDIA)
Message: 72535
Thanks Mike!
The SPI driver supports the GPIO as chip selects, but does it support selection of multiple GPIOs for selecting one device?
for example, following the hardware configuration described above for selecting device#7, we need to set 3 GPIOs high, since we are using a 3:8 decoder.
regards
Ashish
QuoteReplyEditDelete
2009-04-11 11:31:27 Re: SPI SLAVE SELECT Expansion using GPIOs
Mike Frysinger (UNITED STATES)
Message: 72536
no, there is no support at all for that as that isnt compatible with the SPI protocol