public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2] AT91: Small fix on AT91 USART initialization code
@ 2011-08-01 11:30 Hong Xu
  2011-08-01 14:39 ` Reinhard Meyer
  0 siblings, 1 reply; 5+ messages in thread
From: Hong Xu @ 2011-08-01 11:30 UTC (permalink / raw)
  To: u-boot

Before reset dbgu transmitter, we just wait TXEMPTY to drain the
transmitter register. 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>
---
Change since V1:
- Fix comment for easy reading

 drivers/serial/atmel_usart.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index e326b2b..6f9c2de 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -49,17 +49,23 @@ int serial_init(void)
 {
 	atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE;
 
+	/* Just in case: drain transmitter register */
+	while (!(readl(&usart->csr) & USART3_BIT(TXEMPTY)))
+		;
+
 	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;
 }
-- 
1.7.3.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-02 10:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-01 11:30 [U-Boot] [PATCH V2] AT91: Small fix on AT91 USART initialization code Hong Xu
2011-08-01 14:39 ` Reinhard Meyer
2011-08-02  1:51   ` Hong Xu
2011-08-02  9:54     ` Reinhard Meyer
2011-08-02 10:31       ` Hong Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox