[PATCH] ns16550: Respect CONFIG_BAUDRATE < 0 in _debug_uart_init

Joakim Tjernlund joakim.tjernlund at infinera.com
Fri Apr 8 16:29:02 CEST 2022


CONFIG_BAUDRATE less than 0 means do not touch baudrate settings.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund at infinera.com>
---
 drivers/serial/ns16550.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 702109b23b..286d8aecca 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -333,15 +333,19 @@ static inline void _debug_uart_init(void)
 	 * feasible. The better fix is to move all users of this driver to
 	 * driver model.
 	 */
-	baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK,
-					    CONFIG_BAUDRATE);
 	serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER);
 	serial_dout(&com_port->mcr, UART_MCRVAL);
 	serial_dout(&com_port->fcr, UART_FCR_DEFVAL);
 
-	serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL);
-	serial_dout(&com_port->dll, baud_divisor & 0xff);
-	serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff);
+	if (CONFIG_BAUDRATE > 0) {
+		baud_divisor = ns16550_calc_divisor(com_port,
+						    CONFIG_DEBUG_UART_CLOCK,
+						    CONFIG_BAUDRATE);
+
+		serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL);
+		serial_dout(&com_port->dll, baud_divisor & 0xff);
+		serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff);
+	}
 	serial_dout(&com_port->lcr, UART_LCRVAL);
 }
 
-- 
2.34.1



More information about the U-Boot mailing list