diff options
author | Pali Rohár <pali@kernel.org> | 2022-06-23 14:13:56 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-07-08 12:20:04 -0400 |
commit | 5e998b4de33fed22da29e3a12e2856f9c00eaebc (patch) | |
tree | 3f76eaf62451545457bb1d23b19d2184494426ae /drivers/serial/ns16550.c | |
parent | e3812b5b083e39f3dd11009579cc7d44008adaf5 (diff) | |
download | u-boot-5e998b4de33fed22da29e3a12e2856f9c00eaebc.zip u-boot-5e998b4de33fed22da29e3a12e2856f9c00eaebc.tar.gz u-boot-5e998b4de33fed22da29e3a12e2856f9c00eaebc.tar.bz2 |
serial: ns16550: Wait in debug_uart_init until tx buffer is empty
Commit d293759d55cc ("serial: ns16550: Add support for
SPL_DEBUG_UART_BASE") fixed support for setting correct early debug UART
base address in SPL.
But after this commit, output from Marvell A385 BootROM is truncated or
lost and not fully present on serial console.
Debugging this issue showed that BootROM just put bytes into UART HW output
buffer and does not wait until UART HW transmit all characters. U-Boot
ns16550 early debug is initialized very early and during its initialization
is resetting UART HW and flushing remaining transmit buffer (which still
contains BootROM output).
Fix this issue by waiting in init function prior resetting UART HW until
TxEmpty bit in UART Line Status Register is set. TxEmpty is set when all
remaining bytes from HW buffer are transmitted.
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
[trini: Add comment, move ';' to new line per checkpatch.pl]
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'drivers/serial/ns16550.c')
-rw-r--r-- | drivers/serial/ns16550.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 78bfe62..47bad6f 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -328,6 +328,10 @@ static inline void _debug_uart_init(void) struct ns16550 *com_port = (struct ns16550 *)CONFIG_VAL(DEBUG_UART_BASE); int baud_divisor; + /* Wait until tx buffer is empty */ + while (!(serial_din(&com_port->lsr) & UART_LSR_TEMT)) + ; + /* * We copy the code from above because it is already horribly messy. * Trying to refactor to nicely remove the duplication doesn't seem |