MLK-14498-8 tty: serial: imx: add modem device reset
authorAndy Duan <fugang.duan@nxp.com>
Tue, 21 Mar 2017 09:59:20 +0000 (17:59 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:21:39 +0000 (15:21 -0500)
Add modem device reset, wthether to reset depend on dts configuration.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
drivers/tty/serial/imx.c

index fa06bc9..9b20064 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/rational.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -1232,9 +1233,17 @@ static void imx_disable_dma(struct imx_port *sport)
 static int imx_startup(struct uart_port *port)
 {
        struct imx_port *sport = (struct imx_port *)port;
+       struct tty_port *tty_port = &sport->port.state->port;
        int retval, i;
        unsigned long flags, temp;
 
+       /* some modem may need reset */
+       if (!(tty_port->flags & ASYNC_SUSPENDED)) {
+               retval = device_reset(sport->port.dev);
+               if (retval && retval != -ENOENT)
+                       return retval;
+       }
+
        retval = clk_prepare_enable(sport->clk_per);
        if (retval)
                return retval;