From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Patrik=20Dahlstr=C3=B6m?= Date: Sat, 21 Dec 2019 17:25:12 +0100 Subject: [PATCH] serial: ns16550: Use old baud rate divisor for flushing if not given Message-ID: <20191221162512.15465-1-risca@dalakolonin.se> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de If baud_divisor is not set (i.e. =3D=3D -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. Signed-off-by: Patrik Dahlstr=C3=B6m --- drivers/serial/ns16550.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 754b6e9921..d9da7f799c 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -170,6 +170,13 @@ void NS16550_init(NS16550_t com_port, int baud_divisor) =3D=3D UART_LSR_THRE) { if (baud_divisor !=3D -1) NS16550_setbrg(com_port, baud_divisor); + else { + // Re-use old baud rate divisor to flush transmit reg. + const int dll =3D serial_in(&com_port->dll); + const int dlm =3D serial_in(&com_port->dlm); + const int divisor =3D dll | (dlm << 8); + NS16550_setbrg(com_port, divisor); + } serial_out(0, &com_port->mdr1); } #endif --=20 2.17.1