[coreboot] Keyboard not working on Thinkpad X60/T60

Sven Schnelle svens at stackframe.org
Sat May 28 16:23:35 CEST 2011


Hi Kevin,

Kevin O'Connor <kevin at koconnor.net> writes:

> On Sat, May 07, 2011 at 08:48:45PM +0200, Sven Schnelle wrote:
>> Kevin O'Connor <kevin at koconnor.net> writes:
>> > Some ps2 ports send NAK (0xfe) when there is no keyboard plugged in.
>> > The detection for NAK was added so that it doesn't take a full second
>> > to recognize that no keyboard is present.  The patch you sent would
>> > loop infinitely in this situation.
>> 
>> Yes, the patch was only for testing purposes. :)
>> 
>> I feared that are controllers out there that behave like this, so i have
>> to find another solution.
>
> How about something like (untested):
>
> --- a/src/ps2port.c
> +++ b/src/ps2port.c
> @@ -438,9 +438,14 @@ keyboard_init(void *data)
>  
>      /* ------------------- keyboard side ------------------------*/
>      /* reset keyboard and self test  (keyboard side) */
> -    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> -    if (ret)
> -        return;
> +    u64 end = calc_future_tsc(4000);
> +    for (;;) {
> +        ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
> +        if (!ret)
> +            break;
> +        if (check_tsc(end))
> +            return;
> +    }
>      if (param[0] != 0xaa) {
>          dprintf(1, "keyboard self test failed (got %x not 0xaa)\n", param[0]);
>          return;
>
> If it works, the 4000 could be turned into a config option.

Yes, that fixes it. I'm using the patch below right now.

Not sure about the default value, but 0 seems to be safe to not
introduce an additional delay for other users ;)

Signed-off-by: Sven Schnelle <svens at stackframe.org>

diff --git a/src/Kconfig b/src/Kconfig
index 123db01..21cef19 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -126,6 +126,14 @@ menu "Hardware support"
         help
             Support PS2 ports (keyboard and mouse).
 
+    config PS2_RESET_TIMEOUT
+        depends on PS2PORT
+        int "Reset timeout (in ms)"
+        default 0
+        help
+            This option specifies how long we should wait for the Keyboard.
+            Some keyboards are requiring a delay after POR for initialization.
+
     config USB
         bool "USB"
         default y
diff --git a/src/ps2port.c b/src/ps2port.c
index 81d47c9..3df8a8a 100644
--- a/src/ps2port.c
+++ b/src/ps2port.c
@@ -438,7 +438,9 @@ keyboard_init(void *data)
 
     /* ------------------- keyboard side ------------------------*/
     /* reset keyboard and self test  (keyboard side) */
-    ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
+    u64 end = calc_future_tsc(CONFIG_PS2_RESET_TIMEOUT);
+    while ((ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param)) && !check_tsc(end));
+
     if (ret)
         return;
     if (param[0] != 0xaa) {




More information about the coreboot mailing list