linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Gardiner <bengardiner@nanometrics.ca>
To: Kevin Hilman <khilman@deeprootsystems.com>,
	davinci-linux-open-source@linux.davincidsp.com,
	linux-input@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Chris Cordahi <christophercordahi@nanometrics.ca>,
	Paul Mundt <lethal@linux-sh.org>, Sekhar Nori <nsekhar@ti.com>,
	Gabor Juhos <juhosg@openwrt.org>,
	"Govindarajan, Sriramakrishnan" <srk@ti.com>,
	Kevin Hilman <khilman@deeprootsystems.com>
Subject: [PATCH v5 2/5] da850-evm: add UI Expander pushbuttons
Date: Wed, 24 Nov 2010 16:59:31 -0500	[thread overview]
Message-ID: <18c52f8d32a0a34a80644c14c9aae57032495019.1290635422.git.bengardiner@nanometrics.ca> (raw)
In-Reply-To: <cover.1290635422.git.bengardiner@nanometrics.ca>

This patch adds EV_KEYs for each of the 8 pushbuttons on the UI board via a
gpio-key device.

The expander is a tca6416; it controls the SEL_{A,B,C} lines which enable and
disable the peripherals found on the UI board in addition to the 8 pushbuttons
mentioned above. The reason the existing tca6416-keypad driver is not employed
is because there was no aparent way to keep the gpio lines used as
SEL_{A,B,C} registered while simultaneously registering the pushbuttons as a
tca6416-keypad instance.

Some experimentation with the polling interval was performed; we were searching
for the largest polling interval that did not affect the feel of the
responsiveness of the buttons. It is very subjective but 200ms seems to be a
good value that accepts firm pushes but rejects very light ones. The key values
assigned to the buttons were arbitrarily chosen to be F1-F8.

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Reviewed-by: Chris Cordahi <christophercordahi@nanometrics.ca>
CC: Govindarajan, Sriramakrishnan <srk@ti.com>
Reviewed-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
CC: Kevin Hilman <khilman@deeprootsystems.com>
CC: Gabor Juhos <juhosg@openwrt.org>

---

Changes since v4:
 * integrated the use of Gabor Juhos' polled gpio buttons driver
 * removed spurious whitespace change (Sekhar Nori)
 * don't linebreak error messages (Sekhar Nori)
 * kept the explicit static initialization of structure members in-place

Changes since v3:
 * extracted Kconfig changes to patch 5/5
 * fixed leading whitespace problem

Changes since v2:
 * rebased to 083eae3e28643e0eefc5243719f8b1572cf98299 of
   git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git
 * remove the "TODO : populate at runtime using" in this patch instead of 4/4
   (Nori, Sekhar)
 * integrated the static array initialization patch of Sekhar Nori
 * use static array initialization ranges
 * rename DA850_PB_POLL_MS to DA850_GPIO_KEYS_POLL_MS
 * use shorter names prefixed with da850_evm

Changes since v1:
 * set INPUT_POLLDEV default for DA850_EVM machine, but don't select it
   unconditionally
 * adding note to description about why tca6416-keypad was not used
 * adding Govindarajan, Sriramakrishnan, the author of the tca6416-keypad
   driver
---
 arch/arm/mach-davinci/board-da850-evm.c |   95 +++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index f89b0b7..f6490f8 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -17,8 +17,10 @@
 #include <linux/i2c.h>
 #include <linux/i2c/at24.h>
 #include <linux/i2c/pca953x.h>
+#include <linux/input.h>
 #include <linux/mfd/tps6507x.h>
 #include <linux/gpio.h>
+#include <linux/gpio_keys_polled.h>
 #include <linux/platform_device.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
@@ -272,6 +274,87 @@ static inline void da850_evm_setup_emac_rmii(int rmii_sel)
 static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
 #endif
 
+
+#define DA850_KEYS_DEBOUNCE_MS	10
+/*
+ * At 200ms polling interval it is possible to miss an
+ * event by tapping very lightly on the push button but most
+ * pushes do result in an event; longer intervals require the
+ * user to hold the button whereas shorter intervals require
+ * more CPU time for polling.
+ */
+#define DA850_GPIO_KEYS_POLL_MS	200
+
+enum da850_evm_ui_exp_pins {
+	DA850_EVM_UI_EXP_SEL_C = 5,
+	DA850_EVM_UI_EXP_SEL_B,
+	DA850_EVM_UI_EXP_SEL_A,
+	DA850_EVM_UI_EXP_PB8,
+	DA850_EVM_UI_EXP_PB7,
+	DA850_EVM_UI_EXP_PB6,
+	DA850_EVM_UI_EXP_PB5,
+	DA850_EVM_UI_EXP_PB4,
+	DA850_EVM_UI_EXP_PB3,
+	DA850_EVM_UI_EXP_PB2,
+	DA850_EVM_UI_EXP_PB1,
+};
+
+static const char const *da850_evm_ui_exp[] = {
+	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
+	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
+	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
+	[DA850_EVM_UI_EXP_PB8]          = "pb8",
+	[DA850_EVM_UI_EXP_PB7]          = "pb7",
+	[DA850_EVM_UI_EXP_PB6]          = "pb6",
+	[DA850_EVM_UI_EXP_PB5]          = "pb5",
+	[DA850_EVM_UI_EXP_PB4]          = "pb4",
+	[DA850_EVM_UI_EXP_PB3]          = "pb3",
+	[DA850_EVM_UI_EXP_PB2]          = "pb2",
+	[DA850_EVM_UI_EXP_PB1]          = "pb1",
+};
+
+#define DA850_N_UI_PB		8
+
+static struct gpio_keys_button da850_evm_ui_keys[] = {
+	[0 ... DA850_N_UI_PB - 1] = {
+		.type			= EV_KEY,
+		.active_low		= 1,
+		.wakeup			= 0,
+		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
+		.code			= -1, /* assigned at runtime */
+		.gpio			= -1, /* assigned at runtime */
+		.desc			= NULL, /* assigned at runtime */
+	},
+};
+
+static struct gpio_keys_polled_platform_data da850_evm_ui_keys_pdata = {
+	.buttons = da850_evm_ui_keys,
+	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
+	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
+};
+
+static struct platform_device da850_evm_ui_keys_device = {
+	.name = "gpio-keys-polled",
+	.id = 0,
+	.dev = {
+		.platform_data = &da850_evm_ui_keys_pdata
+	},
+};
+
+static void da850_evm_ui_keys_init(unsigned gpio)
+{
+	int i;
+	struct gpio_keys_button *button;
+
+	for (i = 0; i < DA850_N_UI_PB; i++) {
+		button = &da850_evm_ui_keys[i];
+		button->code = KEY_F8 - i;
+		button->desc = (char *)
+				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
+		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
+	}
+}
+
 static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
 						unsigned ngpio, void *c)
 {
@@ -304,6 +387,13 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
 	gpio_direction_output(sel_b, 1);
 	gpio_direction_output(sel_c, 1);
 
+	da850_evm_ui_keys_init(gpio);
+	ret = platform_device_register(&da850_evm_ui_keys_device);
+	if (ret) {
+		pr_warning("Could not register UI GPIO expander push-buttons");
+		goto exp_setup_keys_fail;
+	}
+
 	ui_card_detected = 1;
 	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
 
@@ -313,6 +403,8 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
 
 	return 0;
 
+exp_setup_keys_fail:
+	gpio_free(sel_c);
 exp_setup_selc_fail:
 	gpio_free(sel_b);
 exp_setup_selb_fail:
@@ -324,6 +416,8 @@ exp_setup_sela_fail:
 static int da850_evm_ui_expander_teardown(struct i2c_client *client,
 					unsigned gpio, unsigned ngpio, void *c)
 {
+	platform_device_unregister(&da850_evm_ui_keys_device);
+
 	/* deselect all functionalities */
 	gpio_set_value_cansleep(gpio + 5, 1);
 	gpio_set_value_cansleep(gpio + 6, 1);
@@ -340,6 +434,7 @@ static struct pca953x_platform_data da850_evm_ui_expander_info = {
 	.gpio_base	= DAVINCI_N_GPIO,
 	.setup		= da850_evm_ui_expander_setup,
 	.teardown	= da850_evm_ui_expander_teardown,
+	.names		= da850_evm_ui_exp,
 };
 
 static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
-- 
1.7.0.4


  parent reply	other threads:[~2010-11-24 22:00 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1289835508.git.bengardiner@nanometrics.ca>
2010-11-16 19:39 ` [PATCH v2 0/4] da850-evm: add gpio-{keys,leds} for UI and BB expanders Ben Gardiner
2010-11-16 19:39   ` [PATCH v2 1/4] input: gpio_keys: polling mode support Ben Gardiner
2010-11-16 19:39   ` [PATCH v2 2/4] da850-evm: add UI Expander pushbuttons Ben Gardiner
2010-11-19  9:58     ` Nori, Sekhar
2010-11-19 15:38       ` Ben Gardiner
2010-11-22 11:49         ` Nori, Sekhar
2010-11-22 13:50           ` Ben Gardiner
2010-11-23 12:38             ` Nori, Sekhar
2010-11-23 13:29               ` Ben Gardiner
2010-11-23 15:48               ` Kevin Hilman
2010-11-23 17:58                 ` Ben Gardiner
2010-11-24  6:09                 ` Paul Mundt
2010-11-24 17:17                   ` Ben Gardiner
2010-11-16 19:39   ` [PATCH v2 3/4] da850-evm: extract defines for SEL{A,B,C} pins in UI expander Ben Gardiner
2010-11-19 11:19     ` [PATCH v2 3/4] da850-evm: extract defines for SEL{A, B, C} " Nori, Sekhar
2010-11-19 15:38       ` Ben Gardiner
2010-11-16 19:39   ` [PATCH v2 4/4] da850-evm: add baseboard UI expander buttons, switches and LEDs Ben Gardiner
2010-11-19 12:14     ` Nori, Sekhar
2010-11-19 15:40       ` Ben Gardiner
2010-11-19 17:02         ` Dmitry Torokhov
2010-11-19 17:15           ` Ben Gardiner
2010-11-22 12:00         ` Nori, Sekhar
2010-11-22 14:15           ` Ben Gardiner
2010-11-23 12:42             ` Nori, Sekhar
2010-11-23 13:32               ` Ben Gardiner
2010-11-19 21:37   ` [PATCH v3 0/4] da850-evm: add gpio-{keys,leds} for UI and BB expanders Ben Gardiner
2010-11-19 21:37     ` [PATCH v3 1/4] input: gpio_keys: polling mode support Ben Gardiner
2010-11-19 21:37     ` [PATCH v3 2/4] da850-evm: add UI Expander pushbuttons Ben Gardiner
2010-11-19 21:37     ` [PATCH v3 3/4] da850-evm: extract defines for SEL{A,B,C} pins in UI expander Ben Gardiner
2010-11-19 21:41       ` [PATCH v3 3/4] da850-evm: extract defines for SEL{A, B, C} " Victor Rodriguez
2010-11-19 22:25         ` Ben Gardiner
2010-11-19 21:37     ` [PATCH v3 4/4] da850-evm: add baseboard GPIO expander buttons, switches and LEDs Ben Gardiner
2010-11-23 19:40     ` [PATCH v4 0/5] da850-evm: add gpio-{keys,leds} for UI and BB expanders Ben Gardiner
2010-11-23 19:40       ` [PATCH v4 1/5] input: gpio_keys: polling mode support Ben Gardiner
2010-11-23 19:40       ` [PATCH v4 2/5] da850-evm: add UI Expander pushbuttons Ben Gardiner
2010-11-24 13:16         ` Nori, Sekhar
2010-11-24 17:16           ` Ben Gardiner
2010-11-23 19:40       ` [PATCH v4 3/5] da850-evm: extract defines for SEL{A,B,C} pins in UI expander Ben Gardiner
2010-11-23 19:40       ` [PATCH v4 4/5] da850-evm: add baseboard GPIO expander buttons, switches and LEDs Ben Gardiner
2010-11-23 19:41       ` [PATCH v4 5/5] da850-evm: KEYBOARD_GPIO and INPUT_POLLDEV Kconfig conditionals Ben Gardiner
2010-11-24 21:59       ` [PATCH v5 0/5] da850-evm: add gpio-{keys,leds} for UI and BB expanders Ben Gardiner
2010-11-24 21:59         ` [PATCH v5 1/5] [WIP] input: add input driver for polled GPIO buttons Ben Gardiner
2010-11-24 21:59         ` Ben Gardiner [this message]
2010-11-24 21:59         ` [PATCH v5 3/5] da850-evm: extract defines for SEL{A,B,C} pins in UI expander Ben Gardiner
2010-11-24 21:59         ` [PATCH v5 4/5] da850-evm: add baseboard GPIO expander buttons, switches and LEDs Ben Gardiner
2010-11-24 21:59         ` [PATCH v5 5/5] da850-evm: KEYBOARD_GPIO_POLLED Kconfig conditional Ben Gardiner
2010-12-09 21:51         ` [PATCH v6 0/5] da850-evm: add gpio-{keys,leds} for UI and BB expanders Ben Gardiner
2010-12-09 21:51           ` [PATCH v6 1/5] Input: add input driver for polled GPIO buttons Ben Gardiner
2010-12-10 15:50             ` Kevin Hilman
2010-12-09 21:51           ` [PATCH v6 2/5] da850-evm: add UI Expander pushbuttons Ben Gardiner
2010-12-09 21:51           ` [PATCH v6 3/5] da850-evm: extract defines for SEL{A,B,C} pins in UI expander Ben Gardiner
2010-12-09 21:51           ` [PATCH v6 4/5] da850-evm: add baseboard GPIO expander buttons, switches and LEDs Ben Gardiner
2010-12-09 21:51           ` [PATCH v6 5/5] da850-evm: KEYBOARD_GPIO_POLLED Kconfig conditional Ben Gardiner
2010-12-10 16:16           ` [PATCH v6 0/5] da850-evm: add gpio-{keys,leds} for UI and BB expanders Kevin Hilman
2010-12-10 16:33             ` Ben Gardiner
2010-12-11  0:04               ` Kevin Hilman
2010-12-13 17:02               ` Ben Gardiner
2010-12-13 21:53                 ` Kevin Hilman
2010-12-14  4:31                   ` Ben Gardiner
2010-12-14 16:17                   ` Ben Gardiner
2010-12-14 17:10                     ` Kevin Hilman
2010-12-17 15:15                       ` Ben Gardiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18c52f8d32a0a34a80644c14c9aae57032495019.1290635422.git.bengardiner@nanometrics.ca \
    --to=bengardiner@nanometrics.ca \
    --cc=christophercordahi@nanometrics.ca \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=juhosg@openwrt.org \
    --cc=khilman@deeprootsystems.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=srk@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).