Skip to contentSkip to conversation

Input: twl4030_keypad - add device tree support

PATCH Superseded Sebastian Reichel 2 participants 4 messages Oct 9, 2013 – Oct 11, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Input: twl4030_keypad - add device tree support

Add device tree support for twl4030 keypad driver and update the Documentation with twl4030 keypad device tree binding information.

This patch also adds a twl4030 keypad node to the twl4030.dtsi file, so that board files can just add the keymap.

Tested on Nokia N900.

---
 .../devicetree/bindings/input/twl4030-keypad.txt   | 31 ++++++++
 arch/arm/boot/dts/twl4030.dtsi                     |  7 ++
 drivers/input/keyboard/twl4030_keypad.c            | 91 ++++++++++++++++++----
 3 files changed, 112 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/twl4030-keypad.txt
Documentation/devicetree/bindings/input/twl4030-keypad.txt new file +31 -0
new file mode 100644
index 0000000..2b4bd7a
@@ -0,0 +1,31 @@
+* TWL4030's Keypad Controller device tree bindings
+
+TWL4030's Keypad controller is used to interface a SoC with a matrix-type
+keypad device. The keypad controller supports multiple row and column lines.
+A key can be placed at each intersection of a unique row and a unique column.
+The keypad controller can sense a key-press and key-release and report the
+event using a interrupt to the cpu.
+
+This binding is based on the matrix-keymap binding with the following
+changes:
+
+ * keypad,num-rows and keypad,num-columns are required.
+
+Required SoC Specific Properties:
+- compatible: should be one of the following
+   - "ti,twl4030-keypad": For controllers compatible with twl4030 keypad
+      controller.
+- interrupt: should be one of the following
+   - <1>: For controllers compatible with twl4030 keypad controller.
+
+Optional Properties specific to linux:
+- linux,keypad-no-autorepeat: do no enable autorepeat feature.
+
+Example:
+	twl_keypad: keypad {
+		compatible = "ti,twl4030-keypad";
+		interrupts = <1>;
+		keypad,num-rows = <8>;
+		keypad,num-columns = <8>;
+		linux,keypad-no-autorepeat;
+	};
arch/arm/boot/dts/twl4030.dtsi +7 -0
index ae6a17a..773c94c 100644
@@ -97,4 +97,11 @@
 		compatible = "ti,twl4030-pwmled";
 		#pwm-cells = <2>;
 	};
+
+	twl_keypad: keypad {
+		compatible = "ti,twl4030-keypad";
+		interrupts = <1>;
+		keypad,num-rows = <8>;
+		keypad,num-columns = <8>;
+	};
 };
drivers/input/keyboard/twl4030_keypad.c +74 -17

150 lines not on this page · raw message

Signature · 1 line
1.8.4.rc3
#1 lore raw

PATCH 2/2 ARM: dts: N900: TWL4030 Keypad Matrix definition

Add Keyboard Matrix information to N900's DTS file. This patch maps the keys exactly as the original board code.

---
 arch/arm/boot/dts/omap3-n900.dts | 55 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
arch/arm/boot/dts/omap3-n900.dts +55 -0
index 0fbb77e..d11ff6e 100644
@@ -120,6 +120,61 @@
 #include "twl4030.dtsi"
 #include "twl4030_omap3.dtsi"
 
+&twl_keypad {
+	linux,keymap = < 0x00000010 /* KEY_Q */
+			 0x00010018 /* KEY_O */
+			 0x00020019 /* KEY_P */
+			 0x00030033 /* KEY_COMMA */
+			 0x0004000e /* KEY_BACKSPACE */
+			 0x0006001e /* KEY_A */
+			 0x0007001f /* KEY_S */
+
+			 0x01000011 /* KEY_W */
+			 0x01010020 /* KEY_D */
+			 0x01020021 /* KEY_F */
+			 0x01030022 /* KEY_G */
+			 0x01040023 /* KEY_H */
+			 0x01050024 /* KEY_J */
+			 0x01060025 /* KEY_K */
+			 0x01070026 /* KEY_L */
+
+			 0x02000012 /* KEY_E */
+			 0x02010034 /* KEY_DOT */
+			 0x02020067 /* KEY_UP */
+			 0x0203001c /* KEY_ENTER */
+			 0x0205002c /* KEY_Z */
+			 0x0206002d /* KEY_X */
+			 0x0207002e /* KEY_C */
+			 0x02080043 /* KEY_F9 */
+
+			 0x03000013 /* KEY_R */
+			 0x0301002f /* KEY_V */
+			 0x03020030 /* KEY_B */
+			 0x03030031 /* KEY_N */
+			 0x03040032 /* KEY_M */
+			 0x03050039 /* KEY_SPACE */
+			 0x03060039 /* KEY_SPACE */
+			 0x03070069 /* KEY_LEFT */
+
+			 0x04000014 /* KEY_T */
+			 0x0401006c /* KEY_DOWN */
+			 0x0402006a /* KEY_RIGHT */
+			 0x0404001d /* KEY_LEFTCTRL */
+			 0x04050064 /* KEY_RIGHTALT */
+			 0x0406002a /* KEY_LEFTSHIFT */
+			 0x04080044 /* KEY_F10 */
+
+			 0x05000015 /* KEY_Y */
+			 0x05080057 /* KEY_F11 */
+
+			 0x06000016 /* KEY_U */
+
+			 0x07000017 /* KEY_I */
+			 0x07010041 /* KEY_F7 */
+			 0x07020042 /* KEY_F8 */
+			 >;
+};
+
 &twl_gpio {
 	ti,pullups	= <0x0>;
 	ti,pulldowns	= <0x03ff3f>; /* BIT(0..5) | BIT(8..17) */
Signature · 1 line
1.8.4.rc3
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] ARM: dts: N900: TWL4030 Keypad Matrix definition

Quoted 3 lines · Sebastian Reichel

Add Keyboard Matrix information to N900's DTS file. This patch maps the keys exactly as the original board code.

This should be queued by Benoit along with other .dts changes, not via the input tree:

Acked-by on v1 1/2
#3 lore raw
In reply to Sebastian Reichel
Quoted 7 lines · Sebastian Reichel

Add device tree support for twl4030 keypad driver and update the Documentation with twl4030 keypad device tree binding information.

This patch also adds a twl4030 keypad node to the twl4030.dtsi file, so that board files can just add the keymap.

Tested on Nokia N900.

Nice :) Just few cosmetic comments below.

drivers/input/keyboard/twl4030_keypad.c static int twl4030_kp_program(struct twl4030_keypad *kp) · line 332

Quoted 5 lines
drivers/input/keyboard/twl4030_keypad.c +4 -0
+#ifdef CONFIG_OF
+static int twl4030_keypad_parse_dt(struct device *dev,
+				 struct twl4030_keypad *keypad_data)
+{

I guess the way to go nowadays is to use #IS_ENABLED(CONFIG_OF) here and later on in this patch.

Quoted 12 lines
drivers/input/keyboard/twl4030_keypad.c +1 -2
@@ -331,20 +358,12 @@ static int twl4030_kp_program(struct twl4030_keypad *kp)
 static int twl4030_kp_probe(struct platform_device *pdev)
 {
 	struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
-	const struct matrix_keymap_data *keymap_data;
+	const struct matrix_keymap_data *keymap_data = NULL;
 	struct twl4030_keypad *kp;
 	struct input_dev *input;
 	u8 reg;
 	int error;
 
-	if (!pdata || !pdata->rows || !pdata->cols || !pdata->keymap_data ||

drivers/input/keyboard/twl4030_keypad.c static int twl4030_kp_program(struct twl4030_keypad *kp) · line 369

Quoted 10 lines
drivers/input/keyboard/twl4030_keypad.c +0 -7
-	    pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
-		dev_err(&pdev->dev, "Invalid platform_data\n");
-		return -EINVAL;
-	}
-
-	keymap_data = pdata->keymap_data;
-
 	kp = kzalloc(sizeof(*kp), GFP_KERNEL);
 	input = input_allocate_device();
 	if (!kp || !input) {

I assume you have tested the above so it does not break things for legacy booting?

Other than that: