serial: 8250_port: reset LSR DLAB before set MCR

When setting the 16550 serial port baud rate, you need
to configure the UART to loopback mode. After setting
the DLL and DLH, you need to reset the LSR first,
and then configure the MCR to make the UART return
to the normal mode. If you do not reset the LSR
first, an error will occur when the UART RX is still
receiving data.

Signed-off-by: Steven Liu <steven.liu@rock-chips.com>
Change-Id: Ia940b278554ef1d4e7a6c4550fe4a4600407a57e
This commit is contained in:
Steven Liu
2021-07-02 10:17:21 +08:00
parent eccf16e835
commit e4b2ee8a88

View File

@@ -2681,6 +2681,8 @@ void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB);
serial_dl_write(up, quot);
if (port->type != PORT_16750)
serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */
#ifdef CONFIG_ARCH_ROCKCHIP
serial_port_out(port, UART_MCR, up->mcr);
@@ -2852,10 +2854,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
* LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR
* is written without DLAB set, this mode will be disabled.
*/
if (port->type == PORT_16750)
if (port->type == PORT_16750) {
serial_port_out(port, UART_FCR, up->fcr);
serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */
}
serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */
if (port->type != PORT_16750) {
/* emulated UARTs (Lucent Venus 167x) need two steps */
if (up->fcr & UART_FCR_ENABLE_FIFO)