summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Jones <marc.jones@chromium.org>2012-10-11 15:15:52 +0000
committerTom Rini <trini@ti.com>2012-10-19 15:25:43 -0700
commit59a1b72ced4f3eff6e7e26e566e6090a5e25d384 (patch)
tree7b432e9dc9e8c83b746001dcaed822798dd9151d
parent45fe668f5f6065f37836d5e941f36418fa3676cd (diff)
downloadu-boot-imx-59a1b72ced4f3eff6e7e26e566e6090a5e25d384.zip
u-boot-imx-59a1b72ced4f3eff6e7e26e566e6090a5e25d384.tar.gz
u-boot-imx-59a1b72ced4f3eff6e7e26e566e6090a5e25d384.tar.bz2
input: Fix i8042 keyboard reset
The i8042 keyboard reset was not checking the results of the output buffer after the reset command. This can jam up some KBC/keyboards. Also, remove a write to the wrong register and the CONFIG setting around the incorrect write. Signed-off-by: Marc Jones <marc.jones@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@ti.com>
-rw-r--r--drivers/input/i8042.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 691aabf..26958aa 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -666,31 +666,53 @@ static int kbd_input_empty(void)
/******************************************************************************/
+static int wait_until_kbd_output_full(void)
+{
+ int kbdTimeout = KBD_TIMEOUT * 1000;
+
+ while (((in8(I8042_STATUS_REG) & 0x01) == 0) && kbdTimeout--)
+ udelay(1);
+
+ return kbdTimeout != -1;
+}
+
+/******************************************************************************/
+
static int kbd_reset(void)
{
+ /* KB Reset */
if (kbd_input_empty() == 0)
return -1;
out8(I8042_DATA_REG, 0xff);
+ if (wait_until_kbd_output_full() == 0)
+ return -1;
+
+ if (in8(I8042_DATA_REG) != 0xfa) /* ACK */
+ return -1;
+
+ if (wait_until_kbd_output_full() == 0)
+ return -1;
+
+ if (in8(I8042_DATA_REG) != 0xaa) /* Test Pass*/
+ return -1;
+
if (kbd_input_empty() == 0)
return -1;
-#ifdef CONFIG_USE_CPCIDVI
+ /* Set KBC mode */
out8(I8042_COMMAND_REG, 0x60);
-#else
- out8(I8042_DATA_REG, 0x60);
-#endif
if (kbd_input_empty() == 0)
return -1;
out8(I8042_DATA_REG, 0x45);
-
if (kbd_input_empty() == 0)
return -1;
+ /* Enable Keyboard */
out8(I8042_COMMAND_REG, 0xae);
if (kbd_input_empty() == 0)