diff mbox

[U-Boot] serial: pl01x: drain PL01x FIFO before baudrate change

Message ID 1317592372-32283-1-git-send-email-linus.walleij@linaro.org
State Accepted
Commit 96baa4c37695b4dac2bde981f59c38e7af19f2eb
Headers show

Commit Message

Linus Walleij Oct. 2, 2011, 9:52 p.m. UTC
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 |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

Comments

Wolfgang Denk Oct. 21, 2011, 10:42 p.m. UTC | #1
Dear Linus Walleij,

In message <1317592372-32283-1-git-send-email-linus.walleij@linaro.org> you wrote:
> 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 |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index 7a064ff..ed581ae 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -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();
 }