summaryrefslogtreecommitdiff
path: root/chip/lm4/uart.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-07-09 14:01:58 +0800
committerGerrit <chrome-bot@google.com>2012-07-09 19:50:22 -0700
commit42d027099008ba511260a4b96b8d045847baa173 (patch)
treee4d9f0636351d9f1d4723c45d51e966794b9210f /chip/lm4/uart.c
parent80d92fd6dd0247c5473e139dcdc8b097642b64cd (diff)
downloadchrome-ec-42d027099008ba511260a4b96b8d045847baa173.tar.gz
Clear UART FIFO when initializing to prevent reading garbage
When debug port is left unconnected, EC get garbage keypress input from both UART ports due to UART pin floating. By clearing UART receive FIFO when initializing UART module, this can be prevented. BUG=chrome-os-partner:10235 TEST=Reset EC with debug port unconnected. Check u-boot doesn't get any keypress. Change-Id: I3e84db1f2f95a0173c11180f6afb3edb705d0ae5 Reviewed-on: https://gerrit.chromium.org/gerrit/26908 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Rong Chang <rongchang@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'chip/lm4/uart.c')
-rw-r--r--chip/lm4/uart.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c
index 5e59d5a502..3595721441 100644
--- a/chip/lm4/uart.c
+++ b/chip/lm4/uart.c
@@ -77,6 +77,13 @@ int uart_read_char(void)
return LM4_UART_DR(0);
}
+static void uart_clear_rx_fifo(int channel)
+{
+ int scratch __attribute__ ((unused));
+ while (!(LM4_UART_FR(channel) & 0x10))
+ scratch = LM4_UART_DR(channel);
+}
+
void uart_disable_interrupt(void)
{
task_disable_irq(LM4_IRQ_UART0);
@@ -185,6 +192,7 @@ int uart_init(void)
/* Enable interrupts for UART0 only. UART1 will have to wait until the
* LPC bus is initialized.
*/
+ uart_clear_rx_fifo(0);
task_enable_irq(LM4_IRQ_UART0);
init_done = 1;
@@ -207,6 +215,7 @@ static void uart_comx_putc_wait(int c)
void uart_comx_enable(void)
{
+ uart_clear_rx_fifo(1);
task_enable_irq(LM4_IRQ_UART1);
}