Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: omap: don't disable rs485 if rts gpio is missing

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: 4a0ac0f55b18 ("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>

authored by

Dario Binacchi and committed by
Greg Kroah-Hartman
45f6b6db cea37afd

+4 -8
+4 -8
drivers/tty/serial/omap-serial.c
··· 302 302 serial_out(up, UART_OMAP_SCR, up->scr); 303 303 res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ? 304 304 1 : 0; 305 - if (gpiod_get_value(up->rts_gpiod) != res) { 305 + if (up->rts_gpiod && 306 + gpiod_get_value(up->rts_gpiod) != res) { 306 307 if (port->rs485.delay_rts_after_send > 0) 307 308 mdelay( 308 309 port->rs485.delay_rts_after_send); ··· 412 411 413 412 /* if rts not already enabled */ 414 413 res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0; 415 - if (gpiod_get_value(up->rts_gpiod) != res) { 414 + if (up->rts_gpiod && gpiod_get_value(up->rts_gpiod) != res) { 416 415 gpiod_set_value(up->rts_gpiod, res); 417 416 if (port->rs485.delay_rts_before_send > 0) 418 417 mdelay(port->rs485.delay_rts_before_send); ··· 1408 1407 /* store new config */ 1409 1408 port->rs485 = *rs485; 1410 1409 1411 - /* 1412 - * Just as a precaution, only allow rs485 1413 - * to be enabled if the gpio pin is valid 1414 - */ 1415 1410 if (up->rts_gpiod) { 1416 1411 /* enable / disable rts */ 1417 1412 val = (port->rs485.flags & SER_RS485_ENABLED) ? 1418 1413 SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND; 1419 1414 val = (port->rs485.flags & val) ? 1 : 0; 1420 1415 gpiod_set_value(up->rts_gpiod, val); 1421 - } else 1422 - port->rs485.flags &= ~SER_RS485_ENABLED; 1416 + } 1423 1417 1424 1418 /* Enable interrupts */ 1425 1419 up->ier = mode;