Skip to content
Snippets Groups Projects
Commit 45f6b6db authored by Dario Binacchi's avatar Dario Binacchi Committed by Greg Kroah-Hartman
Browse files

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: 4a0ac0f5 ("OMAP: add RS485 support")
Signed-off-by: default avatarDario Binacchi <dariobin@libero.it>
Link: https://lore.kernel.org/r/20210415210945.25863-1-dariobin@libero.it


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cea37afd
No related branches found
No related tags found
No related merge requests found
...@@ -302,7 +302,8 @@ static void serial_omap_stop_tx(struct uart_port *port) ...@@ -302,7 +302,8 @@ static void serial_omap_stop_tx(struct uart_port *port)
serial_out(up, UART_OMAP_SCR, up->scr); serial_out(up, UART_OMAP_SCR, up->scr);
res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ? res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ?
1 : 0; 1 : 0;
if (gpiod_get_value(up->rts_gpiod) != res) { if (up->rts_gpiod &&
gpiod_get_value(up->rts_gpiod) != res) {
if (port->rs485.delay_rts_after_send > 0) if (port->rs485.delay_rts_after_send > 0)
mdelay( mdelay(
port->rs485.delay_rts_after_send); port->rs485.delay_rts_after_send);
...@@ -411,7 +412,7 @@ static void serial_omap_start_tx(struct uart_port *port) ...@@ -411,7 +412,7 @@ static void serial_omap_start_tx(struct uart_port *port)
/* if rts not already enabled */ /* if rts not already enabled */
res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0; res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0;
if (gpiod_get_value(up->rts_gpiod) != res) { if (up->rts_gpiod && gpiod_get_value(up->rts_gpiod) != res) {
gpiod_set_value(up->rts_gpiod, res); gpiod_set_value(up->rts_gpiod, res);
if (port->rs485.delay_rts_before_send > 0) if (port->rs485.delay_rts_before_send > 0)
mdelay(port->rs485.delay_rts_before_send); mdelay(port->rs485.delay_rts_before_send);
...@@ -1407,18 +1408,13 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) ...@@ -1407,18 +1408,13 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
/* store new config */ /* store new config */
port->rs485 = *rs485; port->rs485 = *rs485;
/*
* Just as a precaution, only allow rs485
* to be enabled if the gpio pin is valid
*/
if (up->rts_gpiod) { if (up->rts_gpiod) {
/* enable / disable rts */ /* enable / disable rts */
val = (port->rs485.flags & SER_RS485_ENABLED) ? val = (port->rs485.flags & SER_RS485_ENABLED) ?
SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND; SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND;
val = (port->rs485.flags & val) ? 1 : 0; val = (port->rs485.flags & val) ? 1 : 0;
gpiod_set_value(up->rts_gpiod, val); gpiod_set_value(up->rts_gpiod, val);
} else }
port->rs485.flags &= ~SER_RS485_ENABLED;
/* Enable interrupts */ /* Enable interrupts */
up->ier = mode; up->ier = mode;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment