All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhoujie Wu <zjwu@marvell.com>
To: ulf.hansson@linaro.org, adrian.hunter@intel.com,
	linux-mmc@vger.kernel.org
Cc: zmxu@marvell.com, jszhang@marvell.com, nadavh@marvell.com,
	xigu@marvell.com, xswang@marvell.com, dingwei@marvell.com,
	kostap@marvell.com, hannah@marvell.com, hongd@marvell.com,
	dougj@marvell.com, ygao@marvell.com, liuw@marvell.com,
	gregory.clement@free-electrons.com,
	thomas.petazzoni@free-electrons.com,
	Zhoujie Wu <zjwu@marvell.com>
Subject: [PATCH 2/2] mmc: sdhci-xenon: implement system standby base on runtime pm
Date: Thu, 24 Aug 2017 15:19:38 -0700	[thread overview]
Message-ID: <1503613178-26912-3-git-send-email-zjwu@marvell.com> (raw)
In-Reply-To: <1503613178-26912-1-git-send-email-zjwu@marvell.com>

Implement system standby based on runtime pm API.
Introduce restore_needed to restore the Xenon specific registers
when resume.

Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
---
 drivers/mmc/host/sdhci-xenon.c | 41 ++++++++++++-----------------------------
 drivers/mmc/host/sdhci-xenon.h |  1 +
 2 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
index 517ff2e..d40ec46 100644
--- a/drivers/mmc/host/sdhci-xenon.c
+++ b/drivers/mmc/host/sdhci-xenon.c
@@ -555,40 +555,15 @@ static int xenon_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
 	int ret;
 
-	ret = sdhci_suspend_host(host);
-	if (ret)
-		return ret;
+	ret = pm_runtime_force_suspend(dev);
 
-	clk_disable_unprepare(pltfm_host->clk);
+	priv->restore_needed = true;
 	return ret;
 }
-
-static int xenon_resume(struct device *dev)
-{
-	struct sdhci_host *host = dev_get_drvdata(dev);
-	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
-	int ret;
-
-	ret = clk_prepare_enable(pltfm_host->clk);
-	if (ret)
-		return ret;
-
-	/*
-	 * If SoCs power off the entire Xenon, registers setting will
-	 * be lost.
-	 * Re-configure Xenon specific register to enable current SDHC
-	 */
-	ret = xenon_sdhc_prepare(host);
-	if (ret)
-		return ret;
-
-	return sdhci_resume_host(host);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(xenon_pmops, xenon_suspend, xenon_resume);
+#endif /* CONFIG_PM_SLEEP */
 
 #ifdef CONFIG_PM
 static int xenon_runtime_suspend(struct device *dev)
@@ -617,6 +592,7 @@ static int xenon_runtime_resume(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
 	int ret;
 
 	ret = clk_prepare_enable(pltfm_host->clk);
@@ -625,11 +601,18 @@ static int xenon_runtime_resume(struct device *dev)
 		return ret;
 	}
 
+	if (priv->restore_needed) {
+		xenon_sdhc_prepare(host);
+		priv->restore_needed = false;
+	}
+
 	return sdhci_runtime_resume_host(host);
 }
 #endif /* CONFIG_PM */
 
 static const struct dev_pm_ops sdhci_xenon_dev_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(xenon_suspend,
+				pm_runtime_force_resume)
 	SET_RUNTIME_PM_OPS(xenon_runtime_suspend,
 			   xenon_runtime_resume,
 			   NULL)
diff --git a/drivers/mmc/host/sdhci-xenon.h b/drivers/mmc/host/sdhci-xenon.h
index 01937f1..2bc0510 100644
--- a/drivers/mmc/host/sdhci-xenon.h
+++ b/drivers/mmc/host/sdhci-xenon.h
@@ -91,6 +91,7 @@ struct xenon_priv {
 	 */
 	void		*phy_params;
 	struct xenon_emmc_phy_regs *emmc_phy_regs;
+	bool restore_needed;
 };
 
 int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios);
-- 
1.9.1


      parent reply	other threads:[~2017-08-24 22:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 22:19 [PATCH 0/2] add runtime pm support for xenon Zhoujie Wu
2017-08-24 22:19 ` [PATCH 1/2] mmc: sdhci-xenon: add runtime pm support Zhoujie Wu
2017-08-28 11:49   ` Adrian Hunter
2017-08-28 18:36     ` Zhoujie Wu
2017-08-24 22:19 ` Zhoujie Wu [this message]

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=1503613178-26912-3-git-send-email-zjwu@marvell.com \
    --to=zjwu@marvell.com \
    --cc=adrian.hunter@intel.com \
    --cc=dingwei@marvell.com \
    --cc=dougj@marvell.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=hannah@marvell.com \
    --cc=hongd@marvell.com \
    --cc=jszhang@marvell.com \
    --cc=kostap@marvell.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=liuw@marvell.com \
    --cc=nadavh@marvell.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=ulf.hansson@linaro.org \
    --cc=xigu@marvell.com \
    --cc=xswang@marvell.com \
    --cc=ygao@marvell.com \
    --cc=zmxu@marvell.com \
    /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 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.