[coreboot-gerrit] Patch set updated for coreboot: 7d52c2b keyboard: Check keyboard controller is ready first
Andrew Wu (arw@dmp.com.tw)
gerrit at coreboot.org
Fri Oct 11 13:25:20 CEST 2013
Andrew Wu (arw at dmp.com.tw) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3958
-gerrit
commit 7d52c2b0566a878194fd933979fad8456d980c54
Author: Andrew Wu <arw at dmp.com.tw>
Date: Fri Oct 11 13:44:55 2013 +0800
keyboard: Check keyboard controller is ready first
PS/2 keyboard controller (8042) has a system flag bit in status byte
(bit 2 of 0x64 port). This bit indicates keyboard controller is ready
or not. System reset clears this bit, and when keyboard controller is
ready, this bit is set.
Add checking system flag bit in kbc_self_test function to make
sure keyboard controller is ready to accept commands.
It is important for Vortex86EX keyboard controller, which has a long
startup time.
Change-Id: I2cdb533a5b25575e1717434533a60decf748f6d8
Signed-off-by: Andrew Wu <arw at dmp.com.tw>
---
src/drivers/pc80/keyboard.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/drivers/pc80/keyboard.c b/src/drivers/pc80/keyboard.c
index 2888bcf..7388920 100644
--- a/src/drivers/pc80/keyboard.c
+++ b/src/drivers/pc80/keyboard.c
@@ -31,6 +31,7 @@
#define KBD_STATUS 0x64
#define KBD_IBF (1 << 1) // 1: input buffer full (data ready for ec)
#define KBD_OBF (1 << 0) // 1: output buffer full (data ready for host)
+#define KBD_SYS_FLAG (1 << 2) // 1: self-test passed
// Keyboard Controller Commands
#define KBC_CMD_READ_COMMAND 0x20 // Read command byte
@@ -64,6 +65,18 @@
/* Wait 400ms for keyboard controller answers */
#define KBC_TIMEOUT_IN_MS 400
+static int kbc_wait_system_flag(void)
+{
+ u32 timeout;
+ for (timeout = KBC_TIMEOUT_IN_MS;
+ timeout && ((inb(KBD_STATUS) & KBD_SYS_FLAG) == 0); timeout--)
+ mdelay(1);
+
+ if (!timeout)
+ printk(BIOS_INFO, "Keyboard controller timed out setting system flag\n");
+ return !!timeout;
+}
+
static int kbc_input_buffer_empty(void)
{
u32 timeout;
@@ -113,6 +126,10 @@ static int kbc_self_test(void)
{
u8 self_test;
+ /* Wait until keyboard controller ready (system flag = 1) */
+ if (!kbc_wait_system_flag())
+ return 0;
+
/* Clean up any junk that might have been in the KBC.
* Both input and output buffers must be empty.
*/
More information about the coreboot-gerrit
mailing list