]> git.sur5r.net Git - u-boot/commitdiff
AT91: Small fix on AT91 USART initialization code
authorXu, Hong <Hong.Xu@atmel.com>
Tue, 2 Aug 2011 01:05:04 +0000 (01:05 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sat, 1 Sep 2012 15:06:13 +0000 (17:06 +0200)
Before reset dbgu transmitter, we just wait TXEMPTY to drain the
transmitter register(Just in case). If not doing this, we may sometimes
see several weird characters from DBGU.

A short delay is also added to make sure the new serial settings are
settled.

Signed-off-by: Hong Xu <hong.xu@atmel.com>
[cherry-picked from u-boot-atmel/old-next]
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
drivers/serial/atmel_usart.c

index e326b2bcff9867985d94720b4fbc2a8033568d88..943ef70fa601f7d4d8093183c9d1a6220a32c0dc 100644 (file)
@@ -49,17 +49,26 @@ int serial_init(void)
 {
        atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE;
 
+       /*
+        * Just in case: drain transmitter register
+        * 1000us is enough for baudrate >= 9600
+        */
+       if (!(readl(&usart->csr) & USART3_BIT(TXEMPTY)))
+               __udelay(1000);
+
        writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), &usart->cr);
 
        serial_setbrg();
 
-       writel(USART3_BIT(RXEN) | USART3_BIT(TXEN), &usart->cr);
        writel((USART3_BF(USART_MODE, USART3_USART_MODE_NORMAL)
                           | USART3_BF(USCLKS, USART3_USCLKS_MCK)
                           | USART3_BF(CHRL, USART3_CHRL_8)
                           | USART3_BF(PAR, USART3_PAR_NONE)
                           | USART3_BF(NBSTOP, USART3_NBSTOP_1)),
                           &usart->mr);
+       writel(USART3_BIT(RXEN) | USART3_BIT(TXEN), &usart->cr);
+       /* 100us is enough for the new settings to be settled */
+       __udelay(100);
 
        return 0;
 }