[coreboot-gerrit] Change in coreboot[master]: ec/acpi: add mechanisms about timeout

Bill XIE (Code Review) gerrit at coreboot.org
Thu Oct 26 09:02:15 CEST 2017


Bill XIE has uploaded this change for review. ( https://review.coreboot.org/22180


Change subject: ec/acpi: add mechanisms about timeout
......................................................................

ec/acpi: add mechanisms about timeout

Sometimes (observed on Thinkpad T400s during cold boot)
a few (only one observed) garbage bytes may detained in
the output queue of EC after power up, and they may
disrupt the interaction during EC's enablement, causing
locked rfkill.

Those garbage bytes could be received out from EC until
a timeout occurred. To do so a static flag is added to
hold the timeout state, with a function to query such
state.

Change-Id: Iee031306c02f5211a4512c6b4ec90f7f0db196ae
Signed-off-by: Bill XIE <persmule at gmail.com>
---
M src/ec/acpi/ec.c
M src/ec/acpi/ec.h
2 files changed, 44 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/80/22180/1

diff --git a/src/ec/acpi/ec.c b/src/ec/acpi/ec.c
index a739b98..10209fb 100644
--- a/src/ec/acpi/ec.c
+++ b/src/ec/acpi/ec.c
@@ -25,10 +25,33 @@
 static const int ec_cmd_reg = EC_SC;
 static const int ec_data_reg = EC_DATA;
 
+static void ec_set_timeout(int is_timeout)
+{
+}
+
+int ec_get_timeout(void)
+{
+	return 0;
+}
+
 #else
 
 static int ec_cmd_reg = EC_SC;
 static int ec_data_reg = EC_DATA;
+
+//Flag to hold timeout state.
+static int ec_is_timeout = 0;
+
+static void ec_set_timeout(int is_timeout)
+{
+	ec_is_timeout = is_timeout;
+}
+
+//Query whether last communication with EC is timed out.
+int ec_get_timeout(void)
+{
+	return ec_is_timeout;
+}
 
 #endif
 
@@ -45,7 +68,10 @@
 	if (!timeout) {
 		printk(BIOS_DEBUG, "Timeout while sending command 0x%02x to EC!\n",
 				command);
+		ec_set_timeout(1);
 		// return -1;
+	} else {
+		ec_set_timeout(0);
 	}
 
 	udelay(10);
@@ -67,7 +93,10 @@
 	if (!timeout) {
 		printk(BIOS_DEBUG, "Timeout while sending data 0x%02x to EC!\n",
 				data);
+		ec_set_timeout(1);
 		// return -1;
+	} else {
+		ec_set_timeout(0);
 	}
 
 	udelay(10);
@@ -101,6 +130,9 @@
 	if (!timeout) {
 		printk(BIOS_DEBUG, "\nTimeout while receiving data from EC!\n");
 		// return -1;
+		ec_set_timeout(1);
+	} else {
+		ec_set_timeout(0);
 	}
 
 	udelay(10);
@@ -111,6 +143,16 @@
 	return data;
 }
 
+void ec_clear_out_queue(void)
+{
+	printk(BIOS_SPEW, "Clearing EC output queue...\n");
+	//recv_ec_data until timeout occurs
+	do {
+		recv_ec_data();
+	} while (!ec_get_timeout());
+	printk(BIOS_SPEW, "EC output queue should have been cleared.\n");
+}
+
 u8 ec_read(u8 addr)
 {
 	send_ec_command(0x80);
diff --git a/src/ec/acpi/ec.h b/src/ec/acpi/ec.h
index d9487e9..a899a04 100644
--- a/src/ec/acpi/ec.h
+++ b/src/ec/acpi/ec.h
@@ -40,6 +40,8 @@
 int send_ec_data(u8 data);
 int send_ec_data_nowait(u8 data);
 u8 recv_ec_data(void);
+int ec_get_timeout(void);
+void ec_clear_out_queue(void);
 u8 ec_status(void);
 u8 ec_query(void);
 u8 ec_read(u8 addr);

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

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee031306c02f5211a4512c6b4ec90f7f0db196ae
Gerrit-Change-Number: 22180
Gerrit-PatchSet: 1
Gerrit-Owner: Bill XIE <persmule at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171026/ace49f17/attachment.html>


More information about the coreboot-gerrit mailing list