Patchwork [U-Boot,1/1,v5] omap3_beagle: Flush UART3 xmit on enable if TEMT is broken

login
register
mail settings
Submitter man.huber@arcor.de
Date March 29, 2013, 12:52 p.m.
Message ID <51558E94.2010306@arcor.de>
Download mbox | patch
Permalink /patch/232394/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

man.huber@arcor.de - March 29, 2013, 12:52 p.m.
From: Manfred Huber <man.huber@arcor.de>

Flush UART3 xmit on enable if TEMT is broken

On some OMAP3 devices when UART3 is configured for boot mode before SPL starts 
only THRE bit is set. We have to empty the transmitter before initialization 
starts. This patch avoids the use of CONFIG_SYS_NS16550_BROKEN_TEMT.

Signed-off-by: Manfred Huber <man.huber@arcor.de>
---
Changes since v4:
	- Changed multiline comment.

Changes since v3:
	- Changed commit summary and added version history.

Changes since v2:
	- Removing CONFIG_SYS_NS16550_BROKEN_TEMT in README and igep00x0.h.

Changes since v1:
	- Replaced CONFIG_SYS_NS16550_BROKEN_TEMT with initial configuration of
	  UART.

 README                     |    8 --------
 drivers/serial/ns16550.c   |   18 ++++++++++++++++--
 include/configs/igep00x0.h |    3 ---
 3 files changed, 16 insertions(+), 13 deletions(-)
Javier Martinez Canillas - April 2, 2013, 7:46 a.m.
On Fri, Mar 29, 2013 at 1:52 PM, Manfred Huber <man.huber@arcor.de> wrote:
> From: Manfred Huber <man.huber@arcor.de>
>
> Flush UART3 xmit on enable if TEMT is broken
>
> On some OMAP3 devices when UART3 is configured for boot mode before SPL starts
> only THRE bit is set. We have to empty the transmitter before initialization
> starts. This patch avoids the use of CONFIG_SYS_NS16550_BROKEN_TEMT.
>
> Signed-off-by: Manfred Huber <man.huber@arcor.de>
> ---
> Changes since v4:
>         - Changed multiline comment.
>
> Changes since v3:
>         - Changed commit summary and added version history.
>
> Changes since v2:
>         - Removing CONFIG_SYS_NS16550_BROKEN_TEMT in README and igep00x0.h.
>
> Changes since v1:
>         - Replaced CONFIG_SYS_NS16550_BROKEN_TEMT with initial configuration of
>           UART.
>
>  README                     |    8 --------
>  drivers/serial/ns16550.c   |   18 ++++++++++++++++--
>  include/configs/igep00x0.h |    3 ---
>  3 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/README b/README
> index a336476..e6b3a50 100644
> --- a/README
> +++ b/README
> @@ -616,14 +616,6 @@ 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 87a0917..a9352fb 100644
> --- a/drivers/serial/ns16550.c
> +++ b/drivers/serial/ns16550.c
> @@ -36,10 +36,24 @@
>
>  void NS16550_init(NS16550_t com_port, int baud_divisor)
>  {
> -#if (!defined(CONFIG_SYS_NS16550_BROKEN_TEMT))
> +#if (defined(CONFIG_SPL_BUILD) && defined(CONFIG_OMAP34XX))
> +       /*
> +        * On some OMAP3 devices when UART3 is configured for boot mode before
> +        * SPL starts only THRE bit is set. We have to empty the transmitter
> +        * before initialization starts.
> +        */
> +       if ((serial_in(&com_port->lsr) & (UART_LSR_TEMT | UART_LSR_THRE))
> +            == UART_LSR_THRE) {
> +               serial_out(UART_LCR_DLAB, &com_port->lcr);
> +               serial_out(baud_divisor & 0xff, &com_port->dll);
> +               serial_out((baud_divisor >> 8) & 0xff, &com_port->dlm);
> +               serial_out(UART_LCRVAL, &com_port->lcr);
> +               serial_out(0, &com_port->mdr1);
> +       }
> +#endif
> +
>         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)) || \
> diff --git a/include/configs/igep00x0.h b/include/configs/igep00x0.h
> index f8131b1..0617a58 100644
> --- a/include/configs/igep00x0.h
> +++ b/include/configs/igep00x0.h
> @@ -67,9 +67,6 @@
>  #define CONFIG_SYS_NS16550_REG_SIZE    (-4)
>  #define CONFIG_SYS_NS16550_CLK         V_NS16550_CLK
>
> -/* define to avoid U-Boot to hang while waiting for TEMT */
> -#define CONFIG_SYS_NS16550_BROKEN_TEMT
> -
>  /* select serial console configuration */
>  #define CONFIG_CONS_INDEX              3
>  #define CONFIG_SYS_NS16550_COM3                OMAP34XX_UART3

Hi Manfred,

I tested your patch on my IGEPv2 and is booting correctly, so:

Tested-by: Javier Martinez Canillas <javier@dowhile0.org>

Thanks a lot for working on this!

Best regards,
Javier
Andreas Bießmann - April 2, 2013, 8:59 a.m.
Dear Manfred Huber,

On 03/29/2013 01:52 PM, Manfred Huber wrote:
> From: Manfred Huber <man.huber@arcor.de>
> 
> Flush UART3 xmit on enable if TEMT is broken
> 
> On some OMAP3 devices when UART3 is configured for boot mode before SPL starts 
> only THRE bit is set. We have to empty the transmitter before initialization 
> starts. This patch avoids the use of CONFIG_SYS_NS16550_BROKEN_TEMT.
> 
> Signed-off-by: Manfred Huber <man.huber@arcor.de>

Tested-by: Andreas Bießmann <andreas.devel@googlemail.com>

on tricorder board.
Tom Rini - April 8, 2013, 4:56 p.m.
On Fri, Mar 29, 2013 at 02:52:36AM -0000, man.huber@arcor.de wrote:

> From: Manfred Huber <man.huber@arcor.de>
> 
> Flush UART3 xmit on enable if TEMT is broken
> 
> On some OMAP3 devices when UART3 is configured for boot mode before SPL starts 
> only THRE bit is set. We have to empty the transmitter before initialization 
> starts. This patch avoids the use of CONFIG_SYS_NS16550_BROKEN_TEMT.
> 
> Signed-off-by: Manfred Huber <man.huber@arcor.de>
> Tested-by: Javier Martinez Canillas <javier@dowhile0.org>
> Tested-by: Andreas Bie??mann <andreas.devel@googlemail.com>

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

Patch

diff --git a/README b/README
index a336476..e6b3a50 100644
--- a/README
+++ b/README
@@ -616,14 +616,6 @@  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 87a0917..a9352fb 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -36,10 +36,24 @@ 
 
 void NS16550_init(NS16550_t com_port, int baud_divisor)
 {
-#if (!defined(CONFIG_SYS_NS16550_BROKEN_TEMT))
+#if (defined(CONFIG_SPL_BUILD) && defined(CONFIG_OMAP34XX))
+	/*
+	 * On some OMAP3 devices when UART3 is configured for boot mode before
+	 * SPL starts only THRE bit is set. We have to empty the transmitter
+	 * before initialization starts.
+	 */
+	if ((serial_in(&com_port->lsr) & (UART_LSR_TEMT | UART_LSR_THRE))
+	     == UART_LSR_THRE) {
+		serial_out(UART_LCR_DLAB, &com_port->lcr);
+		serial_out(baud_divisor & 0xff, &com_port->dll);
+		serial_out((baud_divisor >> 8) & 0xff, &com_port->dlm);
+		serial_out(UART_LCRVAL, &com_port->lcr);
+		serial_out(0, &com_port->mdr1);
+	}
+#endif
+
 	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)) || \
diff --git a/include/configs/igep00x0.h b/include/configs/igep00x0.h
index f8131b1..0617a58 100644
--- a/include/configs/igep00x0.h
+++ b/include/configs/igep00x0.h
@@ -67,9 +67,6 @@ 
 #define CONFIG_SYS_NS16550_REG_SIZE	(-4)
 #define CONFIG_SYS_NS16550_CLK		V_NS16550_CLK
 
-/* define to avoid U-Boot to hang while waiting for TEMT */
-#define CONFIG_SYS_NS16550_BROKEN_TEMT
-
 /* select serial console configuration */
 #define CONFIG_CONS_INDEX		3
 #define CONFIG_SYS_NS16550_COM3		OMAP34XX_UART3