Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / arch / arm / boot / dts / overlays / gpio-shutdown-overlay.dts
1 // Definitions for gpio-poweroff module
2 /dts-v1/;
3 /plugin/;
4
5 // This overlay sets up an input device that generates KEY_POWER events
6 // when a given GPIO pin changes. It defaults to using GPIO3, which can
7 // also be used to wake up (start) the Rpi again after shutdown.
8 // Raspberry Pi 1 Model B rev 1 can be wake up only by GPIO1 pin, so for
9 // these boards change default GPIO pin to 1 via gpio_pin parameter. Since
10 // wakeup is active-low, this defaults to active-low with a pullup
11 // enabled, but all of this can be changed using overlay parameters (but
12 // note that GPIO3 has an external pullup on at least some boards).
13
14 / {
15         compatible = "brcm,bcm2835";
16
17         fragment@0 {
18                 // Configure the gpio pin controller
19                 target = <&gpio>;
20                 __overlay__ {
21                         // Define a pinctrl state, that sets up the gpio
22                         // as an input with a pullup enabled. This does
23                         // not take effect by itself, only when referenced
24                         // by a "pinctrl client", as is done below. See:
25                         //   https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
26                         //   https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/brcm,bcm2835-gpio.txt
27                         pin_state: shutdown_button_pins@3 {
28                                 brcm,pins = <3>; // gpio number
29                                 brcm,function = <0>; // 0 = input, 1 = output
30                                 brcm,pull = <2>; // 0 = none, 1 = pull down, 2 = pull up
31                         };
32                 };
33         };
34         fragment@1 {
35                 // Add a new device to the /soc devicetree node
36                 target-path = "/soc";
37                 __overlay__ {
38                         shutdown_button: shutdown_button@3 {
39                                 // Let the gpio-keys driver handle this device. See:
40                                 // https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt
41                                 compatible = "gpio-keys";
42
43                                 // Declare a single pinctrl state (referencing the one declared above) and name it
44                                 // default, so it is activated automatically.
45                                 pinctrl-names = "default";
46                                 pinctrl-0 = <&pin_state>;
47
48                                 // Enable this device
49                                 status = "okay";
50
51                                 // Define a single key, called "shutdown" that monitors the gpio and sends KEY_POWER
52                                 // (keycode 116, see
53                                 // https://github.com/torvalds/linux/blob/v4.12/include/uapi/linux/input-event-codes.h#L190)
54                                 button: shutdown {
55                                         label = "shutdown";
56                                         linux,code = <116>; // KEY_POWER
57                                         gpios = <&gpio 3 1>;
58                                         debounce-interval = <100>; // ms
59                                 };
60                         };
61                 };
62         };
63
64         // This defines parameters that can be specified when loading
65         // the overlay. Each foo = line specifies one parameter, named
66         // foo. The rest of the specification gives properties where the
67         // parameter value is inserted into (changing the values above
68         // or adding new ones).
69         __overrides__ {
70                 // Allow overriding the GPIO number.
71                 gpio_pin = <&button>,"gpios:4",
72                            <&shutdown_button>,"reg:0",
73                            <&pin_state>,"reg:0",
74                            <&pin_state>,"brcm,pins:0";
75
76                 // Allow changing the internal pullup/down state. 0 = none, 1 = pulldown, 2 = pullup
77                 // Note that GPIO3 and GPIO2 are the I2c pins and have an external pullup (at least
78                 // on some boards). Same applies for GPIO1 on Raspberry Pi 1 Model B rev 1.
79                 gpio_pull = <&pin_state>,"brcm,pull:0";
80
81                 // Allow setting the active_low flag. 0 = active high, 1 = active low
82                 active_low = <&button>,"gpios:8";
83                 debounce = <&button>,"debounce-interval:0";
84         };
85
86 };