Skip to contentSkip to conversation

dt-bindings: input: Convert gpio-keys bindings to schema

PATCH Superseded Rob Herring 2 participants 4 messages Jan 23, 2020 – Jan 27, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 dt-bindings: input: Convert gpio-keys bindings to schema

Convert the gpio-keys and gpio-keys-polled bindings to a DT schema. As both bindings are almost the same, combine them into a single schema.

The binding said 'interrupts' was required, but testing on dts files showed that it isn't required.

'linux,input-value' was only documented for gpio-keys-polled, but there doesn't seem to be any reason for it to be specific to that.

Cc Dmitry Torokhov <[email protected]>
---
 .../bindings/input/gpio-keys-polled.txt       |  45 ------
 .../devicetree/bindings/input/gpio-keys.txt   |  58 -------
 .../devicetree/bindings/input/gpio-keys.yaml  | 151 ++++++++++++++++++
 3 files changed, 151 insertions(+), 103 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/gpio-keys-polled.txt
 delete mode 100644 Documentation/devicetree/bindings/input/gpio-keys.txt
 create mode 100644 Documentation/devicetree/bindings/input/gpio-keys.yaml
Documentation/devicetree/bindings/input/gpio-keys-polled.txt deleted +0 -45
deleted file mode 100644
index 4d9a3717eaaf..000000000000
@@ -1,45 +0,0 @@
-Device-Tree bindings for input/gpio_keys_polled.c keyboard driver
-
-Required properties:
-	- compatible = "gpio-keys-polled";
-	- poll-interval: Poll interval time in milliseconds
-
-Optional properties:
-	- autorepeat: Boolean, Enable auto repeat feature of Linux input
-	  subsystem.
-
-Each button (key) is represented as a sub-node of "gpio-keys-polled":
-Subnode properties:
-
-	- gpios: OF device-tree gpio specification.
-	- label: Descriptive name of the key.
-	- linux,code: Key / Axis code to emit.
-
-Optional subnode-properties:
-	- linux,input-type: Specify event type this button/key generates.
-	  If not specified defaults to <1> == EV_KEY.
-	- linux,input-value: If linux,input-type is EV_ABS or EV_REL then this
-	  value is sent for events this button generates when pressed.
-	  EV_ABS/EV_REL axis will generate an event with a value of 0 when
-	  all buttons with linux,input-type == type and linux,code == axis
-	  are released. This value is interpreted as a signed 32 bit value,
-	  e.g. to make a button generate a value of -1 use:
-	  linux,input-value = <0xffffffff>; /* -1 */
-	- debounce-interval: Debouncing interval time in milliseconds.
-	  If not specified defaults to 5.
-	- wakeup-source: Boolean, button can wake-up the system.
-			 (Legacy property supported: "gpio-key,wakeup")
-
-Example nodes:
-
-	gpio_keys_polled {
-			compatible = "gpio-keys-polled";
-			poll-interval = <100>;
-			autorepeat;
-
-			button21 {
-				label = "GPIO Key UP";
-				linux,code = <103>;
-				gpios = <&gpio1 0 1>;
-			};
-			...
Documentation/devicetree/bindings/input/gpio-keys.txt deleted +0 -58

58 lines not on this page · raw message

Documentation/devicetree/bindings/input/gpio-keys.yaml new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#1 lore raw

Hi Rob,

Quoted 8 lines · Rob Herring

Convert the gpio-keys and gpio-keys-polled bindings to a DT schema. As both bindings are almost the same, combine them into a single schema.

The binding said 'interrupts' was required, but testing on dts files showed that it isn't required.

'linux,input-value' was only documented for gpio-keys-polled, but there doesn't seem to be any reason for it to be specific to that.

Actually, there is: with gpio-keys-polled we take a "snapshot" of the entire device state, so we know when to generate a 0 event (the example we have a device with several GPIOs with values assigned 1, 2, 3, 4, 5.. values, when one of the gpios is active we generate event with given value, when all are inactive we generate 0 event). This does not work for interrupt-only driven device.

Documentation/devicetree/bindings/input/gpio-keys.yaml line 31

Quoted 7 lines
Documentation/devicetree/bindings/input/gpio-keys.yaml new file +7 -0
+
+      properties:
+        gpios:
+          maxItems: 1
+
+        interrupts:
+          maxItems: 1

We support "interrupt-only" mode where we do not have GPIO, so for "gpio-keys" we need either interrupts or gpios or both, and for polled we must have gpios (and I guess we simply ignore interrupts if they are specified).

Does this binding manages to enforce this?

Thanks.

Signature · 1 line
Dmitry
author maintainer
#2 lore raw
Quoted 13 lines · Dmitry Torokhov

Hi Rob,

Quoted 8 lines · Rob Herring

Convert the gpio-keys and gpio-keys-polled bindings to a DT schema. As both bindings are almost the same, combine them into a single schema.

The binding said 'interrupts' was required, but testing on dts files showed that it isn't required.

'linux,input-value' was only documented for gpio-keys-polled, but there doesn't seem to be any reason for it to be specific to that.

Quoted 6 lines

Actually, there is: with gpio-keys-polled we take a "snapshot" of the entire device state, so we know when to generate a 0 event (the example we have a device with several GPIOs with values assigned 1, 2, 3, 4, 5.. values, when one of the gpios is active we generate event with given value, when all are inactive we generate 0 event). This does not work for interrupt-only driven device.

Okay, it wasn't clear to me reading the binding doc. I'll make it conditional.

Quoted 8 lines

Documentation/devicetree/bindings/input/gpio-keys.yaml line 31

Quoted 7 lines
Documentation/devicetree/bindings/input/gpio-keys.yaml new file +6 -0
+      properties:
+        gpios:
+          maxItems: 1
 
+
+        interrupts:
+          maxItems: 1
Quoted 6 lines

We support "interrupt-only" mode where we do not have GPIO, so for "gpio-keys" we need either interrupts or gpios or both, and for polled we must have gpios (and I guess we simply ignore interrupts if they are specified).

Does this binding manages to enforce this?

Yes, this hunk does that:

+ anyOf:
+ - required:
+ - interrupts
+ - required:
+ - gpios

Rob

maintainer
#3 lore raw
Quoted 15 lines · Rob Herring
Quoted 13 lines · Dmitry Torokhov

Hi Rob,

Quoted 8 lines · Rob Herring

Convert the gpio-keys and gpio-keys-polled bindings to a DT schema. As both bindings are almost the same, combine them into a single schema.

The binding said 'interrupts' was required, but testing on dts files showed that it isn't required.

'linux,input-value' was only documented for gpio-keys-polled, but there doesn't seem to be any reason for it to be specific to that.

Quoted 8 lines
Quoted 6 lines

Actually, there is: with gpio-keys-polled we take a "snapshot" of the entire device state, so we know when to generate a 0 event (the example we have a device with several GPIOs with values assigned 1, 2, 3, 4, 5.. values, when one of the gpios is active we generate event with given value, when all are inactive we generate 0 event). This does not work for interrupt-only driven device.

Okay, it wasn't clear to me reading the binding doc. I'll make it conditional.

Actually, I think we can make it usable in interrupt-driver driver. For EV_REL events we do not need to "go back to 0", and for EV_ABS, if desired, we could allow specifying an option to scan all GPIOs on any interrupt. This obviously will not work for pure interrupt devices (where we do not have GPIOs).

Thanks.

Signature · 1 line
Dmitry