Fix P0/EVT boards boot without serial cable connection.
authorLeonid Lobachev <leonidl@google.com>
Mon, 16 Jul 2018 19:30:01 +0000 (12:30 -0700)
committerfaqiang.zhu <faqiang.zhu@nxp.com>
Mon, 15 Jul 2019 06:03:42 +0000 (14:03 +0800)
Change-Id: I5969217e400ab494f9a74662d1d228fcf2e2d465

drivers/serial/serial_mxc.c

index 476df25..872a250 100644 (file)
@@ -216,12 +216,27 @@ static void mxc_serial_putc(const char c)
                WATCHDOG_RESET();
 }
 
-/* Test whether a character is in the RX buffer */
+/*
+ * Test whether a character is in the RX buffer
+ */
+static int one_time_rx_line_always_low_workaround_needed = 1;
 static int mxc_serial_tstc(void)
 {
        /* If receive fifo is empty, return false */
        if (readl(&mxc_base->ts) & UTS_RXEMPTY)
                return 0;
+
+       /* Empty RX FIFO if receiver is stuck because of RXD line being low */
+       if (one_time_rx_line_always_low_workaround_needed) {
+               one_time_rx_line_always_low_workaround_needed = 0;
+               if (!(readl(&mxc_base->sr2) & USR2_RDR)) {
+                       while (!(readl(&mxc_base->ts) & UTS_RXEMPTY)) {
+                               (void) readl(&mxc_base->rxd);
+                       }
+                       return 0;
+               }
+       }
+
        return 1;
 }