Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/20488
Change subject: ec/lenovo/h8: Fix keyboard init on first boot ......................................................................
ec/lenovo/h8: Fix keyboard init on first boot
On first boot after power failure the keyboard does not initialize. After Linux has been booted and the power is kept the keyboard controller can be initialized.
Disable keyboard and mouse port and issue a self test.
Tested on Lenovo T430. The keyboard is initialized on every boot, even after power failure (no AC and removed battery).
Needs tests on other Lenovos.
Change-Id: I1ba7e5cb67f3dfeb2bc3d50b28757efa63c84391 Signed-off-by: Patrick Rudolph siro@das-labor.org --- M src/ec/lenovo/h8/h8.c 1 file changed, 26 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/88/20488/1
diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index b259d9a..9b569a5 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -193,8 +193,34 @@ } #endif
+#define KBD_DATA 0x60 +#define KBD_COMMAND 0x64 +#define KBD_STATUS 0x64 + +static bool h8_wait_kb_ready(void) +{ + size_t timeout = 1000; + while ((inb(KBD_STATUS) & 2) && timeout) + timeout--; + return timeout > 0; +} + static void h8_init(device_t dev) { + /* Lenovo early keyboard controller init sequence */ + /* Disable keyboard */ + if (h8_wait_kb_ready()) + outb(0xad, KBD_COMMAND); + /* Disable mouse */ + if (h8_wait_kb_ready()) + outb(0xa7, KBD_COMMAND); + /* Clear input buffer */ + if (inb(KBD_STATUS) & 1) + inb(KBD_DATA); + /* Self test, don't read result ... */ + if (h8_wait_kb_ready()) + outb(0xaa, KBD_COMMAND); + pc_keyboard_init(NO_AUX_DEVICE); }