Skip to content

Commit

Permalink
dtoverlays: enable SPI CS active-high
Browse files Browse the repository at this point in the history
The documentation isn't very clear explaining how to enable SPI CS
active-high and it takes a long time to understand it. Adding a specific
overlay as a simple example on how to invert this signal can help
understand the solution.

Link: https://forums.raspberrypi.com/viewtopic.php?t=378222
Signed-off-by: Iker Pedrosa <[email protected]>
  • Loading branch information
ikerexxe committed Nov 18, 2024
1 parent bf70ebd commit de56c9f
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions arch/arm/boot/dts/overlays/spi0-1cs-inverted-overlay.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/dts-v1/;
/plugin/;

/*
* There are some devices that need an inverted Chip Select (CS) to select the
* device signal, as an example the AZDelivery 12864 display. That means that
* the CS polarity is active-high. To invert the CS signal the DT needs to set
* the cs-gpio to GPIO_ACTIVE_HIGH (0) in the controller and set the
* spi-cs-high in the peripheral property. On top of that, since this is a
* display the DT also needs to specify the write-only property.
*/

/ {
compatible = "brcm,bcm2835";

fragment@0 {
target = <&spi0_cs_pins>;
frag0: __overlay__ {
brcm,pins = <8>;
};
};

fragment@1 {
target = <&spi0>;
frag1: __overlay__ {
cs-gpios = <&gpio 8 GPIO_ACTIVE_HIGH>;
status = "okay";
};
};

fragment@2 {
target = <&spidev1>;
__overlay__ {
status = "disabled";
};
};

fragment@3 {
target = <&spi0_pins>;
__dormant__ {
brcm,pins = <10 11>;
};
};

fragment@4 {
target = <&spidev0>;
__overlay__ {
spi-cs-high;
};
};

__overrides__ {
cs0_pin = <&frag0>,"brcm,pins:0",
<&frag1>,"cs-gpios:4";
no_miso = <0>,"=3";
};
};

0 comments on commit de56c9f

Please sign in to comment.