When a driver invokes the uart_get_rs485_mode() helper, set the RTS polarity to active high by default unless the newly introduced "rs485-rts-active-low" property was specified. omap-serial historically defaults to active low and supports an "rs485-rts-active-high" property to inverse the polarity. Retain that behavior for compatibility. Cc: Mark Jackson <mpfj@xxxxxxxxxxxxx> Cc: Michał Oleszczyk <oleszczyk.m@xxxxxxxxx> Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> Cc: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> Signed-off-by: Lukas Wunner <lukas@xxxxxxxxx> --- drivers/tty/serial/omap-serial.c | 7 +++++-- drivers/tty/serial/serial_core.c | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index e6aadb6d02e5..7ef36c0af825 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1617,10 +1617,13 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, uart_get_rs485_mode(up->dev, rs485conf); - if (of_property_read_bool(np, "rs485-rts-active-high")) + if (of_property_read_bool(np, "rs485-rts-active-high")) { rs485conf->flags |= SER_RS485_RTS_ON_SEND; - else + rs485conf->flags &= ~SER_RS485_RTS_AFTER_SEND; + } else { + rs485conf->flags &= ~SER_RS485_RTS_ON_SEND; rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; + } /* check for tx enable gpio */ up->rts_gpio = of_get_named_gpio_flags(np, "rts-gpio", 0, &flags); diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 548bb80223c1..64e15507a9bd 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3048,6 +3048,14 @@ void uart_get_rs485_mode(struct device *dev, struct serial_rs485 *rs485conf) rs485conf->delay_rts_after_send = 0; } + if (device_property_read_bool(dev, "rs485-rts-active-low")) { + rs485conf->flags &= ~SER_RS485_RTS_ON_SEND; + rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; + } else { + rs485conf->flags |= SER_RS485_RTS_ON_SEND; + rs485conf->flags &= ~SER_RS485_RTS_AFTER_SEND; + } + /* * clear full-duplex and enabled flags to get to a defined state with * the two following properties. -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html