From patchwork Fri Dec 21 09:21:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot,1/1] serial/ns16550: check UART mode for TEMT value Date: Thu, 20 Dec 2012 23:21:46 -0000 From: Javier Martinez Canillas X-Patchwork-Id: 207773 Message-Id: <1356081706-31239-1-git-send-email-javier.martinez@collabora.co.uk> To: u-boot@lists.denx.de Cc: Tom Rini , Scott Wood , Javier Martinez Canillas 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 --- 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);