Skip to contentSkip to conversation

Add support for TCA6416 based Keypad driver.

PATCH Superseded Sriramakrishnan 4 participants 8 messages Mar 12, 2010

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for TCA6416 based Keypad driver.

AM3517 EVM with APPS board includes keys interfaced to TCA6416 IO expander User keys are connected as GPIO lines to TCA6416 IO expander. Unlike the case with generic gpio-keypad driver individual keys do not generate an interrupt event. Hence we implement a simple keypad driver, that registers as direct I2C client.

The implementation has been tested on AM3517 EVM with the driver tested in polling mode.

Version2 of the patch series addresses review comments from the earlier posting - specifically redesigned to eliminate overhead of using gpio_keys data structures.

Sriramakrishnan (3):
TCA6416 keypad : Implement keypad driver for keys interfaced to

    TCA6416

AM3517: Board hookup for TCA6416 keypad driver.
AM3517 EVM : Enable TCA6416 keypad.

 arch/arm/configs/am3517_evm_defconfig   |   16 ++-
 arch/arm/mach-omap2/board-am3517evm.c   |   47 ++++-
 drivers/input/keyboard/Kconfig          |   16 ++
 drivers/input/keyboard/Makefile         |    1 +
 drivers/input/keyboard/tca6416-keypad.c |  354 +++++++++++++++++++++++++++++++
 include/linux/tca6416_keypad.h          |   34 +++
 6 files changed, 462 insertions(+), 6 deletions(-)
 mode change 100644 => 100755 arch/arm/mach-omap2/board-am3517evm.c
 create mode 100755 drivers/input/keyboard/tca6416-keypad.c
 create mode 100755 include/linux/tca6416_keypad.h
#1 lore raw

PATCH v2 1/3 TCA6416 keypad : Implement keypad driver for keys interfaced to TCA6416

This patch implements a simple Keypad driver that functions as an I2C client. It handles key press events for keys connected to TCA6416 I2C based IO expander.

---
 drivers/input/keyboard/Kconfig          |   16 ++
 drivers/input/keyboard/Makefile         |    1 +
 drivers/input/keyboard/tca6416-keypad.c |  354 +++++++++++++++++++++++++++++++
 include/linux/tca6416_keypad.h          |   34 +++
 4 files changed, 405 insertions(+), 0 deletions(-)
 create mode 100755 drivers/input/keyboard/tca6416-keypad.c
 create mode 100755 include/linux/tca6416_keypad.h
drivers/input/keyboard/Kconfig +16 -0
index 64c1023..cf7fca9 100644
@@ -192,6 +192,22 @@ config KEYBOARD_GPIO
 	  To compile this driver as a module, choose M here: the
 	  module will be called gpio_keys.
 
+config KEYBOARD_TCA6416
+	tristate "TCA6416 Keypad Support"
+	depends on I2C
+	help
+	  This driver implements basic keypad functionality
+	  for keys connected through TCA6416 IO expander
+
+	  Say Y here if your device has keys connected to
+	  TCA6416 IO expander. Your board-specific setup logic
+	  must also provide pin-mask details(of which TCA6416 pins
+	  are used for keypad).
+
+	  If enabled the complete TCA6416 device will be managed through
+	  this driver.
+
+
 config KEYBOARD_MATRIX
 	tristate "GPIO driven matrix keypad support"
 	depends on GENERIC_GPIO
drivers/input/keyboard/Makefile +1 -0
index 706c6b5..47e267c 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_CORGI)		+= corgikbd.o
 obj-$(CONFIG_KEYBOARD_DAVINCI)		+= davinci_keyscan.o
 obj-$(CONFIG_KEYBOARD_EP93XX)		+= ep93xx_keypad.o
 obj-$(CONFIG_KEYBOARD_GPIO)		+= gpio_keys.o
+obj-$(CONFIG_KEYBOARD_TCA6416)		+= tca6416-keypad.o
 obj-$(CONFIG_KEYBOARD_HIL)		+= hil_kbd.o
 obj-$(CONFIG_KEYBOARD_HIL_OLD)		+= hilkbd.o
 obj-$(CONFIG_KEYBOARD_IMX)		+= imx_keypad.o
drivers/input/keyboard/tca6416-keypad.c new file +354 -0

354 lines not on this page · raw message

include/linux/tca6416_keypad.h new file +34 -0
new file mode 100755
index 0000000..7bd266f
@@ -0,0 +1,34 @@
+/*
+ * tca6416 keypad platform support
+ *
+ * Copyright (C) 2010 Texas Instruments
+ *
+ * Author: Sriramakrishnan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _TCA6416_KEYS_H
+#define _TCA6416_KEYS_H
+
+#include <linux/types.h>
+
+struct tca6416_button {
+	/* Configuration parameters */
+	int code;		/* input event code (KEY_*, SW_*) */
+	int active_low;
+	int type;		/* input event type (EV_KEY, EV_SW) */
+};
+
+struct tca6416_keys_platform_data {
+	struct tca6416_button *buttons;
+	int nbuttons;
+	unsigned int rep:1;	/* enable input subsystem auto repeat */
+	uint16_t pinmask;
+	uint16_t invert;
+	int irq_is_gpio;
+	int use_polling;	/* use polling if Interrupt is not connected*/
+};
+#endif
Signature · 1 line
1.6.2.4
#2 lore raw

PATCH v2 2/3 AM3517: Board hookup for TCA6416 keypad driver.

Add board specific hookup for TCA6416 keypad driver.

---
 arch/arm/mach-omap2/board-am3517evm.c |   47 +++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 arch/arm/mach-omap2/board-am3517evm.c
arch/arm/mach-omap2/board-am3517evm.c +42 -5
old mode 100644
new mode 100755
index 6ae8805..d50e505
@@ -20,7 +20,10 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/i2c.h>
 #include <linux/i2c/pca953x.h>
+#include <linux/input.h>
+#include <linux/tca6416_keypad.h>
 
 #include <mach/hardware.h>
 #include <mach/am35xx.h>
@@ -88,16 +91,50 @@ static struct i2c_board_info __initdata am3517evm_tca6416_info_0[] = {
 };
 
 /* Mounted on UI Card */
-static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
+/* IO expander at address 0x20 on UI card will be managed by Keypad driver */
+
+static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
 	.gpio_base	= OMAP_MAX_GPIO_LINES + 16,
 };
-static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
-	.gpio_base	= OMAP_MAX_GPIO_LINES + 32,
+
+/*Keypad Initialization */
+#define KEYPAD_PIN_MASK                0xFFC0
+
+#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
+{								\
+	.type		= ev_type,				\
+	.code		= ev_code,				\
+	.active_low	= act_low,				\
+}
+
+#define KEYPAD_BUTTON_LOW(event_code)		\
+	KEYPAD_BUTTON(EV_KEY, event_code, 1)
+
+static struct tca6416_button am3517_gpio_keys[] = {
+	KEYPAD_BUTTON_LOW(KEY_DOWN),
+	KEYPAD_BUTTON_LOW(KEY_UP),
+	KEYPAD_BUTTON_LOW(KEY_MENU),
+	KEYPAD_BUTTON_LOW(KEY_MODE),
+	KEYPAD_BUTTON_LOW(KEY_LEFTSHIFT),
+	KEYPAD_BUTTON_LOW(KEY_REWIND),
+	KEYPAD_BUTTON_LOW(KEY_FORWARD),
+	KEYPAD_BUTTON_LOW(KEY_STOP),
+	KEYPAD_BUTTON_LOW(KEY_PLAY),
+	KEYPAD_BUTTON_LOW(KEY_RECORD),
 };
+
+static struct tca6416_keys_platform_data am3517evm_tca6416_keys_info = {
+	.buttons	= am3517_gpio_keys,
+	.nbuttons	= ARRAY_SIZE(am3517_gpio_keys),
+	.rep		= 1,
+	.use_polling	= 1,
+	.pinmask	= KEYPAD_PIN_MASK,
+};
+
 static struct i2c_board_info __initdata am3517evm_ui_tca6416_info[] = {
 	{
-		I2C_BOARD_INFO("tca6416", 0x20),
-		.platform_data = &am3517evm_ui_gpio_expander_info_1,
+		I2C_BOARD_INFO("tca6416-keys", 0x20),
+		.platform_data = &am3517evm_tca6416_keys_info,
 	},
 	{
 		I2C_BOARD_INFO("tca6416", 0x21),
Signature · 1 line
1.6.2.4
#3 lore raw

PATCH v2 3/3 AM3517 EVM : Enable TCA6416 keypad.

Update kernel configuration for AM3517EVM to include support for TCA6416 keypad.

---
 arch/arm/configs/am3517_evm_defconfig |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
arch/arm/configs/am3517_evm_defconfig +15 -1
index 66a10b5..93d5fdf 100644
@@ -527,6 +527,7 @@ CONFIG_SCSI_LOWLEVEL=y
 CONFIG_INPUT=y
 # CONFIG_INPUT_FF_MEMLESS is not set
 # CONFIG_INPUT_POLLDEV is not set
+# CONFIG_INPUT_SPARSEKMAP is not set
 
 #
 # Userland interfaces
@@ -539,7 +540,20 @@ CONFIG_INPUT_EVDEV=y
 #
 # Input Device Drivers
 #
-# CONFIG_INPUT_KEYBOARD is not set
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_QT2160 is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_GPIO is not set
+CONFIG_KEYBOARD_TCA6416=y
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TABLET is not set
Signature · 1 line
1.6.2.4
#4 lore raw
In reply to Sriramakrishnan
Quoted 25 lines · Sriramakrishnan

AM3517 EVM with APPS board includes keys interfaced to TCA6416 IO expander User keys are connected as GPIO lines to TCA6416 IO expander. Unlike the case with generic gpio-keypad driver individual keys do not generate an interrupt event. Hence we implement a simple keypad driver, that registers as direct I2C client.

The implementation has been tested on AM3517 EVM with the driver tested in polling mode.

Version2 of the patch series addresses review comments from the earlier posting - specifically redesigned to eliminate overhead of using gpio_keys data structures.

Sriramakrishnan (3):
 TCA6416 keypad : Implement keypad driver for keys interfaced to TCA6416
 AM3517: Board hookup for TCA6416 keypad driver. AM3517 EVM : Enable TCA6416 keypad.

 arch/arm/configs/am3517_evm_defconfig   |   16 ++- arch/arm/mach-omap2/board-am3517evm.c   |   47 ++++- drivers/input/keyboard/Kconfig          |   16 ++ drivers/input/keyboard/Makefile         |    1 + drivers/input/keyboard/tca6416-keypad.c |  354 +++++++++++++++++++++++++++++++ include/linux/tca6416_keypad.h          |   34 +++

Quoted 4 lines
 6 files changed, 462 insertions(+), 6 deletions(-)

 mode change 100644 => 100755 arch/arm/mach-omap2/board-am3517evm.c create mode 100755 drivers/input/keyboard/tca6416-keypad.c create mode 100755 include/linux/tca6416_keypad.h

Please fix mode - remove +x flags.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 36 lines

-----Original Message-----
From: Grazvydas Ignotas [mailto:[email protected]]
Sent: Friday, March 12, 2010 4:54 PM
To: Govindarajan, Sriramakrishnan
Cc: [email protected]; [email protected]
Subject: Re: [PATCHv2 0/3] Add support for TCA6416 based Keypad driver.

Quoted 1 line · Sriramakrishnan

AM3517 EVM with APPS board includes keys interfaced to TCA6416 IO

expander

Quoted 10 lines

User keys are connected as GPIO lines to TCA6416 IO expander. Unlike the case with generic gpio-keypad driver individual keys do not generate an interrupt event. Hence we implement a simple keypad driver, that registers as direct I2C client.

The implementation has been tested on AM3517 EVM with the driver tested in polling mode.

Version2 of the patch series addresses review comments from the earlier posting - specifically redesigned to eliminate overhead of using

gpio_keys

Quoted 8 lines

data structures.

Sriramakrishnan (3):
 TCA6416 keypad : Implement keypad driver for keys interfaced to TCA6416
 AM3517: Board hookup for TCA6416 keypad driver. AM3517 EVM : Enable TCA6416 keypad.

Quoted 5 lines

 arch/arm/configs/am3517_evm_defconfig   |   16 ++- arch/arm/mach-omap2/board-am3517evm.c   |   47 ++++- drivers/input/keyboard/Kconfig          |   16 ++ drivers/input/keyboard/Makefile         |    1 + drivers/input/keyboard/tca6416-keypad.c |  354

Quoted 8 lines

+++++++++++++++++++++++++++++++

Quoted 5 lines

 include/linux/tca6416_keypad.h          |   34 +++

 6 files changed, 462 insertions(+), 6 deletions(-)

 mode change 100644 => 100755 arch/arm/mach-omap2/board-am3517evm.c create mode 100755 drivers/input/keyboard/tca6416-keypad.c create mode 100755 include/linux/tca6416_keypad.h

Please fix mode - remove +x flags.

[Sriram] Thanks for pointing out. I will await further review comments And post the updated version thereafter
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw
Quoted 5 lines · Govindarajan, Sriramakrishnan
Quoted 2 lines

Please fix mode - remove +x flags.

[Sriram] Thanks for pointing out. I will await further review comments And post the updated version thereafter

Please fix mode change issue at TI in general.

We're getting these executable mode change patches from TI on regular basis.

Regards,

Tony

#7 lore raw

Hi,

Quoted 11 lines · Tony Lindgren
Quoted 5 lines · Govindarajan, Sriramakrishnan
Quoted 2 lines

Please fix mode - remove +x flags.

[Sriram] Thanks for pointing out. I will await further review comments And post the updated version thereafter

Please fix mode change issue at TI in general.

We're getting these executable mode change patches from TI on regular basis.

Better way to add checking +x attribute support internally in checkpatch.pl and let everybody scan through checkpatch.pl before submitting a patch to ML. It works !!!

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni