Patchwork [U-Boot,1/2] serial/ns16550: add an option to avoid hanging on broken platforms

login
register
mail settings
Submitter Javier Martinez Canillas
Date Jan. 7, 2013, 11:35 a.m.
Message ID <1357558521-19365-1-git-send-email-javier.martinez@collabora.co.uk>
Download mbox | patch
Permalink /patch/209900/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Javier Martinez Canillas - Jan. 7, 2013, 11:35 a.m.
Some platforms (e.g. IGEPv2 board) has a broken ns16550 UART that
does not set the TEMT bit when the transmitter is empty in SPL.
This makes U-Boot to hang while waiting for TEMT to be set.

Add a new option to avoid this:

CONFIG_SYS_NS16550_BROKEN_TEMT

16550 UART set the Transmitter Empty (TEMT) Bit when all output
has finished and the transmitter is totally empty. U-Boot waits
for this bit to be set to initialize the serial console. On some
broken platforms this bit is not set in SPL making U-Boot to
hang while waiting for TEMT. Define this option to avoid it.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 README                   |    8 ++++++++
 drivers/serial/ns16550.c |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
Tom Rini - Jan. 11, 2013, 2:42 p.m.
On Mon, Jan 07, 2013 at 01:35:20AM -0000, Javier Martinez Canillas wrote:

> Some platforms (e.g. IGEPv2 board) has a broken ns16550 UART that
> does not set the TEMT bit when the transmitter is empty in SPL.
> This makes U-Boot to hang while waiting for TEMT to be set.
> 
> Add a new option to avoid this:
> 
> CONFIG_SYS_NS16550_BROKEN_TEMT
> 
> 16550 UART set the Transmitter Empty (TEMT) Bit when all output
> has finished and the transmitter is totally empty. U-Boot waits
> for this bit to be set to initialize the serial console. On some
> broken platforms this bit is not set in SPL making U-Boot to
> hang while waiting for TEMT. Define this option to avoid it.
> 
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>

Applied to u-boot-ti/master, thanks!

Patch

diff --git a/README b/README
index 78f40df..a89861e 100644
--- a/README
+++ b/README
@@ -616,6 +616,14 @@  The following options need to be configured:
 		boot loader that has already initialized the UART.  Define this
 		variable to flush the UART at init time.
 
+		CONFIG_SYS_NS16550_BROKEN_TEMT
+
+		16550 UART set the Transmitter Empty (TEMT) Bit when all output
+		has finished and the transmitter is totally empty. U-Boot waits
+		for this bit to be set to initialize the serial console. On some
+		broken platforms this bit is not set in SPL making U-Boot to
+		hang while waiting for TEMT. Define this option to avoid it.
+
 
 - Console Interface:
 		Depending on board, define exactly one serial port
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index bbd91ca..87a0917 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -36,8 +36,10 @@ 
 
 void NS16550_init(NS16550_t com_port, int baud_divisor)
 {
+#if (!defined(CONFIG_SYS_NS16550_BROKEN_TEMT))
 	while (!(serial_in(&com_port->lsr) & UART_LSR_TEMT))
 		;
+#endif
 
 	serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
 #if (defined(CONFIG_OMAP) && !defined(CONFIG_OMAP3_ZOOM2)) || \