[coreboot-gerrit] New patch to review for coreboot: 1056907 dmp/vortex86ex: Add timeout for keyboard system flag checking.

Andrew Wu (arw@dmp.com.tw) gerrit at coreboot.org
Thu Oct 24 14:40:54 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/3988

-gerrit

commit 1056907696e02e3bf59e6d00b5b0a1e28e6e5df0
Author: Andrew Wu <arw at dmp.com.tw>
Date:   Thu Oct 24 20:37:48 2013 +0800

    dmp/vortex86ex: Add timeout for keyboard system flag checking.
    
    If Vortex86EX PS/2 keyboard controller system flag bit timeout,
    reload controller firmware code and try again.
    
    Change-Id: I24aec4b20d85c721c01e72686f3eb1259f9334b8
    Signed-off-by: Andrew Wu <arw at dmp.com.tw>
---
 src/southbridge/dmp/vortex86ex/southbridge.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/southbridge/dmp/vortex86ex/southbridge.c b/src/southbridge/dmp/vortex86ex/southbridge.c
index ddb99b8..7ae39e8 100644
--- a/src/southbridge/dmp/vortex86ex/southbridge.c
+++ b/src/southbridge/dmp/vortex86ex/southbridge.c
@@ -25,6 +25,7 @@
 #include <pc80/mc146818rtc.h>
 #include <pc80/keyboard.h>
 #include <string.h>
+#include <delay.h>
 #include "arch/io.h"
 #include "chip.h"
 #include "southbridge.h"
@@ -95,6 +96,9 @@ static const unsigned char irq_to_int_routing[16] = {
 #define POST_KBD_IS_READY 0x08
 #define POST_KBD_FW_VERIFY_FAILURE 0x82
 
+/* keyboard controller system flag timeout */
+#define KBC_TIMEOUT_SYS_FLAG 400
+
 static u8 get_pci_dev_func(device_t dev)
 {
 	return PCI_FUNC(dev->path.pci.devfn);
@@ -140,15 +144,21 @@ static void upload_dmp_keyboard_firmware(struct device *dev)
 	pci_write_config32(dev, SB_REG_IPFCR, reg_sb_c0 & ~0x400L);
 }
 
-static void kbc_wait_system_flag(void)
+static int kbc_wait_system_flag(void)
 {
 	/* wait keyboard controller ready by checking system flag
 	 * (status port bit 2).
 	 */
 	post_code(POST_KBD_CHK_READY);
-	while ((inb(0x64) & 0x4) == 0) {
+	u32 timeout;
+	for (timeout = KBC_TIMEOUT_SYS_FLAG;
+	     timeout && ((inb(0x64) & 0x4) == 0); timeout--)
+		mdelay(1);
+
+	if (!timeout) {
+		printk(BIOS_WARNING, "Keyboard controller system flag timeout\n");
 	}
-	post_code(POST_KBD_IS_READY);
+	return !!timeout;
 }
 
 static void pci_routing_fixup(struct device *dev)
@@ -577,7 +587,13 @@ static void southbridge_init(struct device *dev)
 
 	fix_cmos_rtc_time();
 	rtc_init(0);
-	kbc_wait_system_flag();
+	/* Check keyboard controller ready. If timeout, reload firmware code
+	 * and try again.
+	 */
+	while (!kbc_wait_system_flag()) {
+		upload_dmp_keyboard_firmware(dev);
+	}
+	post_code(POST_KBD_IS_READY);
 	pc_keyboard_init(0);
 }
 



More information about the coreboot-gerrit mailing list