serial: fsl_lpuart: Use common rs485 device tree parsing function
authorSascha Hauer <s.hauer@pengutronix.de>
Wed, 13 Sep 2017 08:18:29 +0000 (10:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Sep 2017 16:36:25 +0000 (18:36 +0200)
We just got a common helper for parsing the rs485 specific
device tree properties. Use it and drop the open coded parser.

As a side effect this adds support for parsing rs485-rts-delay and
rs485-rx-during-tx. As the driver doesn't support this though, probing
fails if these are defined.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/fsl_lpuart.c

index 63f99a0..eac35d4 100644 (file)
@@ -2222,6 +2222,24 @@ static int lpuart_probe(struct platform_device *pdev)
                return ret;
        }
 
+       of_get_rs485_mode(np, &sport->port.rs485);
+
+       if (sport->port.rs485.flags & SER_RS485_RX_DURING_TX) {
+               dev_err(&pdev->dev, "driver doesn't support RX during TX\n");
+               return -ENOSYS;
+       }
+
+       if (sport->port.rs485.delay_rts_before_send ||
+           sport->port.rs485.delay_rts_after_send) {
+               dev_err(&pdev->dev, "driver doesn't support RTS delays\n");
+               return -ENOSYS;
+       }
+
+       if (sport->port.rs485.flags & SER_RS485_ENABLED) {
+               sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
+               writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
+       }
+
        sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx");
        if (!sport->dma_tx_chan)
                dev_info(sport->port.dev, "DMA tx channel request failed, "
@@ -2232,12 +2250,6 @@ static int lpuart_probe(struct platform_device *pdev)
                dev_info(sport->port.dev, "DMA rx channel request failed, "
                                "operating without rx DMA\n");
 
-       if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) {
-               sport->port.rs485.flags |= SER_RS485_ENABLED;
-               sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
-               writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
-       }
-
        return 0;
 }