Add option to handle PS2 keyboards that have a slow power up.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 28 May 2011 15:00:28 +0000 (11:00 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 28 May 2011 15:00:28 +0000 (11:00 -0400)
Add PS2_KEYBOARD_SPINUP option to give certain keyboards more time to
initialize.

Based on report and feedback from: Sven Schnelle <svens@stackframe.org>

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/Kconfig
src/ps2port.c

index 123db018edf97239e845038f0a89a4ee4c6845c7..2195badb35541d619ae9cd8f7d2d5785015ca5d2 100644 (file)
@@ -125,6 +125,14 @@ menu "Hardware support"
         default y
         help
             Support PS2 ports (keyboard and mouse).
+    config PS2_KEYBOARD_SPINUP
+        depends on PS2PORT
+        int "Extra time (in ms) to allow a keyboard to initialize"
+        default 0
+        help
+            Some PS2 keyboards don't respond to commands immediately
+            after powering on.  Specify a positive value here to allow
+            additional time for the keyboard to become responsive.
 
     config USB
         bool "USB"
index 81d47c9e62cb597799ded435d65547505cfcb5ec..8259f659a14211b490dd3ef417725ea88b8d04a0 100644 (file)
@@ -438,9 +438,18 @@ 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(CONFIG_PS2_KEYBOARD_SPINUP);
+    for (;;) {
+        ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
+        if (!ret)
+            break;
+        if (check_tsc(end)) {
+            if (CONFIG_PS2_KEYBOARD_SPINUP)
+                warn_timeout();
+            return;
+        }
+        yield();
+    }
     if (param[0] != 0xaa) {
         dprintf(1, "keyboard self test failed (got %x not 0xaa)\n", param[0]);
         return;