Some keyboards take pretty long to respond to a reset command, some even
delay the ACK to the command. To make the keyboard driver more robust,
increase the timeout for this special command. Also do an interface test
after the self-test to ensure the keyboard is functioning properly.
Another point is to reenable the keyboard *after* the scancode was set,
not before. We also set the system bit when enabling the keyboard
because this seems to be what older operating systems do expect.
One of the problematic keyboards, which will work with this patch
applied, is the DELL RT7D20. Without the patch an overly optimistic
operating system, read Linux 2.4, will not recognise the keyboard
because coreboot didn't fully initialize it.
Signed-off-by: Mathias Krause <mathias.krause(a)secunet.com>
---
Since I was unable to download the git tree (why is it HTTP only, btw?) a
patch against a tarball snapshot.
diff -urp coreboot-403d2d6/src/pc80/keyboard.c coreboot-kbd_fix/src/pc80/keyboard.c
--- coreboot-403d2d6/src/pc80/keyboard.c 2011-12-08 22:42:04.000000000 +0100
+++ coreboot-kbd_fix/src/pc80/keyboard.c 2011-12-12 10:16:04.000000000 +0100
@@ -36,6 +36,7 @@
#define KBC_CMD_READ_COMMAND 0x20 // Read command byte
#define KBC_CMD_WRITE_COMMAND 0x60 // Write command byte
#define KBC_CMD_SELF_TEST 0xAA // Controller self-test
+#define KBC_CMD_KBD_TEST 0xAB // Keyboard Interface test
/* The Keyboard controller command byte
* BIT | Description
@@ -136,6 +137,26 @@ static int kbc_self_test(void)
return 0;
}
+ /* ensure the buffers are empty */
+ kbc_cleanup_buffers();
+
+ /* keyboard interface test */
+ outb(KBC_CMD_KBD_TEST, KBD_COMMAND);
+
+ if (!kbc_output_buffer_full()) {
+ printk(BIOS_ERR, "Keyboard Interface test timed out.\n");
+ return 0;
+ }
+
+ /* read test result, 0x00 should be returned in case of no failures */
+ self_test = inb(KBD_DATA);
+
+ if (self_test != 0x00) {
+ printk(BIOS_ERR, "Keyboard Interface test failed: 0x%x\n",
+ self_test);
+ return 0;
+ }
+
return 1;
}
@@ -147,6 +168,14 @@ static u8 send_keyboard(u8 command)
do {
if (!kbc_input_buffer_empty()) return 0;
outb(command, KBD_DATA);
+ /* the reset command takes much longer then normal commands and
+ * even worse, some keyboards do send the ACK _after_ doing the
+ * reset */
+ if (command == 0xFF) {
+ u8 retries;
+ for (retries = 9; retries && !kbc_output_buffer_full(); retries--)
+ ;
+ }
if (!kbc_output_buffer_full()) {
printk(BIOS_ERR, "Could not send keyboard command %02x\n",
command);
@@ -161,6 +190,7 @@ static u8 send_keyboard(u8 command)
void pc_keyboard_init(struct pc_keyboard *keyboard)
{
+ u8 retries;
u8 regval;
if (!CONFIG_DRIVERS_PS2_KEYBOARD)
return;
@@ -192,10 +222,14 @@ void pc_keyboard_init(struct pc_keyboard
}
if (regval != KBD_REPLY_ACK) {
- printk(BIOS_ERR, "Keyboard selftest failed ACK: 0x%x\n", regval);
+ printk(BIOS_ERR, "Keyboard reset failed ACK: 0x%x\n", regval);
return;
}
+ /* the reset command takes some time, so wait a little longer */
+ for (retries = 9; retries && !kbc_output_buffer_full(); retries--)
+ ;
+
if (!kbc_output_buffer_full()) {
printk(BIOS_ERR, "Timeout waiting for keyboard after reset.\n");
return;
@@ -203,7 +237,7 @@ void pc_keyboard_init(struct pc_keyboard
regval = inb(KBD_DATA);
if (regval != 0xAA) {
- printk(BIOS_ERR, "Keyboard selftest failed: 0x%x\n", regval);
+ printk(BIOS_ERR, "Keyboard reset selftest failed: 0x%x\n", regval);
return;
}
@@ -232,20 +266,20 @@ void pc_keyboard_init(struct pc_keyboard
return;
}
- /* enable the keyboard */
- regval = send_keyboard(0xF4);
- if (regval != KBD_REPLY_ACK) {
- printk(BIOS_ERR, "Keyboard enable failed ACK: 0x%x\n", regval);
- return;
- }
-
/* All is well - enable keyboard interface */
if (!kbc_input_buffer_empty()) return;
outb(0x60, KBD_COMMAND);
if (!kbc_input_buffer_empty()) return;
- outb(0x61, KBD_DATA); /* send cmd: enable keyboard and IRQ 1 */
+ outb(0x65, KBD_DATA); /* send cmd: enable keyboard and IRQ 1 */
if (!kbc_input_buffer_empty()) {
- printk(BIOS_ERR, "Timeout during final keyboard enable\n");
+ printk(BIOS_ERR, "Timeout during keyboard enable\n");
+ return;
+ }
+
+ /* enable the keyboard */
+ regval = send_keyboard(0xF4);
+ if (regval != KBD_REPLY_ACK) {
+ printk(BIOS_ERR, "Keyboard enable failed ACK: 0x%x\n", regval);
return;
}
}
Marc Jones (marcj303(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/487
-gerrit
commit 482f5346ca1a49602cf0b3a3f69a22442a25dab1
Author: Marc Jones <marcj303(a)gmail.com>
Date: Wed Dec 14 15:33:33 2011 -0700
Fix Fam10 MMCONF_SUPPORT_DEFAULT setting.
I misunderstood how kconfig select works. It needs to be selected with a config option. Moved the select to the correct location.
Change-Id: If9b1e21e6cbc5af4671efb76cf87dd18dbbe2234
Signed-off-by: Marc Jones <marcj303(a)gmail.com>
---
src/cpu/amd/model_10xxx/Kconfig | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/src/cpu/amd/model_10xxx/Kconfig b/src/cpu/amd/model_10xxx/Kconfig
index 310f98d..221d044 100644
--- a/src/cpu/amd/model_10xxx/Kconfig
+++ b/src/cpu/amd/model_10xxx/Kconfig
@@ -2,6 +2,7 @@ config CPU_AMD_MODEL_10XXX
bool
select SSE
select SSE2
+ select MMCONF_SUPPORT_DEFAULT
if CPU_AMD_MODEL_10XXX
config CPU_ADDR_BITS
@@ -82,6 +83,4 @@ config UPDATE_CPU_MICROCODE
patches, so you may need to also disable microcode updates in
your operating system in order for this option to matter.
-select MMCONF_SUPPORT_DEFAULT
-
endif # CPU_AMD_MODEL_10XXX
the following patch was just integrated into master:
commit c18ecfd8b74b1a38bee90270e36630f9fad74b98
Author: Sven Schnelle <svens(a)stackframe.org>
Date: Wed Dec 7 14:30:58 2011 -0800
Lenovo X60/T60: add first_battery setting
The EC allows to select the order in which batteries are (dis)charged.
Make this setting available to the user.
Change-Id: Id2a98192565419dbb53f3a7cf0b2c46b672a3ed8
Signed-off-by: Sven Schnelle <svens(a)stackframe.org>
Build-Tested: build bot (Jenkins) at Wed Dec 7 23:53:28 2011, giving +1
Reviewed-By: Stefan Reinauer <stefan.reinauer(a)coreboot.org> at Fri Dec 9 21:47:10 2011, giving +2
Reviewed-By: Peter Stuge <peter(a)stuge.se> at Wed Dec 14 09:41:46 2011, giving +2
See http://review.coreboot.org/475 for details.
-gerrit
the following patch was just integrated into master:
commit 6cd0925c8ba4a894ca053fa40477d79122cd6fba
Author: Florian Zumbiehl <florz(a)florz.de>
Date: Tue Dec 6 10:31:10 2011 +0100
asus k8v-x: explicitly set RAM and bus voltages
Change-Id: I9426cafc252ee765d723af569c4a90e090d313d9
Signed-off-by: Florian Zumbiehl <florz(a)florz.de>
Build-Tested: build bot (Jenkins) at Sat Dec 10 20:22:34 2011, giving +1
Reviewed-By: Peter Stuge <peter(a)stuge.se> at Wed Dec 14 08:51:58 2011, giving +2
See http://review.coreboot.org/482 for details.
-gerrit
the following patch was just integrated into master:
commit 242cb03ce02bde431666e5e6ac7d0eb1375eeba0
Author: Florian Zumbiehl <florz(a)florz.de>
Date: Sat Dec 10 19:39:49 2011 +0100
k8: add CONFIG_K8_FORCE_2T_DRAM_TIMING and enable it for asus k8v-x
Change-Id: Ia457f92f6fb7e287defb838db07f12d0f1766757
Signed-off-by: Florian Zumbiehl <florz(a)florz.de>
Build-Tested: build bot (Jenkins) at Sat Dec 10 20:09:46 2011, giving +1
Reviewed-By: Peter Stuge <peter(a)stuge.se> at Wed Dec 14 08:50:45 2011, giving +2
See http://review.coreboot.org/481 for details.
-gerrit
Peter Stuge (peter(a)stuge.se) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/486
-gerrit
commit cc2e8ec8e1da449915789fe13cc645f23b94669c
Author: Mathias Krause <mathias.krause(a)secunet.com>
Date: Wed Dec 14 08:40:48 2011 +0100
kbd: wait longer for self-test on keyboard reset
Some keyboards take pretty long to respond to a reset command, some even
delay the ACK to the command. To make the keyboard driver more robust,
increase the timeout for this special command. Also do an interface test
after the self-test to ensure the keyboard is functioning properly.
Another point is to reenable the keyboard *after* the scancode was set,
not before. We also set the system bit when enabling the keyboard
because this seems to be what older operating systems do expect.
One of the problematic keyboards, which will work with this patch
applied, is the DELL RT7D20. Without the patch an overly optimistic
operating system, read Linux 2.4, will not recognise the keyboard
because coreboot didn't fully initialize it.
Change-Id: I28c8e05bdde61f71b7de084c96bc2447c1b9575e
Signed-off-by: Mathias Krause <mathias.krause(a)secunet.com>
---
src/pc80/keyboard.c | 56 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/src/pc80/keyboard.c b/src/pc80/keyboard.c
index 8552860..e0a6643 100644
--- a/src/pc80/keyboard.c
+++ b/src/pc80/keyboard.c
@@ -36,6 +36,7 @@
#define KBC_CMD_READ_COMMAND 0x20 // Read command byte
#define KBC_CMD_WRITE_COMMAND 0x60 // Write command byte
#define KBC_CMD_SELF_TEST 0xAA // Controller self-test
+#define KBC_CMD_KBD_TEST 0xAB // Keyboard Interface test
/* The Keyboard controller command byte
* BIT | Description
@@ -136,6 +137,26 @@ static int kbc_self_test(void)
return 0;
}
+ /* ensure the buffers are empty */
+ kbc_cleanup_buffers();
+
+ /* keyboard interface test */
+ outb(KBC_CMD_KBD_TEST, KBD_COMMAND);
+
+ if (!kbc_output_buffer_full()) {
+ printk(BIOS_ERR, "Keyboard Interface test timed out.\n");
+ return 0;
+ }
+
+ /* read test result, 0x00 should be returned in case of no failures */
+ self_test = inb(KBD_DATA);
+
+ if (self_test != 0x00) {
+ printk(BIOS_ERR, "Keyboard Interface test failed: 0x%x\n",
+ self_test);
+ return 0;
+ }
+
return 1;
}
@@ -147,6 +168,14 @@ static u8 send_keyboard(u8 command)
do {
if (!kbc_input_buffer_empty()) return 0;
outb(command, KBD_DATA);
+ /* the reset command takes much longer then normal commands and
+ * even worse, some keyboards do send the ACK _after_ doing the
+ * reset */
+ if (command == 0xFF) {
+ u8 retries;
+ for (retries = 9; retries && !kbc_output_buffer_full(); retries--)
+ ;
+ }
if (!kbc_output_buffer_full()) {
printk(BIOS_ERR, "Could not send keyboard command %02x\n",
command);
@@ -161,6 +190,7 @@ static u8 send_keyboard(u8 command)
void pc_keyboard_init(struct pc_keyboard *keyboard)
{
+ u8 retries;
u8 regval;
if (!CONFIG_DRIVERS_PS2_KEYBOARD)
return;
@@ -192,10 +222,14 @@ void pc_keyboard_init(struct pc_keyboard *keyboard)
}
if (regval != KBD_REPLY_ACK) {
- printk(BIOS_ERR, "Keyboard selftest failed ACK: 0x%x\n", regval);
+ printk(BIOS_ERR, "Keyboard reset failed ACK: 0x%x\n", regval);
return;
}
+ /* the reset command takes some time, so wait a little longer */
+ for (retries = 9; retries && !kbc_output_buffer_full(); retries--)
+ ;
+
if (!kbc_output_buffer_full()) {
printk(BIOS_ERR, "Timeout waiting for keyboard after reset.\n");
return;
@@ -203,7 +237,7 @@ void pc_keyboard_init(struct pc_keyboard *keyboard)
regval = inb(KBD_DATA);
if (regval != 0xAA) {
- printk(BIOS_ERR, "Keyboard selftest failed: 0x%x\n", regval);
+ printk(BIOS_ERR, "Keyboard reset selftest failed: 0x%x\n", regval);
return;
}
@@ -232,20 +266,20 @@ void pc_keyboard_init(struct pc_keyboard *keyboard)
return;
}
- /* enable the keyboard */
- regval = send_keyboard(0xF4);
- if (regval != KBD_REPLY_ACK) {
- printk(BIOS_ERR, "Keyboard enable failed ACK: 0x%x\n", regval);
- return;
- }
-
/* All is well - enable keyboard interface */
if (!kbc_input_buffer_empty()) return;
outb(0x60, KBD_COMMAND);
if (!kbc_input_buffer_empty()) return;
- outb(0x61, KBD_DATA); /* send cmd: enable keyboard and IRQ 1 */
+ outb(0x65, KBD_DATA); /* send cmd: enable keyboard and IRQ 1 */
if (!kbc_input_buffer_empty()) {
- printk(BIOS_ERR, "Timeout during final keyboard enable\n");
+ printk(BIOS_ERR, "Timeout during keyboard enable\n");
+ return;
+ }
+
+ /* enable the keyboard */
+ regval = send_keyboard(0xF4);
+ if (regval != KBD_REPLY_ACK) {
+ printk(BIOS_ERR, "Keyboard enable failed ACK: 0x%x\n", regval);
return;
}
}