summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSherry Sun <sherry.sun@nxp.com>2025-03-07 14:54:46 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-10 14:42:02 +0200
commit57ca19091edc88df5352fe8effee40a2485cde42 (patch)
tree6ebdc98417f2e52a724042fd5880c6085da95379
parentb35de0a52c0f5bbd8bfa7a9b4e03f5bbc18b9080 (diff)
tty: serial: lpuart: only disable CTS instead of overwriting the whole UARTMODIR register
[ Upstream commit e98ab45ec5182605d2e00114cba3bbf46b0ea27f ] No need to overwrite the whole UARTMODIR register before waiting the transmit engine complete, actually our target here is only to disable CTS flow control to avoid the dirty data in TX FIFO may block the transmit engine complete. Also delete the following duplicate CTS disable configuration. Fixes: d5a2e0834364 ("tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete") Cc: stable <stable@kernel.org> Signed-off-by: Sherry Sun <sherry.sun@nxp.com> Link: https://lore.kernel.org/r/20250307065446.1122482-1-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/tty/serial/fsl_lpuart.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 2971de64f6a3..ca5beb083115 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -2342,14 +2342,18 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
uart_update_timeout(port, termios->c_cflag, baud);
/*
+ * disable CTS to ensure the transmit engine is not blocked by the flow
+ * control when there is dirty data in TX FIFO
+ */
+ lpuart32_write(port, modem & ~UARTMODIR_TXCTSE, UARTMODIR);
+
+ /*
* LPUART Transmission Complete Flag may never be set while queuing a break
* character, so skip waiting for transmission complete when UARTCTRL_SBK is
* asserted.
*/
- if (!(old_ctrl & UARTCTRL_SBK)) {
- lpuart32_write(port, 0, UARTMODIR);
+ if (!(old_ctrl & UARTCTRL_SBK))
lpuart32_wait_bit_set(port, UARTSTAT, UARTSTAT_TC);
- }
/* disable transmit and receive */
lpuart32_write(port, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE),
@@ -2357,8 +2361,6 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
lpuart32_write(port, bd, UARTBAUD);
lpuart32_serial_setbrg(sport, baud);
- /* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */
- lpuart32_write(port, modem & ~UARTMODIR_TXCTSE, UARTMODIR);
/* restore control register */
lpuart32_write(port, ctrl, UARTCTRL);
/* re-enable the CTS if needed */