Skip to contentSkip to conversation

input: dm355evm_keys driver

PATCH Applied David Brownell 3 participants 13 messages Jan 17, 2009 – Jun 30, 2009

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

PATCH 1/1 input: dm355evm_keys driver

From: David Brownell <[email protected]>
Subject: input: dm355evm_keys driver

Simple input driver support for the events reported by the MSP430 firmware on the DM355 EVM. Verified using the RC5 remote included with the kit; docs weren't quite right.

Some of the keycode selections might need improvement; they can be remapped, so there's at least a runtime workaround. (I also suspect Linux may someday merit more generic support for RC5 based remote controls.)

These events don't distinguish key press vs release events, so this reports both and then skips the next event if it's identical. The RC5 remote codes include a "toggle" bit that can help detect autorepeated keys; but this driver doesn't bother with those nuances.

This driver relies on the drivers/mfd/dm355evm_msp.c code for core features, including sharing I2C access to this firmware with GPIO, LED, and RTC support.

---
Incorporates previous feedback.

 drivers/input/keyboard/Kconfig         |    8 
 drivers/input/keyboard/Makefile        |    1 
 drivers/input/keyboard/dm355evm_keys.c |  332 +++++++++++++++++++++++++++++++
 3 files changed, 341 insertions(+)
drivers/input/keyboard/Kconfig +8 -0
@@ -332,4 +332,12 @@ config KEYBOARD_SH_KEYSC
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called sh_keysc.
+
+config KEYBOARD_DM355EVM
+	tristate "TI DaVinci DM355 EVM Keypad and IR Remote"
+	depends on MFD_DM355EVM_MSP
+	help
+	  Supports the pushbuttons and IR remote used with
+	  the DM355 EVM board.
+
 endif
drivers/input/keyboard/Makefile +1 -0
@@ -28,3 +28,4 @@ obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
 obj-$(CONFIG_KEYBOARD_SH_KEYSC)		+= sh_keysc.o
+obj-$(CONFIG_KEYBOARD_DM355EVM)		+= dm355evm_keys.o
drivers/input/keyboard/dm355evm_keys.c new file +332 -0

332 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · David Brownell

From: David Brownell <[email protected]>
Subject: input: dm355evm_keys driver

PING?? I was told this was in the input queue, but it does not seem to be in

http://git.kernel.org/?p=linux/kernel/git/dtor/input.git

Current version of the patch is appended.

- Dave

=========== CUT HERE
From: David Brownell <[email protected]>
Subject: input: dm355evm_keys driver

Simple input driver support for the events reported by the MSP430 firmware on the DM355 EVM. Verified using the RC5 remote included with the kit; docs weren't quite right.

Some of the keycode selections might need improvement; they can be remapped, so there's at least a runtime workaround. (I also suspect Linux may someday merit more generic support for RC5 based remote controls.)

These events don't distinguish key press vs release events, so this reports both and then skips the next event if it's identical. The RC5 remote codes include a "toggle" bit that can help detect autorepeated keys; but this driver doesn't bother with those nuances.

This driver relies on the drivers/mfd/dm355evm_msp.c code for core features, including sharing I2C access to this firmware with GPIO, LED, and RTC support.

---
 drivers/input/keyboard/Kconfig         |    8 
 drivers/input/keyboard/Makefile        |    1 
 drivers/input/keyboard/dm355evm_keys.c |  332 +++++++++++++++++++++++++++++++
 3 files changed, 341 insertions(+)
drivers/input/keyboard/Kconfig +8 -0
@@ -332,4 +332,12 @@ config KEYBOARD_SH_KEYSC
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called sh_keysc.
+
+config KEYBOARD_DM355EVM
+	tristate "TI DaVinci DM355 EVM Keypad and IR Remote"
+	depends on MFD_DM355EVM_MSP
+	help
+	  Supports the pushbuttons and IR remote used with
+	  the DM355 EVM board.
+
 endif
drivers/input/keyboard/Makefile +1 -0
@@ -28,3 +28,4 @@ obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
 obj-$(CONFIG_KEYBOARD_SH_KEYSC)		+= sh_keysc.o
+obj-$(CONFIG_KEYBOARD_DM355EVM)		+= dm355evm_keys.o
drivers/input/keyboard/dm355evm_keys.c new file +332 -0

332 lines not on this page · raw message

#2 lore raw
Quoted 5 lines · David Brownell
Quoted 3 lines · David Brownell

From: David Brownell <[email protected]>
Subject: input:  dm355evm_keys driver

Quoted 9 lines

PING??  I was told this was in the input queue, but it does not seem to be in

  http://git.kernel.org/?p=linux/kernel/git/dtor/input.git

Current version of the patch is appended.

- Dave

Hmm, still no response. What's up, input team??

Appended is a minor tweak to this code. I'm going to resend the patch again. Maybe one day, soon, I can take it out of my list of patches-due-to-hit-mainline ...

- Dave

=============== CUT HERE
From: David Brownell <[email protected]>

Convert the dm355evm keys driver to use IRQ threading instead of a private workqueue ... that mechanism was added to Linux after the driver was first written.

---
 drivers/input/keyboard/dm355evm_keys.c |   38 ++++++++++++++-----------------
 1 file changed, 18 insertions(+), 20 deletions(-)
drivers/input/keyboard/dm355evm_keys.c +18 -20
@@ -23,30 +23,16 @@
  * pressed, or its autorepeat kicks in, an event is sent.  This driver
  * read those events from the small (32 event) queue and reports them.
  *
- * Because we communicate with the MSP430 using I2C, and all I2C calls
- * in Linux sleep, we need to cons up a kind of threaded IRQ handler
- * using a work_struct.  The IRQ is active low, but we use it through
- * the GPIO controller so we can trigger on falling edges.
- *
  * Note that physically there can only be one of these devices.
  *
  * This driver was tested with firmware revision A4.
  */
 struct dm355evm_keys {
-	struct work_struct	work;
 	struct input_dev	*input;
 	struct device		*dev;
 	int			irq;
 };
 
-static irqreturn_t dm355evm_keys_irq(int irq, void *_keys)
-{
-	struct dm355evm_keys	*keys = _keys;
-
-	schedule_work(&keys->work);
-	return IRQ_HANDLED;
-}
-
 /* These initial keycodes can be remapped by dm355evm_setkeycode(). */
 static struct {
 	u16	event;
@@ -110,13 +96,12 @@ static struct {
 	{ 0x3169, KEY_PAUSE, },
 };
 
-static void dm355evm_keys_work(struct work_struct *work)
+/* runs in an IRQ thread -- can (and will!) sleep */
+static irqreturn_t dm355evm_keys_irq(int irq, void *_keys)
 {
-	struct dm355evm_keys	*keys;
+	struct dm355evm_keys	*keys = _keys;
 	int			status;
 
-	keys = container_of(work, struct dm355evm_keys, work);
-
 	/* For simplicity we ignore INPUT_COUNT and just read
 	 * events until we get the "queue empty" indicator.
 	 * Reading INPUT_LOW decrements the count.
@@ -184,6 +169,19 @@ static void dm355evm_keys_work(struct wo
 		input_report_key(keys->input, keycode, 0);
 		input_sync(keys->input);
 	}
+	return IRQ_HANDLED;
+}
+
+/*
+ * Because we communicate with the MSP430 using I2C, and all I2C calls
+ * in Linux sleep, we use a threaded IRQ handler.  The IRQ itself is
+ * active low, but we go through the GPIO controller so we can trigger
+ * on falling edges and not worry about enabling/disabling the IRQ in
+ * the keypress handling path.
+ */
+static irqreturn_t dm355evm_keys_hardirq(int irq, void *_keys)
+{
+	return IRQ_WAKE_THREAD;
 }
 
 static int dm355evm_setkeycode(struct input_dev *dev, int index, int keycode)
@@ -259,7 +257,6 @@ static int __devinit dm355evm_keys_probe
 	if (status < 0)
 		goto fail1;
 	keys->irq = status;
-	INIT_WORK(&keys->work, dm355evm_keys_work);
 
 	/* REVISIT:  flush the event queue? */
 
@@ -269,7 +266,8 @@ static int __devinit dm355evm_keys_probe
 		goto fail0;
 
 	/* start reporting events */
-	status = request_irq(keys->irq, dm355evm_keys_irq,
+	status = request_threaded_irq(keys->irq,
+			dm355evm_keys_hardirq, dm355evm_keys_irq,
 			IRQF_TRIGGER_FALLING,
 			dev_name(&pdev->dev), keys);
 	if (status < 0) {

--
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
#3 lore raw

Hi David,

Quoted 11 lines · David Brownell
Quoted 10 lines · David Brownell
Quoted 3 lines · David Brownell

From: David Brownell <[email protected]>
Subject: input:  dm355evm_keys driver

PING??  I was told this was in the input queue, but it does not seem to be in

  http://git.kernel.org/?p=linux/kernel/git/dtor/input.git

I just noticed that you are checking master branch of the input tree while I work with 'for-linus' and 'next' branches normally.

Quoted 10 lines
Quoted 4 lines

Current version of the patch is appended.

- Dave

Hmm, still no response. What's up, input team??

Appended is a minor tweak to this code. I'm going to resend the patch again. Maybe one day, soon, I can take it out of my list of patches-due-to-hit-mainline ...

As you have noticed the driver is in mainline already; please submit additional changes to the driver as incremental patches.

Thanks.

Signature · 5 lines
Dmitry
--
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
#4 lore raw
Quoted 6 lines · Dmitry Torokhov
Quoted 4 lines

Appended is a minor tweak to this code.  I'm going to resend the patch again.  Maybe one day, soon, I can take it out of my list of patches-due-to-hit-mainline ...

As you have noticed the driver is in mainline already;

Actually I didn't notice until just now. It was moved from input/keyboard to input/misc. And I wasn't cc'd on this at any point ... so it's no wonder I had no idea what was happening!

OK, so thanks for merging. Kevin, this means you can remove the original code ... and will want to update the defconfig to use the new symbol.

Quoted 2 lines

please submit
additional changes to the driver as incremental patches.

Will do.

- Dave
--
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
#5 lore raw
Quoted 6 lines · David Brownell
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines

Appended is a minor tweak to this code.  I'm going to resend the patch again.  Maybe one day, soon, I can take it out of my list of patches-due-to-hit-mainline ...

Quoted 7 lines
Quoted 1 line

As you have noticed the driver is in mainline already;

Actually I didn't notice until just now. It was moved from input/keyboard to input/misc. And I wasn't cc'd on this at any point ... so it's no wonder I had no idea what was happening!

Ah, sorry, it was me - all RC drivers live in input/misc, that's why I moved it there.

Signature · 5 lines
Dmitry
--
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
#6 lore raw
Quoted 11 lines · Dmitry Torokhov
Quoted 8 lines
Quoted 2 lines

As you have noticed the driver is in mainline already;

Actually I didn't notice until just now.  It was moved from input/keyboard to input/misc.  And I wasn't cc'd on this at any point ... so it's no wonder I had no idea what was happening!

Ah, sorry, it was me - all RC drivers live in input/misc, that's why I moved it there.

It's not purely an RC driver, but I can understand wanting to overlook the other five buttons. ;)

- Dave

--
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

#7 lore raw
In reply to Dmitry Torokhov
Quoted 11 lines · Dmitry Torokhov
Quoted 8 lines
Quoted 2 lines

As you have noticed the driver is in mainline already;

Actually I didn't notice until just now.  It was moved from input/keyboard to input/misc.  And I wasn't cc'd on this at any point ... so it's no wonder I had no idea what was happening!

Ah, sorry, it was me - all RC drivers live in input/misc, that's why I moved it there.

Moving it did break more than just config files ... see the appended fixup patch. I'll suggest that it go through the input tree to keep things together, though if Sam wants to take this through MFD he surely has that option. :)

- Dave

p.s. Of course this is is a hybrid keypad-plus-remote
driver. :) The only real issue here is having this change with no notice.

======== CUT HERE
From: David Brownell <[email protected]>

The keypad driver for the DM355 EVM got slightly broken as it merged, since it moved from input/keyboard to input/misc and its Kconfig symbol changed. This patch copes with the changed Kconfig symbol.

---
 drivers/mfd/dm355evm_msp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mfd/dm355evm_msp.c +1 -2
@@ -32,8 +32,7 @@
  * This driver was tested with firmware revision A4.
  */
 
-#if defined(CONFIG_KEYBOARD_DM355EVM) \
-		|| defined(CONFIG_KEYBOARD_DM355EVM_MODULE)
+#if defined(CONFIG_INPUT_DM355EVM) || defined(CONFIG_INPUT_DM355EVM_MODULE)
 #define msp_has_keyboard()	true
 #else
 #define msp_has_keyboard()	false

--
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
#8 lore raw
Quoted 10 lines · David Brownell
Quoted 9 lines · Dmitry Torokhov
Quoted 8 lines
Quoted 2 lines

As you have noticed the driver is in mainline already;

Actually I didn't notice until just now.  It was moved from input/keyboard to input/misc.  And I wasn't cc'd on this at any point ... so it's no wonder I had no idea what was happening!

Quoted 8 lines
Quoted 2 lines

Ah, sorry, it was me - all RC drivers live in input/misc, that's why I moved it there.

Moving it did break more than just config files ... see the appended fixup patch. I'll suggest that it go through the input tree to keep things together, though if Sam wants to take this through MFD he surely has that option. :)

Well, I picked it up for 'for-linus' branch, will push in the next round. Thanks David.

Signature · 5 lines
Dmitry
--
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
Applied
#9 lore raw
In reply to David Brownell
Quoted 8 lines · David Brownell
Quoted 6 lines · Dmitry Torokhov
Quoted 4 lines

Appended is a minor tweak to this code.  I'm going to resend the patch again.  Maybe one day, soon, I can take it out of my list of patches-due-to-hit-mainline ...

As you have noticed the driver is in mainline already;

Quoted 8 lines

Actually I didn't notice until just now. It was moved from input/keyboard to input/misc. And I wasn't cc'd on this at any point ... so it's no wonder I had no idea what was happening!

OK, so thanks for merging. Kevin, this means you can remove the original code ... and will want to update the defconfig to use the new symbol.

OK, done. I just reverted all previous commits and cherry-picked
the upstream one until I merge with upstream.

Pushed to davinci git.

Kevin
--
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

#10 lore raw

PATCH 1/1 input: dm355evm_keys uses threaded IRQs

In reply to Dmitry Torokhov

From: David Brownell <[email protected]>

Convert the dm355evm keys driver to use IRQ threading instead of a private workqueue. IRQ threads were added to Linux after this driver was written, and in this case fit what the driver needs. (Although the non-shared thread costs more runtime memory.)

---
 drivers/input/misc/dm355evm_keys.c |   42 ++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 22 deletions(-)
drivers/input/misc/dm355evm_keys.c +20 -22
@@ -23,30 +23,16 @@
  * pressed, or its autorepeat kicks in, an event is sent.  This driver
  * read those events from the small (32 event) queue and reports them.
  *
- * Because we communicate with the MSP430 using I2C, and all I2C calls
- * in Linux sleep, we need to cons up a kind of threaded IRQ handler
- * using a work_struct.  The IRQ is active low, but we use it through
- * the GPIO controller so we can trigger on falling edges.
- *
  * Note that physically there can only be one of these devices.
  *
  * This driver was tested with firmware revision A4.
  */
 struct dm355evm_keys {
-	struct work_struct	work;
 	struct input_dev	*input;
 	struct device		*dev;
 	int			irq;
 };
 
-static irqreturn_t dm355evm_keys_irq(int irq, void *_keys)
-{
-	struct dm355evm_keys	*keys = _keys;
-
-	schedule_work(&keys->work);
-	return IRQ_HANDLED;
-}
-
 /* These initial keycodes can be remapped by dm355evm_setkeycode(). */
 static struct {
 	u16	event;
@@ -110,13 +96,12 @@ static struct {
 	{ 0x3169, KEY_PAUSE, },
 };
 
-static void dm355evm_keys_work(struct work_struct *work)
+/* runs in an IRQ thread -- can (and will!) sleep */
+static irqreturn_t dm355evm_keys_irq(int irq, void *_keys)
 {
-	struct dm355evm_keys	*keys;
+	struct dm355evm_keys	*keys = _keys;
 	int			status;
 
-	keys = container_of(work, struct dm355evm_keys, work);
-
 	/* For simplicity we ignore INPUT_COUNT and just read
 	 * events until we get the "queue empty" indicator.
 	 * Reading INPUT_LOW decrements the count.
@@ -183,6 +168,19 @@ static void dm355evm_keys_work(struct wo
 		input_report_key(keys->input, keycode, 0);
 		input_sync(keys->input);
 	}
+	return IRQ_HANDLED;
+}
+
+/*
+ * Because we communicate with the MSP430 using I2C, and all I2C calls
+ * in Linux sleep, we use a threaded IRQ handler.  The IRQ itself is
+ * active low, but we go through the GPIO controller so we can trigger
+ * on falling edges and not worry about enabling/disabling the IRQ in
+ * the keypress handling path.
+ */
+static irqreturn_t dm355evm_keys_hardirq(int irq, void *_keys)
+{
+	return IRQ_WAKE_THREAD;
 }
 
 static int dm355evm_setkeycode(struct input_dev *dev, int index, int keycode)
@@ -233,7 +231,6 @@ static int __devinit dm355evm_keys_probe
 
 	keys->dev = &pdev->dev;
 	keys->input = input;
-	INIT_WORK(&keys->work, dm355evm_keys_work);
 
 	/* set up "threaded IRQ handler" */
 	status = platform_get_irq(pdev, 0);
@@ -260,9 +257,10 @@ static int __devinit dm355evm_keys_probe
 
 	/* REVISIT:  flush the event queue? */
 
-	status = request_irq(keys->irq, dm355evm_keys_irq,
-			     IRQF_TRIGGER_FALLING,
-			     dev_name(&pdev->dev), keys);
+	status = request_threaded_irq(keys->irq,
+			dm355evm_keys_hardirq, dm355evm_keys_irq,
+			IRQF_TRIGGER_FALLING,
+			dev_name(&pdev->dev), keys);
 	if (status < 0)
 		goto fail1;
 
maintainer
#11 lore raw

Re: [patch 2.6.30] input: dm355evm_keys uses threaded IRQs

Quoted 7 lines · David Brownell

From: David Brownell <[email protected]>

Convert the dm355evm keys driver to use IRQ threading instead of a private workqueue. IRQ threads were added to Linux after this driver was written, and in this case fit what the driver needs. (Although the non-shared thread costs more runtime memory.)

Applied the 'next' branch, thank you David.

Signature · 1 line
Dmitry
#12 lore raw

PATCH 1/1 input: dm355evm_keys driver

In reply to David Brownell

From: David Brownell <[email protected]>
Subject: input: dm355evm_keys driver

Simple input driver support for the events reported by the MSP430 firmware on the DM355 EVM. Verified using the RC5 remote included with the kit; docs weren't quite right.

Some of the keycode selections might need improvement; they can be remapped, so there's at least a runtime workaround. (I also suspect Linux may someday merit more generic support for RC5 based remote controls.)

These events don't distinguish key press vs release events, so this reports both and then skips the next event if it's identical. The RC5 remote codes include a "toggle" bit that can help detect autorepeated keys; but this driver doesn't bother with those nuances.

This driver relies on the drivers/mfd/dm355evm_msp.c code for core features, including sharing I2C access to this firmware with GPIO, LED, and RTC support.

[ Changes from the 21-January version include Kbuild tracking, and switching to threaded IRQ handler from the original workqueue version. ]

---
Note that the DM355 EVM is now in mainline. The only change of note in the code, since its mid-January review on the input list, is using a threaded IRQ handler instead of a workqueue.

 drivers/input/keyboard/Kconfig         |    8 
 drivers/input/keyboard/Makefile        |    1 
 drivers/input/keyboard/dm355evm_keys.c |  330 +++++++++++++++++++++++++++++++
 3 files changed, 339 insertions(+)
drivers/input/keyboard/Kconfig +8 -0
@@ -332,4 +332,12 @@ config KEYBOARD_SH_KEYSC
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called sh_keysc.
+
+config KEYBOARD_DM355EVM
+	tristate "TI DaVinci DM355 EVM Keypad and IR Remote"
+	depends on MFD_DM355EVM_MSP
+	help
+	  Supports the pushbuttons and IR remote used with
+	  the DM355 EVM board.
+
 endif
drivers/input/keyboard/Makefile +1 -0
@@ -28,3 +28,4 @@ obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
 obj-$(CONFIG_KEYBOARD_SH_KEYSC)		+= sh_keysc.o
+obj-$(CONFIG_KEYBOARD_DM355EVM)		+= dm355evm_keys.o
drivers/input/keyboard/dm355evm_keys.c new file +330 -0

330 lines not on this page · raw message