Skip to content

Commit 6d215f8

Browse files
agnersgregkh
authored andcommitted
serial: imx: warn user when using unsupported configuration
When using half-duplex mode (which disables receiver during txing) the RTS signal cannot be driven low during transmission when using i.MX UART RTS/CTS control. This seems to be a limitation of the i.MX UART IP: The RTS (CTS_B) signal is controlled by the receiver. When the receiver is disabled, the signal stays in UART logic idle state which is high... If SER_RS485_RTS_ON_SEND is used, RTS needs to be high active during transmission. Since this is the default state of the RTS (CTS_B) signal when the receiver is off, half-duplex mode in this configuration works fine. However, a low-active RTS signal (flag SER_RS485_RTS_ON_SEND not set) cannot be generated when the receiver is turned off. Print an error if the user selects this unsupported configuration (both SER_RS485_RTS_ON_SEND and SER_RS485_RX_DURING_TX unset) and configure the closest working configuration (set the SER_RS485_RX_DURING_TX flag). Signed-off-by: Stefan Agner <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 46c6975 commit 6d215f8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/tty/serial/imx.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port *port,
18331833
rs485conf->flags &= ~SER_RS485_ENABLED;
18341834

18351835
if (rs485conf->flags & SER_RS485_ENABLED) {
1836+
/* Enable receiver if low-active RTS signal is requested */
1837+
if (sport->have_rtscts && !sport->have_rtsgpio &&
1838+
!(rs485conf->flags & SER_RS485_RTS_ON_SEND))
1839+
rs485conf->flags |= SER_RS485_RX_DURING_TX;
1840+
18361841
/* disable transmitter */
18371842
ucr2 = imx_uart_readl(sport, UCR2);
18381843
if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND)
@@ -2265,6 +2270,18 @@ static int imx_uart_probe(struct platform_device *pdev)
22652270
(!sport->have_rtscts && !sport->have_rtsgpio))
22662271
dev_err(&pdev->dev, "no RTS control, disabling rs485\n");
22672272

2273+
/*
2274+
* If using the i.MX UART RTS/CTS control then the RTS (CTS_B)
2275+
* signal cannot be set low during transmission in case the
2276+
* receiver is off (limitation of the i.MX UART IP).
2277+
*/
2278+
if (sport->port.rs485.flags & SER_RS485_ENABLED &&
2279+
sport->have_rtscts && !sport->have_rtsgpio &&
2280+
(!(sport->port.rs485.flags & SER_RS485_RTS_ON_SEND) &&
2281+
!(sport->port.rs485.flags & SER_RS485_RX_DURING_TX)))
2282+
dev_err(&pdev->dev,
2283+
"low-active RTS not possible when receiver is off, enabling receiver\n");
2284+
22682285
imx_uart_rs485_config(&sport->port, &sport->port.rs485);
22692286

22702287
/* Disable interrupts before requesting them */

0 commit comments

Comments
 (0)