diff options
author | Stefan Agner <stefan@agner.ch> | 2018-04-19 11:39:16 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-23 03:53:36 -0400 |
commit | 6d215f83e5fccb3dd023e97fef1bd0029bfedde9 (patch) | |
tree | 601f424331f62f7ebad83ac850477845a055e781 /drivers | |
parent | 46c6975a1fd9794ed979565235d24b2f5004e014 (diff) |
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 <stefan@agner.ch>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/tty/serial/imx.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 91f3a1a5cb7f..65d7a2bfb6d2 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
@@ -1833,6 +1833,11 @@ static int imx_uart_rs485_config(struct uart_port *port, | |||
1833 | rs485conf->flags &= ~SER_RS485_ENABLED; | 1833 | rs485conf->flags &= ~SER_RS485_ENABLED; |
1834 | 1834 | ||
1835 | if (rs485conf->flags & SER_RS485_ENABLED) { | 1835 | 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 | |||
1836 | /* disable transmitter */ | 1841 | /* disable transmitter */ |
1837 | ucr2 = imx_uart_readl(sport, UCR2); | 1842 | ucr2 = imx_uart_readl(sport, UCR2); |
1838 | if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) | 1843 | if (rs485conf->flags & SER_RS485_RTS_AFTER_SEND) |
@@ -2265,6 +2270,18 @@ static int imx_uart_probe(struct platform_device *pdev) | |||
2265 | (!sport->have_rtscts && !sport->have_rtsgpio)) | 2270 | (!sport->have_rtscts && !sport->have_rtsgpio)) |
2266 | dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); | 2271 | dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); |
2267 | 2272 | ||
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 | |||
2268 | imx_uart_rs485_config(&sport->port, &sport->port.rs485); | 2285 | imx_uart_rs485_config(&sport->port, &sport->port.rs485); |
2269 | 2286 | ||
2270 | /* Disable interrupts before requesting them */ | 2287 | /* Disable interrupts before requesting them */ |