linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: b32955@freescale.com (Huang Shijie)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] serial/imx: enable the clock when we really use the uart port
Date: Wed, 2 May 2012 16:19:30 +0800	[thread overview]
Message-ID: <1335946770-17120-1-git-send-email-b32955@freescale.com> (raw)

The current code keeps the clock enabled even when we do not really
use the uart port. But keep the clock enabled will consume some power.

In order to save more power, disable the clock when we do not use
the uart, and enable the clock when we really use the uart port.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/tty/serial/imx.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index e7fecee..f5dcdf6 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -694,6 +694,8 @@ static int imx_startup(struct uart_port *port)
 	int retval;
 	unsigned long flags, temp;
 
+	clk_prepare_enable(sport->clk);
+
 	imx_setup_ufcr(sport, 0);
 
 	/* disable the DREN bit (Data Ready interrupt enable) before
@@ -877,6 +879,8 @@ static void imx_shutdown(struct uart_port *port)
 		temp &= ~(UCR1_IREN);
 
 	writel(temp, sport->port.membase + UCR1);
+
+	clk_disable_unprepare(sport->clk);
 }
 
 static void
@@ -1526,6 +1530,7 @@ static int serial_imx_probe(struct platform_device *pdev)
 		goto deinit;
 	platform_set_drvdata(pdev, &sport->port);
 
+	clk_disable_unprepare(sport->clk);
 	return 0;
 deinit:
 	if (pdata && pdata->exit)
@@ -1552,7 +1557,6 @@ static int serial_imx_remove(struct platform_device *pdev)
 
 	if (sport) {
 		uart_remove_one_port(&imx_reg, &sport->port);
-		clk_disable_unprepare(sport->clk);
 		clk_put(sport->clk);
 	}
 
-- 
1.7.3.2

             reply	other threads:[~2012-05-02  8:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-02  8:19 Huang Shijie [this message]
2012-05-02  8:19 ` [PATCH] serial/imx: enable the clock when we really use the uart port Sascha Hauer
2012-05-02  8:28   ` Huang Shijie
2012-06-10 17:31   ` Fabio Estevam
2012-06-11  2:13     ` Huang Shijie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335946770-17120-1-git-send-email-b32955@freescale.com \
    --to=b32955@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).