-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
overlays: Add gpio-shutdown overlay #2103
overlays: Add gpio-shutdown overlay #2103
Conversation
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
The kernel patches build the overlay as expected. Nice job, especially on the comments. |
Thanks, great to have it merged so fast :-D |
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
kernel: usb: gadget: f_hid: fix: Move IN request allocation to set_alt() See: raspberrypi/linux#1943 kernel: overlays: Add gpio-shutdown overlay See: raspberrypi/linux#2103 kernel: config: enable generic S/PDIF codec drivers See: raspberrypi/linux#2104 kernel: drm/vc4: firmwarekms DPMS support See: raspberrypi/linux#2102
kernel: usb: gadget: f_hid: fix: Move IN request allocation to set_alt() See: raspberrypi/linux#1943 kernel: overlays: Add gpio-shutdown overlay See: raspberrypi/linux#2103 kernel: config: enable generic S/PDIF codec drivers See: raspberrypi/linux#2104 kernel: drm/vc4: firmwarekms DPMS support See: raspberrypi/linux#2102
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
This overlay facilitates the addition of a powerbutton by converting GPIO edges into KEY_POWER keypresses, which can be handled by systemd-logind to shut down the system. Signed-off-by: Matthijs Kooijman <[email protected]>
Overlay in this pull request does not work for RPI 1 rev 1. RPI 1 rev 1 uses GPIO1 instead of GPIO3. I modified original overlay for RPI 1 rev 1 by applying following diff and then it start working on RPI 1 rev 1 too: --- gpio-shutdown-overlay.dts 2017-07-07 02:09:12.000000000 +0200
+++ gpio-shutdown-rpi1-overlay.dts 2018-12-25 14:58:42.000000000 +0100
@@ -1,13 +1,14 @@
// Definitions for gpio-poweroff module
+// Modified for RPI 1 rev 1 (changed GPIO3 to gpio GPIO1)
/dts-v1/;
/plugin/;
// This overlay sets up an input device that generates KEY_POWER events
-// when a given GPIO pin changes. It defaults to using GPIO3, which can
+// when a given GPIO pin changes. It defaults to using GPIO1, which can
// also be used to wake up (start) the Rpi again after shutdown. Since
// wakeup is active-low, this defaults to active-low with a pullup
// enabled, but all of this can be changed using overlay parameters (but
-// note that GPIO3 has an external pullup on at least some boards).
+// note that GPIO1 has an external pullup on at least some boards).
/ {
compatible = "brcm,bcm2708";
@@ -22,8 +23,8 @@
// by a "pinctrl client", as is done below. See:
// https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
// https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/brcm,bcm2835-gpio.txt
- pin_state: shutdown_button_pins {
- brcm,pins = <3>; // gpio number
+ pin_state: shutdown_button_rpi1_pins {
+ brcm,pins = <1>; // gpio number
brcm,function = <0>; // 0 = input, 1 = output
brcm,pull = <2>; // 0 = none, 1 = pull down, 2 = pull up
};
@@ -33,7 +34,7 @@
// Add a new device to the /soc devicetree node
target-path = "/soc";
__overlay__ {
- shutdown_button {
+ shutdown_button_rpi1 {
// Let the gpio-keys driver handle this device. See:
// https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt
compatible = "gpio-keys";
@@ -49,10 +50,10 @@
// Define a single key, called "shutdown" that monitors the gpio and sends KEY_POWER
// (keycode 116, see
// https://github.com/torvalds/linux/blob/v4.12/include/uapi/linux/input-event-codes.h#L190)
- button: shutdown {
- label = "shutdown";
+ button: shutdown_rpi1 {
+ label = "shutdown_rpi1";
linux,code = <116>; // KEY_POWER
- gpios = <&gpio 3 1>;
+ gpios = <&gpio 1 1>;
};
};
};
@@ -69,7 +70,7 @@
<&pin_state>,"brcm,pins:0";
// Allow changing the internal pullup/down state. 0 = none, 1 = pulldown, 2 = pullup
- // Note that GPIO3 and GPIO2 are the I2c pins and have an external pullup (at least
+ // Note that GPIO1 and GPIO0 are the I2c pins and have an external pullup (at least
// on some boards).
gpio_pull = <&pin_state>,"brcm,pull:0";
|
Rather than modifying the overlay, you can just specify a different GPIO as an argument. E.g.
Or did you try this and did it not work? It might be good to add this to the documentation somewhere (i.e. that this version needs gpio1 rather than 3). |
@matthijskooijman Thank you for saving me the typing! |
@matthijskooijman I have not know that it is possible to specify different GPIO... Where to write that line? Directly to config.txt, replacing my current |
The former. See also the docs |
@matthijskooijman Now I tested So thanks for simplification of setup for my RPI 1 rev 1. What about updating that README file by adding a note that for RPI 1 rev 1 it is needed to change |
This overlay facilitates the addition of a powerbutton by converting
GPIO edges into KEY_POWER keypresses, which can be handled by
systemd-logind to shut down the system.
The overlay was separately tested on:
I tested manually using
dtc -@ -I dts -O dtb -o gpio-shutdown.dtbo gpio-shutdown-overlay.dts
. I did not test compilation inside the kernel tree, for I have not got the environment set up for that.For some more background, see the comments in the overlay source file and this blogpost: http://www.stderr.nl/Blog/Hardware/RaspberryPi/PowerButton.html