serial: imx: warn user when using unsupported configuration
Subsystems (2)
PATCH v2 1/1 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. 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).
---
Changes since v1:
- Consistently check for sport->have_rtscts && !(rs485conf->flags & SER_RS485_RTS_ON_SEND)
- Don't break printed message
drivers/tty/serial/imx.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/tty/serial/imx.c +15 -0
@@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port *port, rs485conf->flags &= ~SER_RS485_ENABLED ;if (rs485conf->flags &SER_RS485_ENABLED ) { +/* Enable receiver if low-active RTS signal is requested */ +if (sport->have_rtscts && + !(rs485conf->flags &SER_RS485_RTS_ON_SEND )) + rs485conf->flags |=SER_RS485_RX_DURING_TX ; +/* disable transmitter */ ucr2 =imx_uart_readl (sport,UCR2 );if (rs485conf->flags &SER_RS485_RTS_AFTER_SEND )
@@ -2265,6 +2270,16 @@ static int imx_uart_probe(struct platform_device *pdev) (!sport->have_rtscts && !sport->have_rtsgpio))dev_err (&pdev->dev,"no RTS control, disabling rs485\n" ); +/* +* The RTS (CTS_B) signal cannot be set low during transmission +* in case the receiver is off (limitation of the i.MX UART IP). +*/ +if (sport->port.rs485.flags &SER_RS485_ENABLED && sport->have_rtscts && + (!(sport->port.rs485.flags &SER_RS485_RTS_ON_SEND ) && + !(sport->port.rs485.flags &SER_RS485_RX_DURING_TX ))) +dev_err (&pdev->dev, +"low-active RTS not possible when receiver is off, enabling receiver\n" ); +imx_uart_rs485_config (&sport->port, &sport->port.rs485);/* Disable interrupts before requesting them */
Signature · 1 line
2.17.0
Quoted 34 lines · Stefan Agner
When using half-duplex mode (which disables receiver during txing) the RTS signal cannot be driven low during transmission. 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_SENDis 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_SENDnot 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_SENDandSER_RS485_RX_DURING_TXunset) and configure the closest working configuration (set theSER_RS485_RX_DURING_TXflag).Signed-off-by Stefan Agner <[email protected]>---
Changes since v1:
- Consistently check forsport->have_rtscts&& !(rs485conf->flags &SER_RS485_RTS_ON_SEND)
- Don't break printed messagedrivers/tty/serial/imx.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/tty/serial/imx.c +0
-0
drivers/tty/serial/imx.c static int imx_uart_rs485_config(struct uart_port *port, · line 1840
Quoted 8 lines
drivers/tty/serial/imx.c +5
-0@@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port *port, rs485conf->flags &= ~SER_RS485_ENABLED ;if (rs485conf->flags &SER_RS485_ENABLED ) { +/* Enable receiver if low-active RTS signal is requested */ +if (sport->have_rtscts && + !(rs485conf->flags &SER_RS485_RTS_ON_SEND )) + rs485conf->flags |=SER_RS485_RX_DURING_TX ; +
I wonder what should happen, if the device tree has both
uart-has-rtscts; rts-gpios = <...>;
. I think the right thing would be to check for
sport->have_rtscts && !sport->have_rtsgpio
.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 46 lines · Uwe Kleine-König
Quoted 34 lines · Stefan Agner
When using half-duplex mode (which disables receiver during txing) the RTS signal cannot be driven low during transmission. 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_SENDis 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_SENDnot 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_SENDandSER_RS485_RX_DURING_TXunset) and configure the closest working configuration (set theSER_RS485_RX_DURING_TXflag).Signed-off-by Stefan Agner <[email protected]>---
Changes since v1:
- Consistently check forsport->have_rtscts&& !(rs485conf->flags &SER_RS485_RTS_ON_SEND)
- Don't break printed messagedrivers/tty/serial/imx.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/tty/serial/imx.c +0
-0drivers/tty/serial/imx.c static int imx_uart_rs485_config(struct uart_port *port, · line 1840
Quoted 8 lines
drivers/tty/serial/imx.c +5
-0@@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port *port, rs485conf->flags &= ~SER_RS485_ENABLED ;if (rs485conf->flags &SER_RS485_ENABLED ) { +/* Enable receiver if low-active RTS signal is requested */ +if (sport->have_rtscts && + !(rs485conf->flags &SER_RS485_RTS_ON_SEND )) + rs485conf->flags |=SER_RS485_RX_DURING_TX ; +I wonder what should happen, if the device tree has both
Quoted 2 lines
uart-has-rtscts; rts-gpios = <...>;
Hm, it seems that the code controls both in that case.
Quoted 4 lines
. I think the right thing would be to check for
sport->have_rtscts && !sport->have_rtsgpio
I agree, since it controls both one can use the GPIO to have a working half duplex with low-active RTS configuration.
Will send v3.
--
Stefan