Re: [PATCH] serial: imx: allow CRTSCTS with RTS/CTS GPIOs
From: Frank Li <Frank.li@nxp.com>
Date: 2025-10-16 15:08:17
Also in:
imx, linux-serial, lkml
On Thu, Oct 16, 2025 at 01:37:30PM +0200, Matthias Schiffer wrote:
The CTS GPIO is only evaluated when the CRTSCTS termios flag is enabled;
it should be possible to enable the flag when only GPIO and no hardware-
controlled RTS/CTS are available. UCR2_IRTS is kept enabled in this case,
so the hardware CTS is ignored.
Fixes: 58362d5be352 ("serial: imx: implement handshaking using gpios with the mctrl_gpio helper")
Signed-off-by: Matthias Schiffer <redacted>Reviewed-by: Frank Li <Frank.Li@nxp.com>
quoted hunk ↗ jump to hunk
--- drivers/tty/serial/imx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 500dfc009d03e..4a54a689a0603 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c@@ -1117,8 +1117,8 @@ static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) ucr2 |= UCR2_CTS; /* * UCR2_IRTS is unset if and only if the port is - * configured for CRTSCTS, so we use inverted UCR2_IRTS - * to get the state to restore to. + * configured for hardware-controlled CRTSCTS, so we use + * inverted UCR2_IRTS to get the state to restore to. */ if (!(ucr2 & UCR2_IRTS)) ucr2 |= UCR2_CTSC;@@ -1780,7 +1780,7 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, if ((termios->c_cflag & CSIZE) == CS8) ucr2 |= UCR2_WS; - if (!sport->have_rtscts) + if (!sport->have_rtscts && !sport->have_rtsgpio) termios->c_cflag &= ~CRTSCTS; if (port->rs485.flags & SER_RS485_ENABLED) {@@ -1794,7 +1794,7 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, else imx_uart_rts_inactive(sport, &ucr2); - } else if (termios->c_cflag & CRTSCTS) { + } else if ((termios->c_cflag & CRTSCTS) && sport->have_rtscts) { /* * Only let receiver control RTS output if we were not requested * to have RTS inactive (which then should take precedence).@@ -1803,7 +1803,7 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, ucr2 |= UCR2_CTSC; } - if (termios->c_cflag & CRTSCTS) + if ((termios->c_cflag & CRTSCTS) && sport->have_rtscts) ucr2 &= ~UCR2_IRTS; if (termios->c_cflag & CSTOPB) ucr2 |= UCR2_STPB; --TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/