OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From e8a650fc27bf1e7d858c997fddd9944e6c222260 Mon Sep 17 00:00:00 2001 |
2 | From: Aaron Shaw <shawaj@gmail.com> |
||
3 | Date: Thu, 4 Jan 2018 15:02:16 +0000 |
||
4 | Subject: [PATCH 157/454] add gpio-key overlay (#2329) |
||
5 | |||
6 | An overlay that allows a Linux key to be bound to a GPIO. |
||
7 | --- |
||
8 | arch/arm/boot/dts/overlays/Makefile | 1 + |
||
9 | arch/arm/boot/dts/overlays/README | 21 ++++++++ |
||
10 | .../boot/dts/overlays/gpio-key-overlay.dts | 48 +++++++++++++++++++ |
||
11 | 3 files changed, 70 insertions(+) |
||
12 | create mode 100644 arch/arm/boot/dts/overlays/gpio-key-overlay.dts |
||
13 | |||
14 | --- a/arch/arm/boot/dts/overlays/Makefile |
||
15 | +++ b/arch/arm/boot/dts/overlays/Makefile |
||
16 | @@ -31,6 +31,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \ |
||
17 | googlevoicehat-soundcard.dtbo \ |
||
18 | gpio-ir.dtbo \ |
||
19 | gpio-ir-tx.dtbo \ |
||
20 | + gpio-key.dtbo \ |
||
21 | gpio-poweroff.dtbo \ |
||
22 | gpio-shutdown.dtbo \ |
||
23 | hifiberry-amp.dtbo \ |
||
24 | --- a/arch/arm/boot/dts/overlays/README |
||
25 | +++ b/arch/arm/boot/dts/overlays/README |
||
26 | @@ -515,6 +515,27 @@ Params: gpio_pin Output G |
||
27 | Default is "0" (active-high). |
||
28 | |||
29 | |||
30 | +Name: gpio-key |
||
31 | +Info: This is a generic overlay for activating GPIO keypresses using |
||
32 | + the gpio-keys library and this dtoverlay. Multiple keys can be |
||
33 | + set up using multiple calls to the overlay for configuring |
||
34 | + additional buttons or joysticks. You can see available keycodes |
||
35 | + at https://github.com/torvalds/linux/blob/v4.12/include/uapi/ |
||
36 | + linux/input-event-codes.h#L64 |
||
37 | +Load: dtoverlay=gpio-key,<param>=<val> |
||
38 | +Params: gpio GPIO pin to trigger on (default 3) |
||
39 | + active_low When this is 1 (active low), a falling |
||
40 | + edge generates a key down event and a |
||
41 | + rising edge generates a key up event. |
||
42 | + When this is 0 (active high), this is |
||
43 | + reversed. The default is 1 (active low) |
||
44 | + gpio_pull Desired pull-up/down state (off, down, up) |
||
45 | + Default is "up". Note that the default pin |
||
46 | + (GPIO3) has an external pullup |
||
47 | + label Set a label for the key |
||
48 | + keycode Set the key code for the button |
||
49 | + |
||
50 | + |
||
51 | Name: gpio-poweroff |
||
52 | Info: Drives a GPIO high or low on poweroff (including halt). Enabling this |
||
53 | overlay will prevent the ability to boot by driving GPIO3 low. |
||
54 | --- /dev/null |
||
55 | +++ b/arch/arm/boot/dts/overlays/gpio-key-overlay.dts |
||
56 | @@ -0,0 +1,48 @@ |
||
57 | +// Definitions for gpio-key module |
||
58 | +/dts-v1/; |
||
59 | +/plugin/; |
||
60 | + |
||
61 | +/ { |
||
62 | + compatible = "brcm,bcm2708"; |
||
63 | + |
||
64 | + fragment@0 { |
||
65 | + // Configure the gpio pin controller |
||
66 | + target = <&gpio>; |
||
67 | + __overlay__ { |
||
68 | + pin_state: button_pins@0 { |
||
69 | + brcm,pins = <3>; // gpio number |
||
70 | + brcm,function = <0>; // 0 = input, 1 = output |
||
71 | + brcm,pull = <2>; // 0 = none, 1 = pull down, 2 = pull up |
||
72 | + }; |
||
73 | + }; |
||
74 | + }; |
||
75 | + fragment@1 { |
||
76 | + target-path = "/"; |
||
77 | + __overlay__ { |
||
78 | + button: button@0 { |
||
79 | + compatible = "gpio-keys"; |
||
80 | + pinctrl-names = "default"; |
||
81 | + pinctrl-0 = <&pin_state>; |
||
82 | + status = "okay"; |
||
83 | + |
||
84 | + key: key { |
||
85 | + linux,code = <116>; |
||
86 | + gpios = <&gpio 3 1>; |
||
87 | + label = "KEY_POWER"; |
||
88 | + }; |
||
89 | + }; |
||
90 | + }; |
||
91 | + }; |
||
92 | + |
||
93 | + __overrides__ { |
||
94 | + gpio = <&key>,"gpios:4", |
||
95 | + <&button>,"reg:0", |
||
96 | + <&pin_state>,"brcm,pins:0", |
||
97 | + <&pin_state>,"reg:0"; |
||
98 | + label = <&key>,"label"; |
||
99 | + keycode = <&key>,"linux,code:0"; |
||
100 | + gpio_pull = <&pin_state>,"brcm,pull:0"; |
||
101 | + active_low = <&key>,"gpios:8"; |
||
102 | + }; |
||
103 | + |
||
104 | +}; |