openwrt/target/linux/bcm27xx/patches-6.6/950-1398-dtoverlays-enable-SPI-CS-active-high.patch
Álvaro Fernández Rojas 3a5584e0df bcm27xx: pull 6.6 patches from RPi repo
Adds latest 6.6 patches from the Raspberry Pi repository.

These patches were generated from:
https://github.com/raspberrypi/linux/commits/rpi-6.6.y/
With the following command:
git format-patch -N v6.6.67..HEAD
(HEAD -> 811ff707533bcd67cdcd368bbd46223082009b12)

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
(cherry picked from commit 692205305db14deeff1a2dc4a6d7f87e19fc418b)
2024-12-28 14:11:52 +01:00

109 lines
3.0 KiB
Diff

From dbf12796d1368286672529d7b03f81066a8c36f3 Mon Sep 17 00:00:00 2001
From: Iker Pedrosa <ikerpedrosam@gmail.com>
Date: Mon, 18 Nov 2024 10:55:33 +0100
Subject: [PATCH] dtoverlays: enable SPI CS active-high
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 <ikerpedrosam@gmail.com>
---
arch/arm/boot/dts/overlays/Makefile | 1 +
arch/arm/boot/dts/overlays/README | 8 +++
.../overlays/spi0-1cs-inverted-overlay.dts | 59 +++++++++++++++++++
3 files changed, 68 insertions(+)
create mode 100644 arch/arm/boot/dts/overlays/spi0-1cs-inverted-overlay.dts
--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -259,6 +259,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
spi-rtc.dtbo \
spi0-0cs.dtbo \
spi0-1cs.dtbo \
+ spi0-1cs-inverted.dtbo \
spi0-2cs.dtbo \
spi1-1cs.dtbo \
spi1-2cs.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -4438,6 +4438,14 @@ Params: cs0_pin GPIO pin
it for other uses.
+Name: spi0-1cs-inverted
+Info: Only use one CS pin for SPI0 and set to active-high
+Load: dtoverlay=spi0-1cs-inverted,<param>=<val>
+Params: cs0_pin GPIO pin for CS0 (default 8)
+ no_miso Don't claim and use the MISO pin (9), freeing
+ it for other uses.
+
+
Name: spi0-2cs
Info: Change the CS pins for SPI0
Load: dtoverlay=spi0-2cs,<param>=<val>
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/spi0-1cs-inverted-overlay.dts
@@ -0,0 +1,59 @@
+/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.
+*/
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+ 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";
+ };
+};