From: MADHAV SINGHCHAUHAN <singh.madhav@samsung.com>
To: linux-mmc@vger.kernel.org, kyungmin.park@samsung.com
Subject: [PATCH RESEND] sdhci-clk-gating-support
Date: Fri, 02 Jul 2010 14:15:44 +0000 (GMT) [thread overview]
Message-ID: <23314024.108801278080144319.JavaMail.weblogic@epml07> (raw)
I fixed the all issues after running checkpatch.pl and resending it.
From 1fae693a2eef37d878066b09c89f95f57f945f64 Mon Sep 17 00:00:00 2001
From: Madhav Singh <singh.madhav@samsung.com>
Date: Fri, 2 Jul 2010 19:33:19 +0530
Subject: [PATCH] sdhci-clk-gating-support
This patch implements clock gating support in sdhci layer.It will enable the clock when
host controller start sending request to attached device and will disable it once it
finish the command.
Signed-off-by: Madhav Chauhan <singh.madhav@samsung.com> , Nitish Ambastha <nitish.a@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/mmc/host/sdhci.c | 34 ++++++++++++++++++++++++++++++++++
drivers/mmc/host/sdhci.h | 7 +++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c6d1bd8..37ed265 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1103,6 +1103,8 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
spin_lock_irqsave(&host->lock, flags);
+ sdhci_clk_enable(host); /*Enable clock as transfer starts now*/
+
WARN_ON(host->mrq != NULL);
#ifndef SDHCI_USE_LEDS_CLASS
@@ -1310,6 +1312,8 @@ static void sdhci_tasklet_finish(unsigned long param)
sdhci_reset(host, SDHCI_RESET_DATA);
}
+ sdhci_clk_disable(host); /*Disable clock as command has been processed*/
+
host->mrq = NULL;
host->cmd = NULL;
host->data = NULL;
@@ -1597,6 +1601,8 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
sdhci_disable_card_detection(host);
+ sdhci_clk_enable(host); /* Enable clock */
+
ret = mmc_suspend_host(host->mmc);
if (ret)
return ret;
@@ -1626,6 +1632,9 @@ int sdhci_resume_host(struct sdhci_host *host)
mmiowb();
ret = mmc_resume_host(host->mmc);
+
+ sdhci_clk_disable(host); /*Now device has wake up disable it*/
+
sdhci_enable_card_detection(host);
return ret;
@@ -1654,6 +1663,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
return ERR_PTR(-ENOMEM);
host = mmc_priv(mmc);
+ host->user = 0; /*For Clock gating*/
+ host->clk_restore = 0;
+
host->mmc = mmc;
return host;
@@ -1984,6 +1996,28 @@ void sdhci_free_host(struct sdhci_host *host)
EXPORT_SYMBOL_GPL(sdhci_free_host);
+void sdhci_clk_enable(struct sdhci_host *host)
+{
+ if (!host->user) {
+ if (host->clk_restore && host->clock == 0)
+ sdhci_set_clock(host, host->clk_restore);
+ }
+ host->user++;
+}
+EXPORT_SYMBOL_GPL(sdhci_clk_enable);
+
+void sdhci_clk_disable(struct sdhci_host *host)
+{
+ host->user--;
+ if (!host->user)
+ if (host->clock != 0) {
+ host->clk_restore = host->clock;
+ sdhci_set_clock(host, 0);
+ }
+}
+EXPORT_SYMBOL_GPL(sdhci_clk_disable);
+
+
/*****************************************************************************\
* *
* Driver init/exit *
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index c846813..5912e28 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -292,6 +292,9 @@ struct sdhci_host {
struct timer_list timer; /* Timer for timeouts */
+ unsigned int clk_restore; /*For Clock Gating*/
+ unsigned int user;
+
unsigned long private[0] ____cacheline_aligned;
};
@@ -410,6 +413,10 @@ static inline void *sdhci_priv(struct sdhci_host *host)
extern int sdhci_add_host(struct sdhci_host *host);
extern void sdhci_remove_host(struct sdhci_host *host, int dead);
+/*For Clock Gating*/
+extern void sdhci_clk_enable(struct sdhci_host *host);
+extern void sdhci_clk_disable(struct sdhci_host *host);
+
#ifdef CONFIG_PM
extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state);
extern int sdhci_resume_host(struct sdhci_host *host);
--
1.6.0.4
next reply other threads:[~2010-07-02 14:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-02 14:15 MADHAV SINGHCHAUHAN [this message]
2010-07-02 16:01 ` [PATCH RESEND] sdhci-clk-gating-support Chris Ball
2010-07-06 5:55 ` Madhav
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=23314024.108801278080144319.JavaMail.weblogic@epml07 \
--to=singh.madhav@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-mmc@vger.kernel.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