]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uart] Wait for 16550 UART to become idle before modifying LCR
authorMichael Brown <mcb30@ipxe.org>
Mon, 23 Jun 2025 21:37:32 +0000 (22:37 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 23 Jun 2025 21:56:09 +0000 (22:56 +0100)
Some implementations of 16550-compatible UARTs (e.g. the DesignWare
UART) are known to ignore writes to the line control register while
the transmitter is active.

Wait for the transmitter to become empty before attempting to write to
the line control register.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/uart/ns16550.c

index cf8c744c6859c43fdad2f34f0898b7c025bb2c81..5455c68fb9cc8fcc91b563217e179c21fe85494e 100644 (file)
@@ -131,6 +131,9 @@ static int ns16550_init ( struct uart *uart, unsigned int baud ) {
        if ( ns16550_read ( ns16550, NS16550_SCR ) != 0xae )
                return -ENODEV;
 
+       /* Wait for UART to become idle before modifying LCR */
+       ns16550_flush ( uart );
+
        /* Configure divisor and line control register, if applicable */
        ns16550_write ( ns16550, NS16550_LCR,
                        ( NS16550_LCR_8N1 | NS16550_LCR_DLAB ) );