diff mbox

[U-Boot,2/5] x86: i8042: Correctly initialize the controller

Message ID BLU436-SMTP188E7289F5EA82ABBC268BDBF790@phx.gbl
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Bin Meng Aug. 17, 2015, 10:45 a.m. UTC
The existing i8042 keyboard controller driver has some issues.
First of all, it does not issue a self-test command (0xaa) to the
controller at the very beginning. Without this, the controller
does not respond any command at all. Secondly, it initializes
the configuration byte reigster to turn on keyboard's interrupt,
which is not allowed as U-Boot we don't normally enable interrupt.
Finally, at the end of the initialization routine, it wrongly
sets the controller to disable all interfaces including both
keyboard and mouse.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/input/i8042.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

Comments

Simon Glass Aug. 18, 2015, 2 a.m. UTC | #1
On 17 August 2015 at 04:45, Bin Meng <bmeng.cn@gmail.com> wrote:
> The existing i8042 keyboard controller driver has some issues.
> First of all, it does not issue a self-test command (0xaa) to the
> controller at the very beginning. Without this, the controller
> does not respond any command at all. Secondly, it initializes
> the configuration byte reigster to turn on keyboard's interrupt,
> which is not allowed as U-Boot we don't normally enable interrupt.
> Finally, at the end of the initialization routine, it wrongly
> sets the controller to disable all interfaces including both
> keyboard and mouse.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  drivers/input/i8042.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 1769c5e..3799580 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -664,6 +664,18 @@  static int wait_until_kbd_output_full(void)
 
 static int kbd_reset(void)
 {
+	/* controller self test */
+	if (kbd_input_empty() == 0)
+		return -1;
+
+	out8(I8042_COMMAND_REG, 0xaa);
+
+	if (wait_until_kbd_output_full() == 0)
+		return -1;
+
+	if (in8(I8042_DATA_REG) != 0x55) /* success */
+		return -1;
+
 	/* KB Reset */
 	if (kbd_input_empty() == 0)
 		return -1;
@@ -691,7 +703,7 @@  static int kbd_reset(void)
 	if (kbd_input_empty() == 0)
 		return -1;
 
-	out8(I8042_DATA_REG, 0x45);
+	out8(I8042_DATA_REG, 0x44);
 
 	if (kbd_input_empty() == 0)
 		return -1;
@@ -701,13 +713,5 @@  static int kbd_reset(void)
 	if (kbd_input_empty() == 0)
 		return -1;
 
-	out8(I8042_COMMAND_REG, 0x60);
-	if (kbd_input_empty() == 0)
-		return -1;
-
-	out8(I8042_DATA_REG, 0xf4);
-	if (kbd_input_empty() == 0)
-		return -1;
-
 	return 0;
 }