Using gpio2[4] as chip select 2 for SPI1

Howdy.

I came into possession of a mikroBUS Cape (http://beagleboard.org/project/mikrobus) and have been using it to learn how to write a .dts overlay. Since there are 4 slots for clickboards on the cape and I have 4 SPI boards (4-20mA T Click), I figured I’d try to create a single .dts that exposed all 4 as SPI devices.

Ignoring SPI0 (routed to “Host 3” on the mikroBUS Cape) for now, I have Host 1 and Host 2 working. These map directly to SPI1.0 and SPI1.1, but I cannot get a “SPI1.2” enabled (Host4). The mikroBUS Cape schematic shows that chipselect for Host 4 is routed to P8.10, so I thought I could add that pin (gpio2_4) as OUTPUT_PULLUP | MODE 7, and then simply add a third fragment for the third chipselect.

spi1@2 {
#address-cells = <1>;
#size-cells = <0>;
compatible = “spidev”;
reg = <2>;
spi-max-frequency = <16000000>;
spi-cpol;
spi-cpha;
};

Unfortunately this fails with a “cs2 >= max2” error when I load the overlay.

Reading around I’m trying to figure out, okay, how do I increase the number of SPI devices on the SPI1 bus. I’ve read about:

num-cs
num-chipselects
cs-gpios

When using cs-gpios like this:

cs-gpios = <0>, <1>, <&gpio3 4 0>;

I get

[ 171.494015] /ocp/spi@481a0000: could not get #gpio-cells for /ocp/interrupt-controller@48200000

My complete dts is at http://pastebin.com/BvxZ3fa2

TL;DR: How can I enable a 3rd chipselect for SPI1 where the CS is mapped to P8.11 (gpio2[4])?

Edit: P8.10 (gpio2[4]) is the chipselect line I’m trying to create

It turns that the spi-omap2 driver in Linux 4.1 does not support GPIO chip selects. However, Linux 4.3 rc7 supports it with a patch. I wrote up details on using the mikroBUS Cape with 4 SPI devices here: http://dev.iachieved.it/iachievedit/adventures-in-beaglebone-black-device-overlays-and-spi/

and explain the patch to the spi-omap2 driver here: http://dev.iachieved.it/iachievedit/gpio-chip-selects-with-the-beaglebone/

Hopefully it’s useful to someone wrestling with multiple SPI devices on the BeagleBone.

Joe

thx :slight_smile: helped me out heaps