Help about chip select on SPI slave devices
tiejun.chen
tiejun.chen at windriver.com
Mon Oct 18 19:17:34 EST 2010
WANG YiFei wrote:
> Hi,
>
> We have a board which has 1 SPI master controller and 4 SPI slave devices, and we'd like to use 2 GPIOs to demux to chip select these slave devices.
> Can anyone tell me if current powerpc dts support demuxer for chip select for spi slave devices? So far as I know, in dts, SPI master can only use 1 to 1 GPIO to CS(then needs 4 GPIOs).
It may be unnecessary to add other device property on the dts for your purpose.
You can still get those original 2 gpios defined on the dts by default, but pass
'4' to num_chipselect of your SPI master when probe SPI master. This will 'tell'
kernel there are 4 kind chipselect signals for SPI sub-system. When the new SPI
device is added, the kernel would acquire the number which chip should be
activated by parsing chip_select of that corresponding spi_device. Then the
kernel call your chipselect defined with struct spi_bitbang to set gpio. (Often
we use gpio API gpio_set_value). On there you can determine how gpio_set_value()
are called according to your SPI device chip_select.
For example,
------
NO.0 Chip ==> gpio_set_value(PIN0, 0); gpio_set_value(PIN1, 0)
NO.1 Chip ==> gpio_set_value(PIN0, 0); gpio_set_value(PIN1, 1)
NO.2 Chip ==> gpio_set_value(PIN0, 1); gpio_set_value(PIN1, 0)
NO.3 Chip ==> gpio_set_value(PIN0, 1); gpio_set_value(PIN1, 1)
Tiejun
>
>
> Thanks in advance,
> YiFei
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
More information about the Linuxppc-dev
mailing list