linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] serial: imx: enable the clocks only when the uart is used
@ 2013-06-04  1:59 Huang Shijie
  2013-06-08  6:01 ` Shawn Guo
  0 siblings, 1 reply; 14+ messages in thread
From: Huang Shijie @ 2013-06-04  1:59 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
v1 --> v2:
	check the return value of clk_prepare_enable().
---
 drivers/tty/serial/imx.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 72bc1db..7cc4810 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -699,6 +699,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
@@ -884,6 +892,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
@@ -1557,6 +1568,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)
@@ -1578,9 +1592,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);
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-06-10  0:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-04  1:59 [PATCH V2] serial: imx: enable the clocks only when the uart is used Huang Shijie
2013-06-08  6:01 ` Shawn Guo
2013-06-08  6:22   ` Huang Shijie
2013-06-08  6:23     ` Shawn Guo
2013-06-08  8:04       ` [PATCH] serial: imx: enable the clocks for console Huang Shijie
2013-06-08 13:11         ` Fabio Estevam
2013-06-09  2:01           ` [PATCH v2] " Huang Shijie
2013-06-09  8:34             ` Shawn Guo
2013-06-09 13:05               ` Shawn Guo
2013-06-09 17:26                 ` Greg KH
2013-06-10  0:55                   ` Shawn Guo
2013-06-09  2:17           ` [PATCH] " Huang Shijie
2013-06-08 11:56       ` Re[2]: [PATCH V2] serial: imx: enable the clocks only when the uart is used Alexander Shiyan
2013-06-08  8:15     ` Russell King - ARM Linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).