Skip to content

Commit 9c3e2ad

Browse files
passgatgregkh
authored andcommitted
serial: omap: don't disable rs485 if rts gpio is missing
[ Upstream commit 45f6b6d ] There are rs485 transceivers (e.g. MAX13487E/MAX13488E) which automatically disable or enable the driver and receiver to keep the bus in the correct state. In these cases we don't need a GPIO for flow control. Fixes: 4a0ac0f ("OMAP: add RS485 support") Signed-off-by: Dario Binacchi <dariobin@libero.it> Link: https://lore.kernel.org/r/20210415210945.25863-1-dariobin@libero.it Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 927162c commit 9c3e2ad

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎drivers/tty/serial/omap-serial.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ static void serial_omap_stop_tx(struct uart_port *port)
302302
serial_out(up, UART_OMAP_SCR, up->scr);
303303
res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ?
304304
1 : 0;
305-
if (gpiod_get_value(up->rts_gpiod) != res) {
305+
if (up->rts_gpiod &&
306+
gpiod_get_value(up->rts_gpiod) != res) {
306307
if (port->rs485.delay_rts_after_send > 0)
307308
mdelay(
308309
port->rs485.delay_rts_after_send);
@@ -411,7 +412,7 @@ static void serial_omap_start_tx(struct uart_port *port)
411412

412413
/* if rts not already enabled */
413414
res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0;
414-
if (gpiod_get_value(up->rts_gpiod) != res) {
415+
if (up->rts_gpiod && gpiod_get_value(up->rts_gpiod) != res) {
415416
gpiod_set_value(up->rts_gpiod, res);
416417
if (port->rs485.delay_rts_before_send > 0)
417418
mdelay(port->rs485.delay_rts_before_send);
@@ -1407,18 +1408,13 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
14071408
/* store new config */
14081409
port->rs485 = *rs485;
14091410

1410-
/*
1411-
* Just as a precaution, only allow rs485
1412-
* to be enabled if the gpio pin is valid
1413-
*/
14141411
if (up->rts_gpiod) {
14151412
/* enable / disable rts */
14161413
val = (port->rs485.flags & SER_RS485_ENABLED) ?
14171414
SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND;
14181415
val = (port->rs485.flags & val) ? 1 : 0;
14191416
gpiod_set_value(up->rts_gpiod, val);
1420-
} else
1421-
port->rs485.flags &= ~SER_RS485_ENABLED;
1417+
}
14221418

14231419
/* Enable interrupts */
14241420
up->ier = mode;

0 commit comments

Comments
 (0)