[coreboot-gerrit] Change in coreboot[master]: ec/lenovo/h8: Fix keyboard init on first boot

Patrick Rudolph (Code Review) gerrit at coreboot.org
Fri Jul 7 17:07:03 CEST 2017


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 at 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);
 }
 

-- 
To view, visit https://review.coreboot.org/20488
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ba7e5cb67f3dfeb2bc3d50b28757efa63c84391
Gerrit-Change-Number: 20488
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <siro at das-labor.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170707/576882bd/attachment.html>


More information about the coreboot-gerrit mailing list