All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: imx: enable the clocks only when the uart is used
@ 2013-06-03  7:42 ` Huang Shijie
  0 siblings, 0 replies; 6+ messages in thread
From: Huang Shijie @ 2013-06-03  7:42 UTC (permalink / raw)
  To: gregkh; +Cc: Huang Shijie, linux-arm-kernel, linux-serial

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>
---
 drivers/tty/serial/imx.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 72bc1db..5705fc8 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -699,6 +699,9 @@ static int imx_startup(struct uart_port *port)
 	int retval;
 	unsigned long flags, temp;
 
+	clk_prepare_enable(sport->clk_per);
+	clk_prepare_enable(sport->clk_ipg);
+
 	imx_setup_ufcr(sport, 0);
 
 	/* disable the DREN bit (Data Ready interrupt enable) before
@@ -884,6 +887,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 +1563,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 +1587,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] 6+ messages in thread

* [PATCH] serial: imx: enable the clocks only when the uart is used
@ 2013-06-03  7:42 ` Huang Shijie
  0 siblings, 0 replies; 6+ messages in thread
From: Huang Shijie @ 2013-06-03  7:42 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>
---
 drivers/tty/serial/imx.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 72bc1db..5705fc8 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -699,6 +699,9 @@ static int imx_startup(struct uart_port *port)
 	int retval;
 	unsigned long flags, temp;
 
+	clk_prepare_enable(sport->clk_per);
+	clk_prepare_enable(sport->clk_ipg);
+
 	imx_setup_ufcr(sport, 0);
 
 	/* disable the DREN bit (Data Ready interrupt enable) before
@@ -884,6 +887,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 +1563,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 +1587,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] 6+ messages in thread

* Re: [PATCH] serial: imx: enable the clocks only when the uart is used
  2013-06-03  7:42 ` Huang Shijie
@ 2013-06-03  9:50   ` Russell King - ARM Linux
  -1 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2013-06-03  9:50 UTC (permalink / raw)
  To: Huang Shijie; +Cc: gregkh, linux-arm-kernel, linux-serial

On Mon, Jun 03, 2013 at 03:42:11PM +0800, Huang Shijie wrote:
> 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>
> ---
>  drivers/tty/serial/imx.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 72bc1db..5705fc8 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -699,6 +699,9 @@ static int imx_startup(struct uart_port *port)
>  	int retval;
>  	unsigned long flags, temp;
>  
> +	clk_prepare_enable(sport->clk_per);
> +	clk_prepare_enable(sport->clk_ipg);

You should check the return value.  I've a good mind to mark these
functions with __must_check...

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

* [PATCH] serial: imx: enable the clocks only when the uart is used
@ 2013-06-03  9:50   ` Russell King - ARM Linux
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2013-06-03  9:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 03, 2013 at 03:42:11PM +0800, Huang Shijie wrote:
> 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>
> ---
>  drivers/tty/serial/imx.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 72bc1db..5705fc8 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -699,6 +699,9 @@ static int imx_startup(struct uart_port *port)
>  	int retval;
>  	unsigned long flags, temp;
>  
> +	clk_prepare_enable(sport->clk_per);
> +	clk_prepare_enable(sport->clk_ipg);

You should check the return value.  I've a good mind to mark these
functions with __must_check...

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

* Re: [PATCH] serial: imx: enable the clocks only when the uart is used
  2013-06-03  9:50   ` Russell King - ARM Linux
@ 2013-06-04  2:12     ` Huang Shijie
  -1 siblings, 0 replies; 6+ messages in thread
From: Huang Shijie @ 2013-06-04  2:12 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: gregkh, linux-arm-kernel, linux-serial

于 2013年06月03日 17:50, Russell King - ARM Linux 写道:
> You should check the return value.  I've a good mind to mark these
> functions with __must_check...
yes, that's a good idea to add the __must_check.

thanks
Huang Shijie

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH] serial: imx: enable the clocks only when the uart is used
@ 2013-06-04  2:12     ` Huang Shijie
  0 siblings, 0 replies; 6+ messages in thread
From: Huang Shijie @ 2013-06-04  2:12 UTC (permalink / raw)
  To: linux-arm-kernel

? 2013?06?03? 17:50, Russell King - ARM Linux ??:
> You should check the return value.  I've a good mind to mark these
> functions with __must_check...
yes, that's a good idea to add the __must_check.

thanks
Huang Shijie

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

end of thread, other threads:[~2013-06-04  2:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03  7:42 [PATCH] serial: imx: enable the clocks only when the uart is used Huang Shijie
2013-06-03  7:42 ` Huang Shijie
2013-06-03  9:50 ` Russell King - ARM Linux
2013-06-03  9:50   ` Russell King - ARM Linux
2013-06-04  2:12   ` Huang Shijie
2013-06-04  2:12     ` Huang Shijie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.