I'm using a Raspberry Pi 3 B+ and I need to use 4 SPI devices so I followed PhilE's
viewtopic.php?t=98318&start=25#p821666 suggestion to create a Device Tree overlay. This didn't work. It broke the existing chip select pins. I eventually got it working with a few tweaks. I thought I'd post it here for anyone who ends up in the same boat.
I happen to be using pins 24 and 25 but I don't believe that's significant.
Code: Select all
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&spi0>;
frag0: __overlay__ {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
status = "okay";
cs-gpios = <&gpio 8 1>, <&gpio 7 1>, <&gpio 24 1>, <&gpio 25 1>;
spidev@2{
compatible = "spidev";
reg = <2>; /* CE2 */
#address-cells = <1>;
#size-cells = <0>;
spi-tx-bus-width = <2>;
spi-rx-bus-width = <2>;
spi-max-frequency = <125000000>;
};
spidev@3{
compatible = "spidev";
reg = <3>; /* CE3 */
#address-cells = <1>;
#size-cells = <0>;
spi-tx-bus-width = <2>;
spi-rx-bus-width = <2>;
spi-max-frequency = <125000000>;
};
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
spi0_cs_pins: spi0_cs_pins {
brcm,pins = <8 7 24 25>;
brcm,function = <1>; /* out */
};
};
};
__overrides__ {
cs2_pin = <&frag0>,"cs-gpios:12", <&spi0_cs_pins>,"brcm,pins:0";
cs3_pin = <&frag0>,"cs-gpios:24", <&spi0_cs_pins>,"brcm,pins:4";
};
};
cheers,
Richard