]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
serial: imx: enable the clocks only when the uart is used
authorHuang Shijie <b32955@freescale.com>
Tue, 4 Jun 2013 01:59:33 +0000 (09:59 +0800)
committerJason Liu <r64343@freescale.com>
Wed, 30 Oct 2013 01:54:02 +0000 (09:54 +0800)
Current code opens the clocks when the uart driver is probed.
This will wastes some power if several uarts are enabled, but not really
used.

So close these clocks for uart, and enable the clocks only when
the uart is used.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c

index a07e94f6a9fc4c155fd94090ae5b38e1f5ca630c..d290274e063ca47ecca19946bb7b03d06700a908 100644 (file)
@@ -700,6 +700,14 @@ static int imx_startup(struct uart_port *port)
        int retval;
        unsigned long flags, temp;
 
+       retval = clk_prepare_enable(sport->clk_per);
+       if (retval)
+               goto error_out1;
+
+       retval = clk_prepare_enable(sport->clk_ipg);
+       if (retval)
+               goto error_out1;
+
        imx_setup_ufcr(sport, 0);
 
        /* disable the DREN bit (Data Ready interrupt enable) before
@@ -887,6 +895,9 @@ static void imx_shutdown(struct uart_port *port)
 
        writel(temp, sport->port.membase + UCR1);
        spin_unlock_irqrestore(&sport->port.lock, flags);
+
+       clk_disable_unprepare(sport->clk_per);
+       clk_disable_unprepare(sport->clk_ipg);
 }
 
 static void
@@ -1565,6 +1576,9 @@ static int serial_imx_probe(struct platform_device *pdev)
                goto deinit;
        platform_set_drvdata(pdev, sport);
 
+       clk_disable_unprepare(sport->clk_per);
+       clk_disable_unprepare(sport->clk_ipg);
+
        return 0;
 deinit:
        if (pdata && pdata->exit)
@@ -1586,9 +1600,6 @@ static int serial_imx_remove(struct platform_device *pdev)
 
        uart_remove_one_port(&imx_reg, &sport->port);
 
-       clk_disable_unprepare(sport->clk_per);
-       clk_disable_unprepare(sport->clk_ipg);
-
        if (pdata && pdata->exit)
                pdata->exit(pdev);