public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] serial/ns16550: check UART mode for TEMT value
@ 2012-12-21  9:21 Javier Martinez Canillas
  2012-12-22  2:45 ` Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Javier Martinez Canillas @ 2012-12-21  9:21 UTC (permalink / raw)
  To: u-boot

On ns16550, the Transmitter Empty (TEMT) Bit is used to
indicate when the Transmitter Holding Register (THR) and
the Transmitter Shift Register (TSR) are both empty.

But ns16550 UART has two operation modes (16450 and FIFO)
and the TEMT bit logic value set is different on each mode.

On 16450, the TEMT bit is set to 1 when both THR and TSR are
empty and is set to 0 on FIFO mode.

So, checking the TEMT value without checking the current mode
and assuming a logical value of 1, can lead to U-Boot to hang
forever if the UART is initialized on FIFO mode by default.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/serial/ns16550.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index bbd91ca..d75d814 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -36,7 +36,9 @@
 
 void NS16550_init(NS16550_t com_port, int baud_divisor)
 {
-	while (!(serial_in(&com_port->lsr) & UART_LSR_TEMT))
+	int mode = serial_in(&com_port->fcr) & UART_FCR_FIFO_EN;
+
+	while (!(serial_in(&com_port->lsr) & UART_LSR_TEMT ^ mode))
 		;
 
 	serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread
[parent not found: <CAAwP0s0y=hPh3FrTSLptd_5UnbYGTV47s=6hVkR8aL0-Z_Ejeg@mail.gmail.com>]

end of thread, other threads:[~2013-01-07 11:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-21  9:21 [U-Boot] [PATCH 1/1] serial/ns16550: check UART mode for TEMT value Javier Martinez Canillas
2012-12-22  2:45 ` Scott Wood
2012-12-22  3:40   ` Javier Martinez Canillas
     [not found] <CAAwP0s0y=hPh3FrTSLptd_5UnbYGTV47s=6hVkR8aL0-Z_Ejeg@mail.gmail.com>
2013-01-03  2:58 ` Scott Wood
2013-01-03 21:04   ` Tom Rini
2013-01-07 11:37     ` Javier Martinez Canillas

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