overlays: Add gpio-hog overlay
authorPhil Elwell <phil@raspberrypi.com>
Mon, 16 May 2022 11:16:46 +0000 (12:16 +0100)
committerPhil Elwell <phil@raspberrypi.com>
Mon, 16 May 2022 11:18:54 +0000 (12:18 +0100)
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
arch/arm/boot/dts/overlays/README
arch/arm/boot/dts/overlays/gpio-hog-overlay.dts [new file with mode: 0644]

index eacea8d..7177d3c 100644 (file)
@@ -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 \
index 8abbaef..88bec2b 100644 (file)
@@ -1061,6 +1061,17 @@ Params: gpiopin                 GPIO used to control the fan (default 12)
                                 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
diff --git a/arch/arm/boot/dts/overlays/gpio-hog-overlay.dts b/arch/arm/boot/dts/overlays/gpio-hog-overlay.dts
new file mode 100644 (file)
index 0000000..c9e3904
--- /dev/null
@@ -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?";
+       };
+};