Skip to contentSkip to conversation

serial: ns16550: Use old baud rate divisor for flushing if not given

PATCH New Patrik Dahlström 2 participants 2 messages Dec 21, 2019 – Jan 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: ns16550: Use old baud rate divisor for flushing if not given

If baud_divisor is not set (i.e. == -1), we should use the baud divisor already in use for flushing the xmit register. If we don't flush the xmit register, then SPL will hang.

---
 drivers/serial/ns16550.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/serial/ns16550.c +7 -0
index 754b6e9921..d9da7f799c 100644
@@ -170,6 +170,13 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 	     == UART_LSR_THRE) {
 		if (baud_divisor != -1)
 			NS16550_setbrg(com_port, baud_divisor);
+		else {
+			// Re-use old baud rate divisor to flush transmit reg.
+			const int dll = serial_in(&com_port->dll);
+			const int dlm = serial_in(&com_port->dlm);
+			const int divisor = dll | (dlm << 8);
+			NS16550_setbrg(com_port, divisor);
+		}
 		serial_out(0, &com_port->mdr1);
 	}
 #endif
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 serial: ns16550: Use old baud rate divisor for flushing if not given

Quoted 5 lines · Patrik Dahlström

If baud_divisor is not set (i.e. == -1), we should use the baud divisor already in use for flushing the xmit register. If we don't flush the xmit register, then SPL will hang.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200125/2d040723/attachment.sig>