diff options
author | Lukas Wunner <lukas@wunner.de> | 2017-11-24 17:26:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-11-28 10:05:19 -0500 |
commit | f1e5b618c1c26cb8b5818e36f996e8c2fbedbeb7 (patch) | |
tree | d75fec5220f2f86305a22a7c877cfe272d85309a | |
parent | 6abe9ea8a5a5904d935b8a482117a7fd9b25f09e (diff) |
serial: core: Support common rs485 binding for RTS polarity
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.
imx contains a line to set the default RTS polarity to active high,
it is now superfluous and hence deleted.
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@newflow.co.uk>
Cc: Michał Oleszczyk <oleszczyk.m@gmail.com>
Cc: Rafael Gago Castano <rgc@hms.se>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/imx.c | 1 | ||||
-rw-r--r-- | drivers/tty/serial/omap-serial.c | 7 | ||||
-rw-r--r-- | drivers/tty/serial/serial_core.c | 13 |
3 files changed, 15 insertions, 6 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index aca3b7dbd09c..d2c7d88d5774 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
@@ -2060,7 +2060,6 @@ static int serial_imx_probe(struct platform_device *pdev) | |||
2060 | sport->port.fifosize = 32; | 2060 | sport->port.fifosize = 32; |
2061 | sport->port.ops = &imx_pops; | 2061 | sport->port.ops = &imx_pops; |
2062 | sport->port.rs485_config = imx_rs485_config; | 2062 | sport->port.rs485_config = imx_rs485_config; |
2063 | sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND; | ||
2064 | sport->port.flags = UPF_BOOT_AUTOCONF; | 2063 | sport->port.flags = UPF_BOOT_AUTOCONF; |
2065 | timer_setup(&sport->timer, imx_timeout, 0); | 2064 | timer_setup(&sport->timer, imx_timeout, 0); |
2066 | 2065 | ||
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 227347548fff..56e683373d6d 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
@@ -1613,10 +1613,13 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, | |||
1613 | 1613 | ||
1614 | uart_get_rs485_mode(up->dev, rs485conf); | 1614 | uart_get_rs485_mode(up->dev, rs485conf); |
1615 | 1615 | ||
1616 | if (of_property_read_bool(np, "rs485-rts-active-high")) | 1616 | if (of_property_read_bool(np, "rs485-rts-active-high")) { |
1617 | rs485conf->flags |= SER_RS485_RTS_ON_SEND; | 1617 | rs485conf->flags |= SER_RS485_RTS_ON_SEND; |
1618 | else | 1618 | rs485conf->flags &= ~SER_RS485_RTS_AFTER_SEND; |
1619 | } else { | ||
1620 | rs485conf->flags &= ~SER_RS485_RTS_ON_SEND; | ||
1619 | rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; | 1621 | rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; |
1622 | } | ||
1620 | 1623 | ||
1621 | /* check for tx enable gpio */ | 1624 | /* check for tx enable gpio */ |
1622 | up->rts_gpio = of_get_named_gpio_flags(np, "rts-gpio", 0, &flags); | 1625 | 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 a59184a7afb0..f57969de2f1c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -3036,16 +3036,23 @@ void uart_get_rs485_mode(struct device *dev, struct serial_rs485 *rs485conf) | |||
3036 | } | 3036 | } |
3037 | 3037 | ||
3038 | /* | 3038 | /* |
3039 | * clear full-duplex and enabled flags to get to a defined state with | 3039 | * Clear full-duplex and enabled flags, set RTS polarity to active high |
3040 | * the two following properties. | 3040 | * to get to a defined state with the following properties: |
3041 | */ | 3041 | */ |
3042 | rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED); | 3042 | rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED | |
3043 | SER_RS485_RTS_AFTER_SEND); | ||
3044 | rs485conf->flags |= SER_RS485_RTS_ON_SEND; | ||
3043 | 3045 | ||
3044 | if (device_property_read_bool(dev, "rs485-rx-during-tx")) | 3046 | if (device_property_read_bool(dev, "rs485-rx-during-tx")) |
3045 | rs485conf->flags |= SER_RS485_RX_DURING_TX; | 3047 | rs485conf->flags |= SER_RS485_RX_DURING_TX; |
3046 | 3048 | ||
3047 | if (device_property_read_bool(dev, "linux,rs485-enabled-at-boot-time")) | 3049 | if (device_property_read_bool(dev, "linux,rs485-enabled-at-boot-time")) |
3048 | rs485conf->flags |= SER_RS485_ENABLED; | 3050 | rs485conf->flags |= SER_RS485_ENABLED; |
3051 | |||
3052 | if (device_property_read_bool(dev, "rs485-rts-active-low")) { | ||
3053 | rs485conf->flags &= ~SER_RS485_RTS_ON_SEND; | ||
3054 | rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; | ||
3055 | } | ||
3049 | } | 3056 | } |
3050 | EXPORT_SYMBOL_GPL(uart_get_rs485_mode); | 3057 | EXPORT_SYMBOL_GPL(uart_get_rs485_mode); |
3051 | 3058 | ||