summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-12-09 19:11:52 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-12-12 21:03:37 -0800
commitac4c3020de7f77f9f697947dd097f4295be62502 (patch)
tree0ffd4c0fd0cda98e3ef53dc8c63058aeab3e273c /chip
parente2e875c5668e8b499c5b87f659c84e8ebf4588cb (diff)
downloadchrome-ec-ac4c3020de7f77f9f697947dd097f4295be62502.tar.gz
g: tweak cflush() to wait a bit longer
It turns out that even when the UART status register returns TX_IDLE bit set, the transmitter is still active - probably working out the stop sequence. So, resetting immediately after TX_EMPTY is asserted causes the last character to be corrupted on the receiving side. This patch adds a wait for the duration of transmitting 10 bits at 115200 baud, which should be plenty. Wait loop in capped in case timer is not running for any reason. BRANCH=none BUG=chrome-os-partner:60321 TEST=added code to print out a string and then call cflush() and reset immediately. The last character is not lost any more, the exact string is printed. Change-Id: If386c515d9d9cc63d161fba73e6ed4e70e465136 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/418487 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/g/uartn.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/chip/g/uartn.c b/chip/g/uartn.c
index c6c80ced51..2de44ab208 100644
--- a/chip/g/uartn.c
+++ b/chip/g/uartn.c
@@ -68,9 +68,22 @@ int uartn_tx_in_progress(int uart)
void uartn_tx_flush(int uart)
{
+ timestamp_t ts;
+ int i;
+
/* Wait until TX FIFO is idle. */
while (uartn_tx_in_progress(uart))
;
+ /*
+ * Even when uartn_tx_in_progress() returns false, the chip seems to
+ * be still trasmitting, resetting at this point results in an eaten
+ * last symbol. Let's just wait some time (required to transmit 10
+ * bits at 115200 baud).
+ */
+ ts = get_time(); /* Start time. */
+ for (i = 0; i < 1000; i++) /* Limit it in case timer is not running. */
+ if ((get_time().val - ts.val) > ((1000000 * 10) / 115200))
+ return;
}
int uartn_tx_ready(int uart)