Skip to contentSkip to conversation

AM335x-ICE: Add support for rotary switch

PATCH Superseded Vignesh R 2 participants 6 messages Aug 12, 2016 – Aug 17, 2016

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Vignesh R

author
#0 lore raw

cover AM335x-ICE: Add support for rotary switch

This series adds support for rotary-switch on AM335x-ICE that is connected to TI PCA9536 I2C GPIO expander.
First patch adds new generic driver to read status of group of GPIO lines and report the value as an input event. The second patch adds DT entries for the same.

Vignesh R (2):
input: misc: Add generic input driver to read encoded GPIO lines
ARM: dts: am335x-icev2: Add nodes for gpio-decoder

 .../devicetree/bindings/input/gpio-decoder.txt     |  23 ++++
 arch/arm/boot/dts/am335x-icev2.dts                 |   9 ++
 drivers/input/misc/Kconfig                         |  12 ++
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/gpio_decoder.c                  | 128 +++++++++++++++++++++
 5 files changed, 173 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/gpio-decoder.txt
 create mode 100644 drivers/input/misc/gpio_decoder.c
Signature · 1 line
2.9.2
author
#1 lore raw

PATCH 1/2 input: misc: Add generic input driver to read encoded GPIO lines

Add a driver to read group of GPIO lines and provide its status as a numerical value as input event to the system. This will help in intefacing devices, that can be connected over GPIOs, that provide input to the system by driving GPIO lines connected to them like a rotary dial or a switch.

For example, a rotary switch can be connected to four GPIO lines. The status of the GPIO lines reflect the actual position of the rotary switch dial. For example, if dial points to 9, then the four GPIO lines connected to the switch will read HLLH(0b'1001 = 9). This value can be reported as an ABS_* event to the input subsystem.

---
 .../devicetree/bindings/input/gpio-decoder.txt     |  23 ++++
 drivers/input/misc/Kconfig                         |  12 ++
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/gpio_decoder.c                  | 128 +++++++++++++++++++++
 4 files changed, 164 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/gpio-decoder.txt
 create mode 100644 drivers/input/misc/gpio_decoder.c
Documentation/devicetree/bindings/input/gpio-decoder.txt new file +23 -0
new file mode 100644
index 000000000000..efd947f52cb3
@@ -0,0 +1,23 @@
+* GPIO Decoder DT bindings
+
+Required Properties:
+- compatible: should be "gpio-decoder"
+- gpios: a spec of gpios (atleast two) to be decoded to a number with
+  first entry representing the MSB.
+
+Optional Properties:
+- gpio-decoder,max-value: Maximum possible value that can be reported by
+  the gpios.
+- linux,axis: the input subsystem axis to map to (ABS_X/ABS_Y).
+  Defaults to 0 (ABS_X).
+
+Example:
+	gpio-decoder0 {
+		compatible = "gpio-decoder";
+		gpios = <&pca9536 3 GPIO_ACTIVE_HIGH>,
+			<&pca9536 2 GPIO_ACTIVE_HIGH>,
+			<&pca9536 1 GPIO_ACTIVE_HIGH>,
+			<&pca9536 0 GPIO_ACTIVE_HIGH>;
+		linux,axis = <0>; /* ABS_X */
+		gpio-decoder,max-value = <9>;
+	};
drivers/input/misc/Kconfig +12 -0
index efb0ca871327..c44513cac3b7 100644
@@ -292,6 +292,18 @@ config INPUT_GPIO_TILT_POLLED
 	  To compile this driver as a module, choose M here: the
 	  module will be called gpio_tilt_polled.
 
+config INPUT_GPIO_DECODER
+	tristate "Polled GPIO Decoder Input driver"
+	depends on GPIOLIB && OF
+	select INPUT_POLLDEV
+	help
+	 Say Y here if you want driver to read status of multiple GPIO
+	 lines and report the encoded value as an absolute integer to
+	 input subsystem.
+
+	 To compile this driver as a module, choose M here: the module
+	 will will be called gpio_decoder.
+
 config INPUT_IXP4XX_BEEPER
 	tristate "IXP4XX Beeper support"
 	depends on ARCH_IXP4XX
drivers/input/misc/Makefile +1 -0
index 6a1e5e20fc1c..0b6d025f0487 100644
@@ -35,6 +35,7 @@ obj-$(CONFIG_INPUT_DRV2667_HAPTICS)	+= drv2667.o
 obj-$(CONFIG_INPUT_GP2A)		+= gp2ap002a00f.o
 obj-$(CONFIG_INPUT_GPIO_BEEPER)		+= gpio-beeper.o
 obj-$(CONFIG_INPUT_GPIO_TILT_POLLED)	+= gpio_tilt_polled.o
+obj-$(CONFIG_INPUT_GPIO_DECODER)	+= gpio_decoder.o
 obj-$(CONFIG_INPUT_HISI_POWERKEY)	+= hisi_powerkey.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_IMS_PCU)		+= ims-pcu.o
drivers/input/misc/gpio_decoder.c new file +128 -0

128 lines not on this page · raw message

Signature · 1 line
2.9.2
author
#4 lore raw

PATCH 2/2 ARM: dts: am335x-icev2: Add nodes for gpio-decoder

In reply to Vignesh R

AM335x ICE board has a rotary-switch connected to PCA9536 I2C GPIO expander. The position of the rotary-switch is reflected by status of GPIO lines. Add gpio-decoder node to read these GPIO line status via gpio-decoder driver and report it as an input event to the system.

---
 arch/arm/boot/dts/am335x-icev2.dts | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/am335x-icev2.dts +9 -0
index 7d8b8fefdf08..f2de594343f2 100644
@@ -139,6 +139,15 @@
 			default-state = "off";
 		};
 	};
+	gpio-decoder0 {
+		compatible = "gpio-decoder";
+		gpios = <&pca9536 3 GPIO_ACTIVE_HIGH>,
+			<&pca9536 2 GPIO_ACTIVE_HIGH>,
+			<&pca9536 1 GPIO_ACTIVE_HIGH>,
+			<&pca9536 0 GPIO_ACTIVE_HIGH>;
+		linux,axis = <0>; /* ABS_X */
+		gpio-decoder,max-value = <9>;
+	};
 };
 
 &am33xx_pinmux {
Signature · 1 line
2.9.2
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] input: misc: Add generic input driver to read encoded GPIO lines

In reply to Vignesh R
Quoted 28 lines · Vignesh R

Add a driver to read group of GPIO lines and provide its status as a numerical value as input event to the system. This will help in intefacing devices, that can be connected over GPIOs, that provide input to the system by driving GPIO lines connected to them like a rotary dial or a switch.

For example, a rotary switch can be connected to four GPIO lines. The status of the GPIO lines reflect the actual position of the rotary switch dial. For example, if dial points to 9, then the four GPIO lines connected to the switch will read HLLH(0b'1001 = 9). This value can be reported as an ABS_* event to the input subsystem.

---
 .../devicetree/bindings/input/gpio-decoder.txt     |  23 ++++
 drivers/input/misc/Kconfig                         |  12 ++
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/gpio_decoder.c                  | 128 +++++++++++++++++++++
 4 files changed, 164 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/gpio-decoder.txt
 create mode 100644 drivers/input/misc/gpio_decoder.c
Documentation/devicetree/bindings/input/gpio-decoder.txt new file +0 -0
new file mode 100644
index 000000000000..efd947f52cb3

Documentation/devicetree/bindings/input/gpio-decoder.txt line 9

Quoted 9 lines
Documentation/devicetree/bindings/input/gpio-decoder.txt new file +9 -0
@@ -0,0 +1,23 @@
+* GPIO Decoder DT bindings
+
+Required Properties:
+- compatible: should be "gpio-decoder"
+- gpios: a spec of gpios (atleast two) to be decoded to a number with
+  first entry representing the MSB.
+
+Optional Properties:
+- gpio-decoder,max-value: Maximum possible value that can be reported by

Just "decoder-max-value".

With that, the binding looks fine to me:

maintainer
#5 lore raw

Re: [PATCH 2/2] ARM: dts: am335x-icev2: Add nodes for gpio-decoder

In reply to Vignesh R
Quoted 15 lines · Vignesh R

AM335x ICE board has a rotary-switch connected to PCA9536 I2C GPIO expander. The position of the rotary-switch is reflected by status of GPIO lines. Add gpio-decoder node to read these GPIO line status via gpio-decoder driver and report it as an input event to the system.

---
 arch/arm/boot/dts/am335x-icev2.dts | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/am335x-icev2.dts +0 -0
index 7d8b8fefdf08..f2de594343f2 100644

arch/arm/boot/dts/am335x-icev2.dts line 142

Quoted 4 lines
arch/arm/boot/dts/am335x-icev2.dts +1 -0
@@ -139,6 +139,15 @@
 			default-state = "off";
 		};
 	};
+	gpio-decoder0 {

Drop the 0 here.

Quoted 14 lines
arch/arm/boot/dts/am335x-icev2.dts +8 -0
+		compatible = "gpio-decoder";
+		gpios = <&pca9536 3 GPIO_ACTIVE_HIGH>,
+			<&pca9536 2 GPIO_ACTIVE_HIGH>,
+			<&pca9536 1 GPIO_ACTIVE_HIGH>,
+			<&pca9536 0 GPIO_ACTIVE_HIGH>;
+		linux,axis = <0>; /* ABS_X */
+		gpio-decoder,max-value = <9>;
+	};
 };
 
 &am33xx_pinmux {
Signature · 1 line
2.9.2
author
#3 lore raw

Re: [PATCH 1/2] input: misc: Add generic input driver to read encoded GPIO lines

In reply to Rob Herring
Quoted 32 lines · Rob Herring
Quoted 31 lines · Vignesh R

Add a driver to read group of GPIO lines and provide its status as a numerical value as input event to the system. This will help in intefacing devices, that can be connected over GPIOs, that provide input to the system by driving GPIO lines connected to them like a rotary dial or a switch.

For example, a rotary switch can be connected to four GPIO lines. The status of the GPIO lines reflect the actual position of the rotary switch dial. For example, if dial points to 9, then the four GPIO lines connected to the switch will read HLLH(0b'1001 = 9). This value can be reported as an ABS_* event to the input subsystem.

---
 .../devicetree/bindings/input/gpio-decoder.txt     |  23 ++++
 drivers/input/misc/Kconfig                         |  12 ++
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/gpio_decoder.c                  | 128 +++++++++++++++++++++
 4 files changed, 164 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/gpio-decoder.txt
 create mode 100644 drivers/input/misc/gpio_decoder.c
Documentation/devicetree/bindings/input/gpio-decoder.txt new file +3 -0
new file mode 100644
index 000000000000..efd947f52cb3
@@ -0,0 +1,23 @@
+* GPIO Decoder DT bindings
+
+Required Properties:
Quoted 8 lines

Documentation/devicetree/bindings/input/gpio-decoder.txt line 9

Quoted 6 lines
Documentation/devicetree/bindings/input/gpio-decoder.txt new file +6 -0
+- compatible: should be "gpio-decoder"
+- gpios: a spec of gpios (atleast two) to be decoded to a number with
+  first entry representing the MSB.
+
+Optional Properties:
+- gpio-decoder,max-value: Maximum possible value that can be reported by

Just "decoder-max-value".

Agreed. I will wait for any comments for the driver part, before sending the next version.

Quoted 5 lines

With that, the binding looks fine to me:

Thanks!

Signature · 2 lines
Regards
Vignesh