diff options
-rw-r--r-- | drivers/serial/ns16550.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index f9041aa626..04b604fa2c 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c | |||
@@ -267,12 +267,26 @@ static inline void _debug_uart_init(void) | |||
267 | serial_dout(&com_port->lcr, UART_LCRVAL); | 267 | serial_dout(&com_port->lcr, UART_LCRVAL); |
268 | } | 268 | } |
269 | 269 | ||
270 | static inline int NS16550_read_baud_divisor(struct NS16550 *com_port) | ||
271 | { | ||
272 | int ret; | ||
273 | |||
274 | serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL); | ||
275 | ret = serial_din(&com_port->dll) & 0xff; | ||
276 | ret |= (serial_din(&com_port->dlm) & 0xff) << 8; | ||
277 | serial_dout(&com_port->lcr, UART_LCRVAL); | ||
278 | |||
279 | return ret; | ||
280 | } | ||
281 | |||
270 | static inline void _debug_uart_putc(int ch) | 282 | static inline void _debug_uart_putc(int ch) |
271 | { | 283 | { |
272 | struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; | 284 | struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; |
273 | 285 | ||
274 | while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) | 286 | while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) { |
275 | ; | 287 | if (!NS16550_read_baud_divisor(com_port)) |
288 | return; | ||
289 | } | ||
276 | serial_dout(&com_port->thr, ch); | 290 | serial_dout(&com_port->thr, ch); |
277 | } | 291 | } |
278 | 292 | ||