mirror of
				https://github.com/Ysurac/openmptcprouter.git
				synced 2025-03-09 15:40:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			114 lines
		
	
	
	
		
			3.9 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
	
		
			3.9 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From fb193abe0f00c45b7959f6bcce7d5feb173604f9 Mon Sep 17 00:00:00 2001
 | |
| From: Aaron Shaw <shawaj@gmail.com>
 | |
| Date: Thu, 4 Jan 2018 15:02:16 +0000
 | |
| Subject: [PATCH 175/277] add gpio-key overlay (#2329)
 | |
| 
 | |
| An overlay that allows a Linux key to be bound to a GPIO.
 | |
| ---
 | |
|  arch/arm/boot/dts/overlays/Makefile             |  1 +
 | |
|  arch/arm/boot/dts/overlays/README               | 21 +++++++++++
 | |
|  arch/arm/boot/dts/overlays/gpio-key-overlay.dts | 48 +++++++++++++++++++++++++
 | |
|  3 files changed, 70 insertions(+)
 | |
|  create mode 100644 arch/arm/boot/dts/overlays/gpio-key-overlay.dts
 | |
| 
 | |
| diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile
 | |
| index 7aa703e938c0..05661168a7bf 100644
 | |
| --- a/arch/arm/boot/dts/overlays/Makefile
 | |
| +++ b/arch/arm/boot/dts/overlays/Makefile
 | |
| @@ -31,6 +31,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 | |
|  	googlevoicehat-soundcard.dtbo \
 | |
|  	gpio-ir.dtbo \
 | |
|  	gpio-ir-tx.dtbo \
 | |
| +	gpio-key.dtbo \
 | |
|  	gpio-poweroff.dtbo \
 | |
|  	gpio-shutdown.dtbo \
 | |
|  	hifiberry-amp.dtbo \
 | |
| diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README
 | |
| index b8a2f3fdf732..2ad2397348e8 100644
 | |
| --- a/arch/arm/boot/dts/overlays/README
 | |
| +++ b/arch/arm/boot/dts/overlays/README
 | |
| @@ -515,6 +515,27 @@ Params: gpio_pin                Output GPIO (default 18)
 | |
|                                  Default is "0" (active-high).
 | |
|  
 | |
|  
 | |
| +Name:   gpio-key
 | |
| +Info:   This is a generic overlay for activating GPIO keypresses using
 | |
| +        the gpio-keys library and this dtoverlay. Multiple keys can be
 | |
| +        set up using multiple calls to the overlay for configuring
 | |
| +        additional buttons or joysticks. You can see available keycodes
 | |
| +        at https://github.com/torvalds/linux/blob/v4.12/include/uapi/
 | |
| +        linux/input-event-codes.h#L64
 | |
| +Load:   dtoverlay=gpio-key,<param>=<val>
 | |
| +Params: gpio                    GPIO pin to trigger on (default 3)
 | |
| +        active_low              When this is 1 (active low), a falling
 | |
| +                                edge generates a key down event and a
 | |
| +                                rising edge generates a key up event.
 | |
| +                                When this is 0 (active high), this is
 | |
| +                                reversed. The default is 1 (active low)
 | |
| +        gpio_pull               Desired pull-up/down state (off, down, up)
 | |
| +                                Default is "up". Note that the default pin
 | |
| +                                (GPIO3) has an external pullup
 | |
| +        label                   Set a label for the key
 | |
| +        keycode                 Set the key code for the button
 | |
| +
 | |
| +
 | |
|  Name:   gpio-poweroff
 | |
|  Info:   Drives a GPIO high or low on poweroff (including halt). Enabling this
 | |
|          overlay will prevent the ability to boot by driving GPIO3 low.
 | |
| diff --git a/arch/arm/boot/dts/overlays/gpio-key-overlay.dts b/arch/arm/boot/dts/overlays/gpio-key-overlay.dts
 | |
| new file mode 100644
 | |
| index 000000000000..333d016d6f02
 | |
| --- /dev/null
 | |
| +++ b/arch/arm/boot/dts/overlays/gpio-key-overlay.dts
 | |
| @@ -0,0 +1,48 @@
 | |
| +// Definitions for gpio-key module
 | |
| +/dts-v1/;
 | |
| +/plugin/;
 | |
| +
 | |
| +/ {
 | |
| +	compatible = "brcm,bcm2708";
 | |
| +
 | |
| +	fragment@0 {
 | |
| +		// Configure the gpio pin controller
 | |
| +		target = <&gpio>;
 | |
| +		__overlay__ {
 | |
| +			pin_state: button_pins@0 {
 | |
| +				brcm,pins = <3>; // gpio number
 | |
| +				brcm,function = <0>; // 0 = input, 1 = output
 | |
| +				brcm,pull = <2>; // 0 = none, 1 = pull down, 2 = pull up
 | |
| +			};
 | |
| +		};
 | |
| +	};
 | |
| +	fragment@1 {
 | |
| +		target-path = "/";
 | |
| +		__overlay__ {
 | |
| +			button: button@0 {
 | |
| +				compatible = "gpio-keys";
 | |
| +				pinctrl-names = "default";
 | |
| +				pinctrl-0 = <&pin_state>;
 | |
| +				status = "okay";
 | |
| +
 | |
| +				key: key {
 | |
| +					linux,code = <116>;
 | |
| +					gpios = <&gpio 3 1>;
 | |
| +					label = "KEY_POWER";
 | |
| +				};
 | |
| +			};
 | |
| +		};
 | |
| +	};
 | |
| +
 | |
| +	__overrides__ {
 | |
| +		gpio =       <&key>,"gpios:4",
 | |
| +		             <&button>,"reg:0",
 | |
| +		             <&pin_state>,"brcm,pins:0",
 | |
| +		             <&pin_state>,"reg:0";
 | |
| +		label =      <&key>,"label";
 | |
| +		keycode =    <&key>,"linux,code:0";
 | |
| +		gpio_pull =  <&pin_state>,"brcm,pull:0";
 | |
| +		active_low = <&key>,"gpios:8";
 | |
| +	};
 | |
| +
 | |
| +};
 | |
| -- 
 | |
| 2.16.1
 | |
| 
 |