2021-10-25 18:08:26

by Kieran Bingham

[permalink] [raw]
Subject: [PATCH v2] arm64: dts: renesas: r8a779a0: falcon-cpu: Add SW46 switch support

From: Kieran Bingham <[email protected]>

Add support for SW46-1 and SW46-2 as switches using the gpio-keys
framework.

Signed-off-by: Kieran Bingham <[email protected]>
---
v2:
- Don't adjust the pin-config bias

SW_LID and SW_DOCK are selected as low-impact switch events for the
default configuration. Would SW_RFKILL_ALL, and SW_MUTE_DEVICE be
preferred as more 'functional' defaults? (I have otherwise avoided these
to hopefully prevent unwanted / undocumented effects occuring on
development hardware running a full interface which may parse these)

I'd expect them to be overridden by any platform using them anyway.

Testing this with evtest on the board shows this:

kbingham@falcon-v3u:~$ sudo evtest /dev/input/by-path/platform-keys-event
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "keys"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 2 (KEY_1)
Event code 3 (KEY_2)
Event code 4 (KEY_3)
Event type 5 (EV_SW)
Event code 0 (SW_LID) state 0
Event code 5 (SW_DOCK) state 0
Properties:
Testing ... (interrupt to exit)
Event: time 1635166698.832665, type 5 (EV_SW), code 5 (SW_DOCK), value 1
Event: time 1635166698.832665, -------------- SYN_REPORT ------------
Event: time 1635166701.661119, type 5 (EV_SW), code 0 (SW_LID), value 1
Event: time 1635166701.661119, -------------- SYN_REPORT ------------
Event: time 1635166711.453056, type 5 (EV_SW), code 5 (SW_DOCK), value 0
Event: time 1635166711.453056, -------------- SYN_REPORT ------------
Event: time 1635166712.791572, type 5 (EV_SW), code 0 (SW_LID), value 0
Event: time 1635166712.791572, -------------- SYN_REPORT ------------

.../boot/dts/renesas/r8a779a0-falcon-cpu.dtsi | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi b/arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi
index 1fe0cf0dcc99..0ca21a057530 100644
--- a/arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi
@@ -83,6 +83,24 @@ keys {
pinctrl-0 = <&keys_pins>;
pinctrl-names = "default";

+ sw-1 {
+ gpios = <&gpio1 28 GPIO_ACTIVE_LOW>;
+ linux,code = <SW_LID>;
+ linux,input-type = <EV_SW>;
+ label = "SW46-1";
+ wakeup-source;
+ debounce-interval = <20>;
+ };
+
+ sw-2 {
+ gpios = <&gpio1 29 GPIO_ACTIVE_LOW>;
+ linux,code = <SW_DOCK>;
+ linux,input-type = <EV_SW>;
+ label = "SW46-2";
+ wakeup-source;
+ debounce-interval = <20>;
+ };
+
key-1 {
gpios = <&gpio6 18 GPIO_ACTIVE_LOW>;
linux,code = <KEY_1>;
--
2.30.2


2021-11-04 17:57:09

by Kieran Bingham

[permalink] [raw]
Subject: [PATCH] Input: add 'safe' user switch codes

All existing SW input codes define an action which can be interpreted by
a user environment to adapt to the condition of the switch.

For example, switches to define the audio mute, will prevent audio
playback, and switches to indicate lid and covers being closed may
disable displays.

Many evaluation platforms provide switches which can be connected to the
input system but associating these to an action incorrectly could
provide inconsistent end user experiences due to unmarked switch
positions.

Define two custom user defined switches allowing hardware descriptions
to be created whereby the position of the switch is not interpreted as
any standard condition that will affect a user experience.

This allows wiring up custom generic switches in a way that will allow
them to be read and processed, without incurring undesired or otherwise
undocumented (by the hardware) 'default' behaviours.

Signed-off-by: Kieran Bingham <[email protected]>
---
I'd like to hear feedback from linux-input on this of course, and if
accepted I'll submit updates to the evtest utility too.


include/uapi/linux/input-event-codes.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 225ec87d4f22..84a7b3debcb3 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -894,7 +894,9 @@
#define SW_MUTE_DEVICE 0x0e /* set = device disabled */
#define SW_PEN_INSERTED 0x0f /* set = pen inserted */
#define SW_MACHINE_COVER 0x10 /* set = cover closed */
-#define SW_MAX 0x10
+#define SW_1 0x11 /* set = user defined */
+#define SW_2 0x12 /* set = user defined */
+#define SW_MAX 0x12
#define SW_CNT (SW_MAX+1)

/*
--
2.30.2