]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
serial: pl01x: drain PL01x FIFO before baudrate change
authorLinus Walleij <linus.walleij@linaro.org>
Sun, 2 Oct 2011 11:52:52 +0000 (11:52 +0000)
committerWolfgang Denk <wd@denx.de>
Fri, 21 Oct 2011 22:42:04 +0000 (00:42 +0200)
Not draining the FIFO and waiting for the UART to be non-busy
before changing baudrate results in crap characters on the
console, so let's wait for the FIFO to drain and the last
character to be clocked out before we do that.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/serial/serial_pl01x.c

index 7a064ffb24dfa169095e68c209bbbd286290989f..ed581ae22bf11113d2ae080f4aabad3210fe2165 100644 (file)
@@ -194,7 +194,17 @@ int serial_tstc (void)
 
 void serial_setbrg (void)
 {
+       struct pl01x_regs *regs = pl01x_get_regs(CONSOLE_PORT);
+
        baudrate = gd->baudrate;
+       /*
+        * Flush FIFO and wait for non-busy before changing baudrate to avoid
+        * crap in console
+        */
+       while (!(readl(&regs->fr) & UART_PL01x_FR_TXFE))
+               WATCHDOG_RESET();
+       while (readl(&regs->fr) & UART_PL01x_FR_BUSY)
+               WATCHDOG_RESET();
        serial_init();
 }