diff mbox

Input: imx_keypad - reset the hardware before enabling

Message ID 1345476893-4737-1-git-send-email-m.grzeschik@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Grzeschik Aug. 20, 2012, 3:34 p.m. UTC
assert the hardware is correctly initialized before requesting the
interrupt. Otherwise if a key was already touched since power-on the
kernel enters an interrupt loop. To fix this issue we clear pending
interrupt sources. We have to ensure to enable clks while changing the
keypad registers.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/input/keyboard/imx_keypad.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Dmitry Torokhov Aug. 22, 2012, 5:06 a.m. UTC | #1
On Mon, Aug 20, 2012 at 05:34:53PM +0200, Michael Grzeschik wrote:
> assert the hardware is correctly initialized before requesting the
> interrupt. Otherwise if a key was already touched since power-on the
> kernel enters an interrupt loop. To fix this issue we clear pending
> interrupt sources. We have to ensure to enable clks while changing the
> keypad registers.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

Applied, thank you Michael.
diff mbox

Patch

diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index ff4c0a8..ce68e36 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -358,6 +358,7 @@  static void imx_keypad_inhibit(struct imx_keypad *keypad)
 	/* Inhibit KDI and KRI interrupts. */
 	reg_val = readw(keypad->mmio_base + KPSR);
 	reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE);
+	reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD;
 	writew(reg_val, keypad->mmio_base + KPSR);
 
 	/* Colums as open drain and disable all rows */
@@ -515,7 +516,9 @@  static int __devinit imx_keypad_probe(struct platform_device *pdev)
 	input_set_drvdata(input_dev, keypad);
 
 	/* Ensure that the keypad will stay dormant until opened */
+	clk_enable(keypad->clk);
 	imx_keypad_inhibit(keypad);
+	clk_disable(keypad->clk);
 
 	error = request_irq(irq, imx_keypad_irq_handler, 0,
 			    pdev->name, keypad);