Skip to contentSkip to conversation

ARM: shmobile: Enable DSW2 with gpio-keys on KZM9D

PATCH New Magnus Damm 2 participants 5 messages Nov 13, 2013 – Nov 19, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: shmobile: Enable DSW2 with gpio-keys on KZM9D

From: Magnus Damm <[email protected]>

Use the gpio-keys driver to support the 4 pins on the dip switch DSW2 which is mounted on the KZM9D board.

---

 arch/arm/boot/dts/emev2-kzm9d.dts |   39 ++++++++++++++++++++++++++++++++++++-
 arch/arm/boot/dts/emev2.dtsi      |    2 -
 2 files changed, 39 insertions(+), 2 deletions(-)
arch/arm/boot/dts/emev2-kzm9d.dts +38 -1
@@ -9,7 +9,9 @@
  */
 /dts-v1/;
 
-/include/ "emev2.dtsi"
+#include "emev2.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 
 / {
 	model = "EMEV2 KZM9D Board";
@@ -54,4 +56,39 @@
 		vddvario-supply = <&reg_1p8v>;
 		vdd33a-supply = <&reg_3p3v>;
 	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		button at 1 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-1";
+			linux,code = <KEY_1>;
+			gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
+		};
+		button at 2 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-2";
+			linux,code = <KEY_2>;
+			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
+		};
+		button at 3 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-3";
+			linux,code = <KEY_3>;
+			gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
+		};
+		button at 4 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-4";
+			linux,code = <KEY_4>;
+			gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
+		};
+	};
 };
arch/arm/boot/dts/emev2.dtsi +1 -1
@@ -8,7 +8,7 @@
  * kind, whether express or implied.
  */
 
-/include/ "skeleton.dtsi"
+#include "skeleton.dtsi"
 
 / {
 	compatible = "renesas,emev2";
#1 lore raw

PATCH 1/1 ARM: shmobile: Enable DSW2 with gpio-keys on KZM9D

Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Use the gpio-keys driver to support the 4 pins on the dip switch DSW2 which is mounted on the KZM9D board.

Hi Magnus,

I have tried enabling the following on a config produced using the kzm9d_defconfig:

CONFIG_INPUT_KEYBOARD
CONFIG_INPUT_EVDEV
CONFIG_KEYBOARD_GPIO

But all I see so far in dmsg is:

# dmesg | grep gpio 
platform gpio_keys.3: Driver gpio-keys requests probe deferral

I was expecting something more along the lines of:
input: gpio-keys as /devices/platform/gpio-keys/input/input0

Could you give me some guidance on how to test this?

Quoted 71 lines

---

 arch/arm/boot/dts/emev2-kzm9d.dts |   39 ++++++++++++++++++++++++++++++++++++-
 arch/arm/boot/dts/emev2.dtsi      |    2 -
 2 files changed, 39 insertions(+), 2 deletions(-)
arch/arm/boot/dts/emev2-kzm9d.dts +38 -1
@@ -9,7 +9,9 @@
  */
 /dts-v1/;
 
-/include/ "emev2.dtsi"
+#include "emev2.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 
 / {
 	model = "EMEV2 KZM9D Board";
@@ -54,4 +56,39 @@
 		vddvario-supply = <&reg_1p8v>;
 		vdd33a-supply = <&reg_3p3v>;
 	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		button at 1 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-1";
+			linux,code = <KEY_1>;
+			gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
+		};
+		button at 2 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-2";
+			linux,code = <KEY_2>;
+			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
+		};
+		button at 3 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-3";
+			linux,code = <KEY_3>;
+			gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
+		};
+		button at 4 {
+			debounce_interval = <50>;
+			wakeup = <1>;
+			label = "DSW2-4";
+			linux,code = <KEY_4>;
+			gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
+		};
+	};
 };
arch/arm/boot/dts/emev2.dtsi +1 -1
@@ -8,7 +8,7 @@
  * kind, whether express or implied.
  */
 
-/include/ "skeleton.dtsi"
+#include "skeleton.dtsi"
 
 / {
 	compatible = "renesas,emev2";
#2 lore raw

PATCH 1/1 ARM: shmobile: Enable DSW2 with gpio-keys on KZM9D

Quoted 19 lines · Simon Horman
Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Use the gpio-keys driver to support the 4 pins on the dip switch DSW2 which is mounted on the KZM9D board.

Hi Magnus,

I have tried enabling the following on a config produced using the kzm9d_defconfig:

CONFIG_INPUT_KEYBOARD
CONFIG_INPUT_EVDEV
CONFIG_KEYBOARD_GPIO

But all I see so far in dmsg is:

Quoted 7 lines
# dmesg | grep gpio 
platform gpio_keys.3: Driver gpio-keys requests probe deferral

I was expecting something more along the lines of:
input: gpio-keys as /devices/platform/gpio-keys/input/input0

Could you give me some guidance on how to test this?

I now notice that I also need
"[PATCH 00/03] gpio: R-Car and EM GPIO update"

But with that applied I now see:

# dmesg  | grep gpio 
gpio-keys gpio_keys.3: Failed to request GPIO 14, error -517
platform gpio_keys.3: Driver gpio-keys requests probe deferral
#3 lore raw

PATCH 1/1 ARM: shmobile: Enable DSW2 with gpio-keys on KZM9D

Hi Simon,

Quoted 28 lines · Simon Horman
Quoted 19 lines · Simon Horman
Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Use the gpio-keys driver to support the 4 pins on the dip switch DSW2 which is mounted on the KZM9D board.

Hi Magnus,

I have tried enabling the following on a config produced using the kzm9d_defconfig:

CONFIG_INPUT_KEYBOARD
CONFIG_INPUT_EVDEV
CONFIG_KEYBOARD_GPIO

But all I see so far in dmsg is:

Quoted 7 lines
# dmesg | grep gpio
platform gpio_keys.3: Driver gpio-keys requests probe deferral

I was expecting something more along the lines of:
input: gpio-keys as /devices/platform/gpio-keys/input/input0

Could you give me some guidance on how to test this?

Quoted 8 lines

I now notice that I also need
"[PATCH 00/03] gpio: R-Car and EM GPIO update"

But with that applied I now see:

# dmesg  | grep gpio
gpio-keys gpio_keys.3: Failed to request GPIO 14, error -517
platform gpio_keys.3: Driver gpio-keys requests probe deferral

Thanks for testing. In case of EMEV2 we don't have any PFC support, so because of that you probably need to deselect PINCTRL. The patch below does the trick, but for proper operation you probably have to split this up per-SoC. And these days KZM9D is MULTIPLATFORM only where PINCTRL probably wants to be set as a global default, so I suppose the proper way to support this is to add PFC support for EMEV2.

Another option would be to make these two cases behave the same:
- PINCTRL=y but no pinctrl support for the SoC
- PINCTRL=n

arch/arm/Kconfig 2013-11-14 17:42:36.000000000 +0900 renamed from arch/arm/Kconfig +1 -1
@@ -655,7 +655,7 @@ config ARCH_SHMOBILE
     select MIGHT_HAVE_CACHE_L2X0
     select MULTI_IRQ_HANDLER
     select NO_IOPORT
-    select PINCTRL
+#    select PINCTRL
     select PM_GENERIC_DOMAINS if PM
     select SPARSE_IRQ
     help

Cheers,

/ magnus

#4 lore raw

PATCH 1/1 ARM: shmobile: Enable DSW2 with gpio-keys on KZM9D

Quoted 40 lines · Magnus Damm

Hi Simon,

Quoted 28 lines · Simon Horman
Quoted 19 lines · Simon Horman
Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Use the gpio-keys driver to support the 4 pins on the dip switch DSW2 which is mounted on the KZM9D board.

Hi Magnus,

I have tried enabling the following on a config produced using the kzm9d_defconfig:

CONFIG_INPUT_KEYBOARD
CONFIG_INPUT_EVDEV
CONFIG_KEYBOARD_GPIO

But all I see so far in dmsg is:

Quoted 7 lines
# dmesg | grep gpio
platform gpio_keys.3: Driver gpio-keys requests probe deferral

I was expecting something more along the lines of:
input: gpio-keys as /devices/platform/gpio-keys/input/input0

Could you give me some guidance on how to test this?

Quoted 8 lines

I now notice that I also need
"[PATCH 00/03] gpio: R-Car and EM GPIO update"

But with that applied I now see:

# dmesg  | grep gpio
gpio-keys gpio_keys.3: Failed to request GPIO 14, error -517
platform gpio_keys.3: Driver gpio-keys requests probe deferral
Quoted 6 lines

Thanks for testing. In case of EMEV2 we don't have any PFC support, so because of that you probably need to deselect PINCTRL. The patch below does the trick, but for proper operation you probably have to split this up per-SoC. And these days KZM9D is MULTIPLATFORM only where PINCTRL probably wants to be set as a global default, so I suppose the proper way to support this is to add PFC support for EMEV2.

Thanks. This hack worked. Although curiously while I see keyboard events for pins 1 - 3 I don't get any for pin 4. Perhaps there is a hardware fault on my board.

Quoted 3 lines

Another option would be to make these two cases behave the same:
- PINCTRL=y but no pinctrl support for the SoC
- PINCTRL=n

I'm unsure of what the best way forward is. It seems that the nicest option would be to add PFC support for KZM9D. But is that likely to happen?

If not, I think your last suggestion would be best.
Though I'm not quite sure that I understand the implementation implications.

Quoted 20 lines
arch/arm/Kconfig 2013-11-14 17:42:36.000000000 +0900 renamed from arch/arm/Kconfig +1 -1
@@ -655,7 +655,7 @@ config ARCH_SHMOBILE
     select MIGHT_HAVE_CACHE_L2X0
     select MULTI_IRQ_HANDLER
     select NO_IOPORT
-    select PINCTRL
+#    select PINCTRL
     select PM_GENERIC_DOMAINS if PM
     select SPARSE_IRQ
     help

Cheers,

/ magnus
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html