From: Rudy <oleszczyk.m@xxxxxxxxx> Remove default RS485 flag setting. Prepare separated function which reads RS485 configuration from device tree instead. Signed-off-by: Michal Oleszczyk <oleszczyk.m@xxxxxxxxx> --- drivers/tty/serial/imx.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index dfeff39..576e53b 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2076,6 +2076,37 @@ static void serial_imx_probe_pdata(struct imx_port *sport, sport->have_rtscts = 1; } +static void serial_imx_probe_rs485(struct imx_port *sport, + struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct serial_rs485 *rs485conf = &sport->port.rs485; + u32 rs485_delay[2]; + + rs485conf->flags = 0; + if (!np) + return; + + 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; + + if (of_property_read_u32_array(np, "rs485-rts-delay", + rs485_delay, 2) == 0) { + rs485conf->delay_rts_before_send = rs485_delay[0]; + rs485conf->delay_rts_after_send = rs485_delay[1]; + } + + if (of_property_read_bool(np, "rs485-rx-during-tx")) + rs485conf->flags |= SER_RS485_RX_DURING_TX; + + if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) + rs485conf->flags |= SER_RS485_ENABLED; + + return; +} + static int serial_imx_probe(struct platform_device *pdev) { struct imx_port *sport; @@ -2094,6 +2125,7 @@ static int serial_imx_probe(struct platform_device *pdev) else if (ret < 0) return ret; + serial_imx_probe_rs485(sport, pdev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) @@ -2112,8 +2144,6 @@ static int serial_imx_probe(struct platform_device *pdev) sport->port.fifosize = 32; sport->port.ops = &imx_pops; sport->port.rs485_config = imx_rs485_config; - sport->port.rs485.flags = - SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX; sport->port.flags = UPF_BOOT_AUTOCONF; init_timer(&sport->timer); sport->timer.function = imx_timeout; -- 2.7.4 -- 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