<p>Bill XIE has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/22180">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ec/acpi: add mechanisms about timeout<br><br>Sometimes (observed on Thinkpad T400s during cold boot)<br>a few (only one observed) garbage bytes may detained in<br>the output queue of EC after power up, and they may<br>disrupt the interaction during EC's enablement, causing<br>locked rfkill.<br><br>Those garbage bytes could be received out from EC until<br>a timeout occurred. To do so a static flag is added to<br>hold the timeout state, with a function to query such<br>state.<br><br>Change-Id: Iee031306c02f5211a4512c6b4ec90f7f0db196ae<br>Signed-off-by: Bill XIE <persmule@gmail.com><br>---<br>M src/ec/acpi/ec.c<br>M src/ec/acpi/ec.h<br>2 files changed, 44 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/80/22180/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/ec/acpi/ec.c b/src/ec/acpi/ec.c<br>index a739b98..10209fb 100644<br>--- a/src/ec/acpi/ec.c<br>+++ b/src/ec/acpi/ec.c<br>@@ -25,10 +25,33 @@<br> static const int ec_cmd_reg = EC_SC;<br> static const int ec_data_reg = EC_DATA;<br> <br>+static void ec_set_timeout(int is_timeout)<br>+{<br>+}<br>+<br>+int ec_get_timeout(void)<br>+{<br>+ return 0;<br>+}<br>+<br> #else<br> <br> static int ec_cmd_reg = EC_SC;<br> static int ec_data_reg = EC_DATA;<br>+<br>+//Flag to hold timeout state.<br>+static int ec_is_timeout = 0;<br>+<br>+static void ec_set_timeout(int is_timeout)<br>+{<br>+ ec_is_timeout = is_timeout;<br>+}<br>+<br>+//Query whether last communication with EC is timed out.<br>+int ec_get_timeout(void)<br>+{<br>+ return ec_is_timeout;<br>+}<br> <br> #endif<br> <br>@@ -45,7 +68,10 @@<br> if (!timeout) {<br> printk(BIOS_DEBUG, "Timeout while sending command 0x%02x to EC!\n",<br> command);<br>+ ec_set_timeout(1);<br> // return -1;<br>+ } else {<br>+ ec_set_timeout(0);<br> }<br> <br> udelay(10);<br>@@ -67,7 +93,10 @@<br> if (!timeout) {<br> printk(BIOS_DEBUG, "Timeout while sending data 0x%02x to EC!\n",<br> data);<br>+ ec_set_timeout(1);<br> // return -1;<br>+ } else {<br>+ ec_set_timeout(0);<br> }<br> <br> udelay(10);<br>@@ -101,6 +130,9 @@<br> if (!timeout) {<br> printk(BIOS_DEBUG, "\nTimeout while receiving data from EC!\n");<br> // return -1;<br>+ ec_set_timeout(1);<br>+ } else {<br>+ ec_set_timeout(0);<br> }<br> <br> udelay(10);<br>@@ -111,6 +143,16 @@<br> return data;<br> }<br> <br>+void ec_clear_out_queue(void)<br>+{<br>+ printk(BIOS_SPEW, "Clearing EC output queue...\n");<br>+ //recv_ec_data until timeout occurs<br>+ do {<br>+ recv_ec_data();<br>+ } while (!ec_get_timeout());<br>+ printk(BIOS_SPEW, "EC output queue should have been cleared.\n");<br>+}<br>+<br> u8 ec_read(u8 addr)<br> {<br> send_ec_command(0x80);<br>diff --git a/src/ec/acpi/ec.h b/src/ec/acpi/ec.h<br>index d9487e9..a899a04 100644<br>--- a/src/ec/acpi/ec.h<br>+++ b/src/ec/acpi/ec.h<br>@@ -40,6 +40,8 @@<br> int send_ec_data(u8 data);<br> int send_ec_data_nowait(u8 data);<br> u8 recv_ec_data(void);<br>+int ec_get_timeout(void);<br>+void ec_clear_out_queue(void);<br> u8 ec_status(void);<br> u8 ec_query(void);<br> u8 ec_read(u8 addr);<br></pre><p>To view, visit <a href="https://review.coreboot.org/22180">change 22180</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/22180"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iee031306c02f5211a4512c6b4ec90f7f0db196ae </div>
<div style="display:none"> Gerrit-Change-Number: 22180 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Bill XIE <persmule@gmail.com> </div>