aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.15/950-0913-overlays-Add-gpio-hog-overlay.patch
blob: 47a99dbe15062eff90ac1ab3207e244b52c9427e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From a2948fd59692f1d30ce64035bed33b32997a0ad7 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Mon, 16 May 2022 12:16:46 +0100
Subject: [PATCH] overlays: Add gpio-hog overlay

Add an overlay to activate a hog on a specified pin. Note that
hogged GPIOs are not available for other uses, i.e. drivers or
gpioset/gpioget.

Inspired by a Forum thread here:

    https://forums.raspberrypi.com/viewtopic.php?t=334286

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             | 11 ++++++++
 .../boot/dts/overlays/gpio-hog-overlay.dts    | 27 +++++++++++++++++++
 3 files changed, 39 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/gpio-hog-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -59,6 +59,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	goodix.dtbo \
 	googlevoicehat-soundcard.dtbo \
 	gpio-fan.dtbo \
+	gpio-hog.dtbo \
 	gpio-ir.dtbo \
 	gpio-ir-tx.dtbo \
 	gpio-key.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1061,6 +1061,17 @@ Params: gpiopin                 GPIO use
                                 millicelcius (default 55000)
 
 
+Name:   gpio-hog
+Info:   Activate a "hog" for a GPIO - request that the kernel configures it as
+        an output, driven low or high as indicated by the presence or absence
+        of the active_low parameter. Note that a hogged GPIO is not available
+        to other drivers or for gpioset/gpioget.
+Load:   dtoverlay=gpio-hog,<param>=<val>
+Params: gpio                    GPIO pin to hog (default 26)
+        active_low              If set, the hog drives the GPIO low (defaults
+                                to off - the GPIO is driven high)
+
+
 Name:   gpio-ir
 Info:   Use GPIO pin as rc-core style infrared receiver input. The rc-core-
         based gpio_ir_recv driver maps received keys directly to a
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/gpio-hog-overlay.dts
@@ -0,0 +1,27 @@
+// Configure a "hog" on the specified GPIO
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&gpio>;
+		__overlay__ {
+			hog: hog@1a {
+			     gpio-hog;
+			     gpios = <26 GPIO_ACTIVE_HIGH>;
+			     output-high;
+			};
+		};
+	};
+
+	__overrides__ {
+		gpio =       <&hog>,"reg:0",
+		             <&hog>,"gpios:0";
+		active_low = <&hog>,"output-high!",
+			     <&hog>,"output-low?";
+	};
+};