The raspberry pi SPI0 by default has 2 CS pins configured. The SPI driver in the kernel uses GPIOS toggled by software, rather than hardware controlled chip selects. This means that any GPIO can be used for a chip select, and any number of them can be supported concurrently. All of these setup for the SPI driver is defined in the device tree, and we can use device tree overlays stored in /boot to dynamically configure the device tree.
The attached example creates a SPI device with 5 CS pins, on GPIO 8, 7, 1, 5, and 6.
To compile it to a binary:
dtc -@ -I dts -O dtb -o spi-cs-extend.dtbo spi-cs-extend.dts
Then place spi-cs-extend.dtbo
into /boot/overlays
and add the following line to your /boot/config.txt
:
dtoverlay=spi-cs-extend
.
After your next reboot, you should find /dev/spi0.2
, /dev/spi0.3
, and /dev/spi0.4
have been created.
Great I'm glad it helped! Thanks for letting me know.