summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-08-30 18:01:58 -0700
committerCommit Bot <commit-bot@chromium.org>2019-09-03 23:46:35 +0000
commit6881fa3712de15d4b938dcb330bae7744a6db4bf (patch)
tree6433bec3232074709b6f26c653c644e46747c16c
parentd5927cd01e761177d7dde9db072e48c11c1c3ed8 (diff)
downloadchrome-ec-6881fa3712de15d4b938dcb330bae7744a6db4bf.tar.gz
g: fix UART TX done logic
TX is done when both TX_IDLE and TX_EMPTY conditions are true. Fixing the check makes unnecessary the code which waited for another character time before proceeding when flushing the UART TX FIFO. BRANCH=cr50, cr50-mp BUG=b:140305442 TEST=added code to print a really long string before reset in the 'reboot' command, observed that the entire string is reliably printed before the reset. Change-Id: I0882d96ba9ca5412deb704ccdbc43e8cebeeeab5 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1779587 Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
-rw-r--r--chip/g/uartn.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/chip/g/uartn.c b/chip/g/uartn.c
index ce90b7b290..3f4b75b7e0 100644
--- a/chip/g/uartn.c
+++ b/chip/g/uartn.c
@@ -62,28 +62,16 @@ void uartn_tx_stop(int uart)
int uartn_tx_in_progress(int uart)
{
/* Transmit is in progress unless the TX FIFO is empty and idle. */
- return !(GR_UART_STATE(uart) & (GC_UART_STATE_TXIDLE_MASK |
- GC_UART_STATE_TXEMPTY_MASK));
+ return (GR_UART_STATE(uart) & (GC_UART_STATE_TXIDLE_MASK |
+ GC_UART_STATE_TXEMPTY_MASK)) !=
+ (GC_UART_STATE_TXIDLE_MASK | GC_UART_STATE_TXEMPTY_MASK);
}
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)