* [PATCH] mmc: sdhci-of-dwcmshc: add suspend/resume support
@ 2020-05-15 6:19 Jisheng Zhang
2020-05-15 7:09 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: Jisheng Zhang @ 2020-05-15 6:19 UTC (permalink / raw)
To: Adrian Hunter, Ulf Hansson; +Cc: linux-mmc, linux-kernel
Add dwcmshc specific system-level suspend and resume support.
Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
---
drivers/mmc/host/sdhci-of-dwcmshc.c | 43 +++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
index a9ed0e006e06..64ac0dbee95c 100644
--- a/drivers/mmc/host/sdhci-of-dwcmshc.c
+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
@@ -163,6 +163,48 @@ static int dwcmshc_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int dwcmshc_suspend(struct device *dev)
+{
+ struct sdhci_host *host = dev_get_drvdata(dev);
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+ struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
+ int ret;
+
+ ret = sdhci_suspend_host(host);
+ if (ret)
+ return ret;
+
+ clk_disable_unprepare(pltfm_host->clk);
+ if (!IS_ERR(priv->bus_clk))
+ clk_disable_unprepare(priv->bus_clk);
+
+ return ret;
+}
+
+static int dwcmshc_resume(struct device *dev)
+{
+ struct sdhci_host *host = dev_get_drvdata(dev);
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+ struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
+ int ret;
+
+ ret = clk_prepare_enable(pltfm_host->clk);
+ if (ret)
+ return ret;
+
+ if (!IS_ERR(priv->bus_clk)) {
+ ret = clk_prepare_enable(priv->bus_clk);
+ if (ret)
+ return ret;
+ }
+
+ return sdhci_resume_host(host);
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume);
+
static const struct of_device_id sdhci_dwcmshc_dt_ids[] = {
{ .compatible = "snps,dwcmshc-sdhci" },
{}
@@ -173,6 +215,7 @@ static struct platform_driver sdhci_dwcmshc_driver = {
.driver = {
.name = "sdhci-dwcmshc",
.of_match_table = sdhci_dwcmshc_dt_ids,
+ .pm = &dwcmshc_pmops,
},
.probe = dwcmshc_probe,
.remove = dwcmshc_remove,
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: sdhci-of-dwcmshc: add suspend/resume support
2020-05-15 6:19 [PATCH] mmc: sdhci-of-dwcmshc: add suspend/resume support Jisheng Zhang
@ 2020-05-15 7:09 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2020-05-15 7:09 UTC (permalink / raw)
To: Jisheng Zhang; +Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List
On Fri, 15 May 2020 at 08:19, Jisheng Zhang <Jisheng.Zhang@synaptics.com> wrote:
>
> Add dwcmshc specific system-level suspend and resume support.
>
> Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/host/sdhci-of-dwcmshc.c | 43 +++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
> index a9ed0e006e06..64ac0dbee95c 100644
> --- a/drivers/mmc/host/sdhci-of-dwcmshc.c
> +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
> @@ -163,6 +163,48 @@ static int dwcmshc_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM_SLEEP
> +static int dwcmshc_suspend(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
> + int ret;
> +
> + ret = sdhci_suspend_host(host);
> + if (ret)
> + return ret;
> +
> + clk_disable_unprepare(pltfm_host->clk);
> + if (!IS_ERR(priv->bus_clk))
> + clk_disable_unprepare(priv->bus_clk);
> +
> + return ret;
> +}
> +
> +static int dwcmshc_resume(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
> + int ret;
> +
> + ret = clk_prepare_enable(pltfm_host->clk);
> + if (ret)
> + return ret;
> +
> + if (!IS_ERR(priv->bus_clk)) {
> + ret = clk_prepare_enable(priv->bus_clk);
> + if (ret)
> + return ret;
> + }
> +
> + return sdhci_resume_host(host);
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume);
> +
> static const struct of_device_id sdhci_dwcmshc_dt_ids[] = {
> { .compatible = "snps,dwcmshc-sdhci" },
> {}
> @@ -173,6 +215,7 @@ static struct platform_driver sdhci_dwcmshc_driver = {
> .driver = {
> .name = "sdhci-dwcmshc",
> .of_match_table = sdhci_dwcmshc_dt_ids,
> + .pm = &dwcmshc_pmops,
> },
> .probe = dwcmshc_probe,
> .remove = dwcmshc_remove,
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-15 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 6:19 [PATCH] mmc: sdhci-of-dwcmshc: add suspend/resume support Jisheng Zhang
2020-05-15 7:09 ` Ulf Hansson
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).