From ae78c40a12501108e0fee5c7d3b9d0e3e1a8214e Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 17 Apr 2018 11:34:34 +0200 Subject: serial: imx: add RS-485 device tree properties Add device tree properties to influence RTS polarity and whether the receiver is enabled during transmission (rs485-rts-active-low, rs485-rx-during-tx). This aligns with behavior with upstream Linux, where RTS is active high by default (SER_RS485_RTS_AFTER_SEND) and the receiver is disabled by default when using RS485 (SER_RS485_RX_DURING_TX). Note that for Toradex hardware both properties are required, hence using RS-485 on Toradex Carrier Boards requires the following properties being specified in the device tree: linux,rs485-enabled-at-boot-time; rs485-rts-active-low; rs485-rx-during-tx; Signed-off-by: Stefan Agner Acked-by: Max Krummenacher --- drivers/tty/serial/imx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 002eb91eca12..cd37a3a0f387 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2069,8 +2069,16 @@ static int serial_imx_probe_dt(struct imx_port *sport, if (of_get_property(np, "fsl,dte-mode", NULL)) sport->dte_mode = 1; - if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) { + sport->port.rs485.flags |= SER_RS485_RTS_AFTER_SEND; + + if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) sport->port.rs485.flags |= SER_RS485_ENABLED; + + if (of_property_read_bool(np, "rs485-rx-during-tx")) + sport->port.rs485.flags |= SER_RS485_RX_DURING_TX; + + if (of_property_read_bool(np, "rs485-rts-active-low")) { + sport->port.rs485.flags &= ~SER_RS485_RTS_ON_SEND; sport->port.rs485.flags |= SER_RS485_RTS_AFTER_SEND; } -- cgit v1.2.3