Skip to content

Commit

Permalink
overlays: Add gpio-hog overlay
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pelwell committed May 16, 2022
1 parent 1125a6a commit d187e64
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm/boot/dts/overlays/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
11 changes: 11 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions arch/arm/boot/dts/overlays/gpio-hog-overlay.dts
Original file line number Diff line number Diff line change
@@ -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?";
};
};

0 comments on commit d187e64

Please sign in to comment.