[PATCH] tty: serial: imx: Enable UART before toggling CTS on probe

Marek Vasut marex at denx.de
Mon Feb 7 07:26:42 PST 2022


In case the UART and RX is not enabled, the CTS control is inoperable.
This is noticable with SER_RS485_RTS_ON_SEND, which should pull the CTS
line low when probing the driver, however it does nothing instead. With
this patch, the CTS line is correctly pulled low.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Richard Zhu <hongxing.zhu at nxp.com>
Cc: Shawn Guo <shawnguo at kernel.org>
Cc: linux-imx at nxp.com
---
 drivers/tty/serial/imx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index d8034f1666861..958e8ed98b6d9 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1901,7 +1901,7 @@ static int imx_uart_rs485_config(struct uart_port *port,
 				 struct serial_rs485 *rs485conf)
 {
 	struct imx_port *sport = (struct imx_port *)port;
-	u32 ucr2;
+	u32 ucr1, ucr2;
 
 	/* RTS is required to control the transmitter */
 	if (!sport->have_rtscts && !sport->have_rtsgpio)
@@ -1913,6 +1913,14 @@ static int imx_uart_rs485_config(struct uart_port *port,
 		    !(rs485conf->flags & SER_RS485_RTS_ON_SEND))
 			rs485conf->flags |= SER_RS485_RX_DURING_TX;
 
+		ucr1 = imx_uart_readl(sport, UCR1);
+		ucr1 |= UCR1_UARTEN;
+		imx_uart_writel(sport, ucr1, UCR1);
+
+		ucr2 = imx_uart_readl(sport, UCR2);
+		ucr2 |= UCR2_RXEN;
+		imx_uart_writel(sport, ucr2, UCR2);
+
 		/* disable transmitter */
 		ucr2 = imx_uart_readl(sport, UCR2);
 		if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND)
-- 
2.34.1




More information about the linux-arm-kernel mailing list