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)
6 An overlay that allows a Linux key to be bound to a GPIO.
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
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 \
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).
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
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.
55 +++ b/arch/arm/boot/dts/overlays/gpio-key-overlay.dts
57 +// Definitions for gpio-key module
62 + compatible = "brcm,bcm2708";
65 + // Configure the gpio pin controller
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
79 + compatible = "gpio-keys";
80 + pinctrl-names = "default";
81 + pinctrl-0 = <&pin_state>;
86 + gpios = <&gpio 3 1>;
87 + label = "KEY_POWER";
94 + gpio = <&key>,"gpios:4",
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";