Commit 1ab0d2d7 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Ulf Hansson

mmc: sdhci: enable/disable the clock in sdhci_pltfm_suspend/resume

This commit provides similar cleanups as commit 83eacdfa ("mmc:
sdhci: disable the clock in sdhci_pltfm_unregister()") did for
unregister hooks.

sdhci-brcmstb.c and sdhci-sirf.c implement their own suspend/resume
hooks to handle pltfm_host->clk.  Move clock handling to sdhci_pltfm.c
so that the drivers can reuse sdhci_pltfm_pmops.

The following drivers did not previously touch pltfm_host->clk during
suspend/resume, but now do:
  - sdhci-bcm-kona.c
  - sdhci-dove.c
  - sdhci-iproc.c
  - sdhci-pxav2.c
  - sdhci-tegra.c
  - sdhci-xenon.c
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Acked-by: default avatarAl Cooper <alcooperx@gmail.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 3fd1d86f
...@@ -21,41 +21,6 @@ ...@@ -21,41 +21,6 @@
#include "sdhci-pltfm.h" #include "sdhci-pltfm.h"
#ifdef CONFIG_PM_SLEEP
static int sdhci_brcmstb_suspend(struct device *dev)
{
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
int res;
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
mmc_retune_needed(host->mmc);
res = sdhci_suspend_host(host);
if (res)
return res;
clk_disable_unprepare(pltfm_host->clk);
return res;
}
static int sdhci_brcmstb_resume(struct device *dev)
{
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
int err;
err = clk_prepare_enable(pltfm_host->clk);
if (err)
return err;
return sdhci_resume_host(host);
}
#endif /* CONFIG_PM_SLEEP */
static SIMPLE_DEV_PM_OPS(sdhci_brcmstb_pmops, sdhci_brcmstb_suspend,
sdhci_brcmstb_resume);
static const struct sdhci_ops sdhci_brcmstb_ops = { static const struct sdhci_ops sdhci_brcmstb_ops = {
.set_clock = sdhci_set_clock, .set_clock = sdhci_set_clock,
.set_bus_width = sdhci_set_bus_width, .set_bus_width = sdhci_set_bus_width,
...@@ -131,7 +96,7 @@ MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match); ...@@ -131,7 +96,7 @@ MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match);
static struct platform_driver sdhci_brcmstb_driver = { static struct platform_driver sdhci_brcmstb_driver = {
.driver = { .driver = {
.name = "sdhci-brcmstb", .name = "sdhci-brcmstb",
.pm = &sdhci_brcmstb_pmops, .pm = &sdhci_pltfm_pmops,
.of_match_table = of_match_ptr(sdhci_brcm_of_match), .of_match_table = of_match_ptr(sdhci_brcm_of_match),
}, },
.probe = sdhci_brcmstb_probe, .probe = sdhci_brcmstb_probe,
......
...@@ -212,18 +212,36 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister); ...@@ -212,18 +212,36 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister);
static int sdhci_pltfm_suspend(struct device *dev) static int sdhci_pltfm_suspend(struct device *dev)
{ {
struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
int ret;
if (host->tuning_mode != SDHCI_TUNING_MODE_3) if (host->tuning_mode != SDHCI_TUNING_MODE_3)
mmc_retune_needed(host->mmc); mmc_retune_needed(host->mmc);
return sdhci_suspend_host(host); ret = sdhci_suspend_host(host);
if (ret)
return ret;
clk_disable_unprepare(pltfm_host->clk);
return 0;
} }
static int sdhci_pltfm_resume(struct device *dev) static int sdhci_pltfm_resume(struct device *dev)
{ {
struct sdhci_host *host = dev_get_drvdata(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;
return sdhci_resume_host(host); ret = sdhci_resume_host(host);
if (ret)
clk_disable_unprepare(pltfm_host->clk);
return ret;
} }
#endif #endif
......
...@@ -230,43 +230,6 @@ static int sdhci_sirf_probe(struct platform_device *pdev) ...@@ -230,43 +230,6 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
return ret; return ret;
} }
#ifdef CONFIG_PM_SLEEP
static int sdhci_sirf_suspend(struct device *dev)
{
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
int ret;
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
mmc_retune_needed(host->mmc);
ret = sdhci_suspend_host(host);
if (ret)
return ret;
clk_disable(pltfm_host->clk);
return 0;
}
static int sdhci_sirf_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_enable(pltfm_host->clk);
if (ret) {
dev_dbg(dev, "Resume: Error enabling clock\n");
return ret;
}
return sdhci_resume_host(host);
}
#endif
static SIMPLE_DEV_PM_OPS(sdhci_sirf_pm_ops, sdhci_sirf_suspend, sdhci_sirf_resume);
static const struct of_device_id sdhci_sirf_of_match[] = { static const struct of_device_id sdhci_sirf_of_match[] = {
{ .compatible = "sirf,prima2-sdhc" }, { .compatible = "sirf,prima2-sdhc" },
{ } { }
...@@ -277,7 +240,7 @@ static struct platform_driver sdhci_sirf_driver = { ...@@ -277,7 +240,7 @@ static struct platform_driver sdhci_sirf_driver = {
.driver = { .driver = {
.name = "sdhci-sirf", .name = "sdhci-sirf",
.of_match_table = sdhci_sirf_of_match, .of_match_table = sdhci_sirf_of_match,
.pm = &sdhci_sirf_pm_ops, .pm = &sdhci_pltfm_pmops,
}, },
.probe = sdhci_sirf_probe, .probe = sdhci_sirf_probe,
.remove = sdhci_pltfm_unregister, .remove = sdhci_pltfm_unregister,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment