linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] tty: serial: imx: Fix broken RS485
@ 2024-02-20  6:12 Rickard Andersson
  2024-02-20  6:53 ` Marek Vasut
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Rickard Andersson @ 2024-02-20  6:12 UTC (permalink / raw)
  To: linux-serial, rickard314.andersson, gregkh, shawnguo, s.hauer,
	kernel, festevam, linux-imx, martin.fuzzey, marex
  Cc: rickaran, kernel

From: Rickard x Andersson <rickaran@axis.com>

When about to transmit the function imx_uart_start_tx is called and in
some RS485 configurations this function will call imx_uart_stop_rx. The
problem is that imx_uart_stop_rx will enable loopback and when loopback
is enabled transmitted data will just be looped to RX.

This patch fixes the above problem by explicitly disabling loopback in
the case described above.

Fixes: 79d0224f6bf2 ("tty: serial: imx: Handle RS485 DE signal active high")
Signed-off-by: Rickard x Andersson <rickaran@axis.com>
---
 drivers/tty/serial/imx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 4aa72d5aeafb..899e331bdfc8 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -683,8 +683,15 @@ static void imx_uart_start_tx(struct uart_port *port)
 			imx_uart_writel(sport, ucr2, UCR2);
 
 			if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) &&
-			    !port->rs485_rx_during_tx_gpio)
+			    !port->rs485_rx_during_tx_gpio) {
 				imx_uart_stop_rx(port);
+				/*
+				 * The function imx_uart_stop_rx right above
+				 * will enable loopback, but since we are just
+				 * about to transmit then disable loopback.
+				 */
+				imx_uart_disable_loopback_rs485(sport);
+			}
 
 			sport->tx_state = WAIT_AFTER_RTS;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-07 14:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20  6:12 [PATCH v2] tty: serial: imx: Fix broken RS485 Rickard Andersson
2024-02-20  6:53 ` Marek Vasut
2024-02-20  6:53 ` Greg KH
2024-02-20  6:53 ` Greg KH
2024-02-20  9:55 ` [RFC][PATCH] serial: imx: Fix RS485 behaviour on disabled RX_DURING_TX Christoph Niedermaier
2024-02-20 10:57   ` Christoph Niedermaier
2024-03-07 11:07     ` Tobias Jakobi (Compleo)
2024-03-07 12:38       ` Christoph Niedermaier
2024-03-07 14:10         ` Tobias Jakobi (Compleo)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).