All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] input/nomadik-ske: get rid of multiple interrupts
@ 2012-06-17 14:17 Linus Walleij
  2012-06-25  7:35 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2012-06-17 14:17 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, Naveen Kumar Gaddipati, Linus Walleij

From: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>

The keypad could cause multiple interrupts to be fired in succession
since we weren't waiting for the IRQs to clear properly in the
interrupt handler. We ait for a number of bus iterations (the
readl():s from the peripheral bus will stall, so these are quite
long) before giving up on getting keys ready to read, then we
sleep until the IRQ is deasserted (this is OK since the interrupt
is threaded). Also use the debounce platform data for another
hardcoded wait loop.

Signed-off-by: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
Reviewed-by: Rikard Olsson <rikard.p.olsson@stericsson.com>
Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/input/keyboard/nomadik-ske-keypad.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index 68c36a7..ca802fe 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -49,6 +49,7 @@
 #define SKE_ASR3	0x2C
 
 #define SKE_NUM_ASRX_REGISTERS	(4)
+#define	KEY_PRESSED_DELAY	10
 
 /**
  * struct ske_keypad  - data structure used by keypad driver
@@ -92,7 +93,7 @@ static void ske_keypad_set_bits(struct ske_keypad *keypad, u16 addr,
 static int __init ske_keypad_chip_init(struct ske_keypad *keypad)
 {
 	u32 value;
-	int timeout = 50;
+	int timeout = keypad->board->debounce_ms;
 
 	/* check SKE_RIS to be 0 */
 	while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--)
@@ -196,18 +197,22 @@ static void ske_keypad_read_data(struct ske_keypad *keypad)
 static irqreturn_t ske_keypad_irq(int irq, void *dev_id)
 {
 	struct ske_keypad *keypad = dev_id;
-	int retries = 20;
+	int timeout = keypad->board->debounce_ms;
 
 	/* disable auto scan interrupt; mask the interrupt generated */
 	ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
 	ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA);
 
-	while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --retries)
+	while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout)
 		cpu_relax();
 
 	/* SKEx registers are stable and can be read */
 	ske_keypad_read_data(keypad);
 
+	/* wait until raw interrupt is clear */
+	while ((readl(keypad->reg_base + SKE_RIS)) && --timeout)
+		msleep(KEY_PRESSED_DELAY);
+
 	/* enable auto scan interrupts */
 	ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
 
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/4] input/nomadik-ske: get rid of multiple interrupts
  2012-06-17 14:17 [PATCH 3/4] input/nomadik-ske: get rid of multiple interrupts Linus Walleij
@ 2012-06-25  7:35 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2012-06-25  7:35 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-input, Naveen Kumar Gaddipati, Linus Walleij

On Sun, Jun 17, 2012 at 04:17:58PM +0200, Linus Walleij wrote:
> From: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
> 
> The keypad could cause multiple interrupts to be fired in succession
> since we weren't waiting for the IRQs to clear properly in the
> interrupt handler. We ait for a number of bus iterations (the
> readl():s from the peripheral bus will stall, so these are quite
> long) before giving up on getting keys ready to read, then we
> sleep until the IRQ is deasserted (this is OK since the interrupt
> is threaded). Also use the debounce platform data for another
> hardcoded wait loop.
> 
> Signed-off-by: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
> Reviewed-by: Rikard Olsson <rikard.p.olsson@stericsson.com>
> Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-25  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-17 14:17 [PATCH 3/4] input/nomadik-ske: get rid of multiple interrupts Linus Walleij
2012-06-25  7:35 ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.