Am Donnerstag, den 23.08.2007, 09:01 -0600 schrieb Steve Strobel:
> I am working on a Blackfin 537 project running uClinux.  The BF537 has a 
> built-in hardware SPI port with up to seven slave select outputs, of which I 
> can use four or five (the others aren't available because they share I/O pins 
> with something else I need more).  I have 10 SPI devices I need to control.  
> I am looking for advice about the best way to access more SPI devices (the 
> way that will fit the best with how the Linux SPI driver works).  I can think 
> of 
> four options:
> 
>         #1:  Chain multiple SPI devices together like shift registers using 
> the 
>                same slave select.
>         #2:  Use GPIO lines as additional slave select outputs.
>         #3:  Use software and GPIO lines to make an additional bit-banged 
>                SPI interface for the slow devices.
>         #4:  Demultiplex the existing slave select outputs.
> 
> Option #1 is straightforward enough, but makes it difficult to write 
> independent 
> drivers if the chained devices serve different logical functions.  I suppose 
> it 
> would be possible to make separate drivers for each device, then make them 
> connect to a virtual SPI port that would combine the data for the different 
> devices into a longer data string and send it out to the chain of devices.  
> Does 
> Linux already have such a virtual SPI port?
> 
> Option #2:  It is easy enough to turn on a GPIO-based slave select before 
> causing an SPI transfer, but how can I tell when the transfer has finished 
> and 
> it is safe to turn it off?  Is there a hook in the SPI driver for that?
> 
> Option #3:  If I bit-bang GPIO lines to control not only the slave selects 
> (as 
> with option #2) but also the SPI data and clock signals, it will be easy to 
> control the sequence of events, but will be a lot slower than using the 
> hardware-assisted SPI interface.  Does Linux already have code for a 
> bit-banged SPI interface?  Where would I find docs for it?
> 
> Option #4:  I don't know if it is practical on the Blackfin or not.  What I 
> have 
> in mind is something like the way the 68HC16's queued SPI provides four 
> programmable slave selects that can be used individually to select one of 
> four devices, or demultiplexed to select one of up to 16 peripheral devices.  
> Does the Linux SPI driver provide a way to specify that a combination of 
> slave selects needs to be asserted to select a particular slave?
> 
> Thanks for any suggestions or advice.
> 
> Steve

Another idea #5:
you just need one "main" chipselect on the cpu, and an additional shift
register. 
1) With the chipselect inactive, send out an 8 bit pattern of
slave-select signals into the shift register. 
2) Activate the chipselect. This will transfer the shift register to the
output latches, and activate your peripherals chipselect.
3) now, the SPI transfer can take place, deactivating the "main"
chipselect clears the shiftregister and deactivates the peripherals
chipselect.

This is just the basic idea, the shift register can easily be
implemented in a PLD or in an external microcontroller as well. You can
use as many SPI peripherals as you like with only four SPI interface
lines on the cpu, and the overhead is very small. 

Regards,
Erwin


_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to