aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>2012-06-25 03:34:36 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-06-25 03:45:15 -0400
commit84b63ad8477c822edbeb1e310b201609f33522ec (patch)
tree119dbc19dbb993c8156e6972791411c1c015cc9e
parentaf77c88b8971232f23b4cba7a46fc7a43914bf22 (diff)
Input: nomadik-ske-keypad - get rid of multiple interrupts
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 wait 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> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/keyboard/nomadik-ske-keypad.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index 6857454bb13c..a880e7414202 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -49,6 +49,7 @@
49#define SKE_ASR3 0x2C 49#define SKE_ASR3 0x2C
50 50
51#define SKE_NUM_ASRX_REGISTERS (4) 51#define SKE_NUM_ASRX_REGISTERS (4)
52#define KEY_PRESSED_DELAY 10
52 53
53/** 54/**
54 * struct ske_keypad - data structure used by keypad driver 55 * 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,
92static int __init ske_keypad_chip_init(struct ske_keypad *keypad) 93static int __init ske_keypad_chip_init(struct ske_keypad *keypad)
93{ 94{
94 u32 value; 95 u32 value;
95 int timeout = 50; 96 int timeout = keypad->board->debounce_ms;
96 97
97 /* check SKE_RIS to be 0 */ 98 /* check SKE_RIS to be 0 */
98 while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--) 99 while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--)
@@ -196,18 +197,22 @@ static void ske_keypad_read_data(struct ske_keypad *keypad)
196static irqreturn_t ske_keypad_irq(int irq, void *dev_id) 197static irqreturn_t ske_keypad_irq(int irq, void *dev_id)
197{ 198{
198 struct ske_keypad *keypad = dev_id; 199 struct ske_keypad *keypad = dev_id;
199 int retries = 20; 200 int timeout = keypad->board->debounce_ms;
200 201
201 /* disable auto scan interrupt; mask the interrupt generated */ 202 /* disable auto scan interrupt; mask the interrupt generated */
202 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0); 203 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
203 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA); 204 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA);
204 205
205 while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --retries) 206 while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout)
206 cpu_relax(); 207 cpu_relax();
207 208
208 /* SKEx registers are stable and can be read */ 209 /* SKEx registers are stable and can be read */
209 ske_keypad_read_data(keypad); 210 ske_keypad_read_data(keypad);
210 211
212 /* wait until raw interrupt is clear */
213 while ((readl(keypad->reg_base + SKE_RIS)) && --timeout)
214 msleep(KEY_PRESSED_DELAY);
215
211 /* enable auto scan interrupts */ 216 /* enable auto scan interrupts */
212 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA); 217 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
213 218