Skip to content

Commit a7da3d9

Browse files
committed
add gpio-key overlay
1 parent d19642c commit a7da3d9

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

arch/arm/boot/dts/overlays/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
3030
goodix.dtbo \
3131
googlevoicehat-soundcard.dtbo \
3232
gpio-ir.dtbo \
33+
gpio-key.dtbo \
3334
gpio-poweroff.dtbo \
3435
gpio-shutdown.dtbo \
3536
hifiberry-amp.dtbo \

arch/arm/boot/dts/overlays/README

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,26 @@ Params: gpio_pin Input pin number. Default is 18.
503503
rc-map-name Default rc keymap (can also be changed by
504504
ir-keytable), defaults to "rc-rc6-mce"
505505

506+
Name: gpio-key
507+
Info: This is a generic overlay for activating GPIO keypresses using
508+
the gpio-keys library and this dtoverlay. Multiple keys can be
509+
set up using multiple calls to the overlay for configuring
510+
additional buttons or joysticks. You can see available keycodes
511+
at https://github.com/torvalds/linux/blob/v4.12/include/uapi/
512+
linux/input-event-codes.h#L64
513+
Load: dtoverlay=gpio-key,<param>=<val>
514+
Params: gpio GPIO pin to trigger on (default 3)
515+
active_low When this is 1 (active low), a falling
516+
edge generates a key down event and a
517+
rising edge generates a key up event.
518+
When this is 0 (active high), this is
519+
reversed. The default is 1 (active low)
520+
gpio_pull Desired pull-up/down state (off, down, up)
521+
Default is "up". Note that the default pin
522+
(GPIO3) has an external pullup
523+
label Set a label for the key
524+
keycode Set the key code for the button
525+
506526

507527
Name: gpio-poweroff
508528
Info: Drives a GPIO high or low on poweroff (including halt). Enabling this
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Definitions for gpio-key module
2+
/dts-v1/;
3+
/plugin/;
4+
5+
/ {
6+
compatible = "brcm,bcm2708";
7+
8+
fragment@0 {
9+
// Configure the gpio pin controller
10+
target = <&gpio>;
11+
__overlay__ {
12+
pin_state: button_pins {
13+
brcm,pins = <3>; // gpio number
14+
brcm,function = <0>; // 0 = input, 1 = output
15+
brcm,pull = <2>; // 0 = none, 1 = pull down, 2 = pull up
16+
};
17+
};
18+
};
19+
fragment@1 {
20+
target-path = "/soc";
21+
__overlay__ {
22+
button {
23+
compatible = "gpio-keys";
24+
#address-cells = <1>;
25+
#size-cells = <0>;
26+
pinctrl-names = "default";
27+
pinctrl-0 = <&pin_state>;
28+
status = "okay";
29+
30+
key@0 {
31+
reg = < 0 >;
32+
linux,code = <116>;
33+
gpios = <&gpio 3 1>;
34+
label = "KEY_POWER";
35+
};
36+
};
37+
};
38+
};
39+
40+
__overrides__ {
41+
gpio = <&key>,"gpios:4",
42+
<&key>,"reg:0",
43+
<&pin_state>,"brcm,pins:0";
44+
label = <&key>,"label";
45+
keycode = <&key>,"linux,code:0"
46+
gpio_pull = <&pin_state>,"brcm,pull:0";
47+
active_low = <&key>,"gpios:8";
48+
};
49+
50+
};

0 commit comments

Comments
 (0)