Skip to content

Commit 1ab0d2d

Browse files
masahir0ystorulf
authored andcommitted
mmc: sdhci: enable/disable the clock in sdhci_pltfm_suspend/resume
This commit provides similar cleanups as commit 83eacdf ("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: Masahiro Yamada <[email protected]> Acked-by: Adrian Hunter <[email protected]> Acked-by: Al Cooper <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 3fd1d86 commit 1ab0d2d

File tree

3 files changed

+22
-76
lines changed

3 files changed

+22
-76
lines changed

drivers/mmc/host/sdhci-brcmstb.c

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,6 @@
2121

2222
#include "sdhci-pltfm.h"
2323

24-
#ifdef CONFIG_PM_SLEEP
25-
26-
static int sdhci_brcmstb_suspend(struct device *dev)
27-
{
28-
struct sdhci_host *host = dev_get_drvdata(dev);
29-
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
30-
int res;
31-
32-
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
33-
mmc_retune_needed(host->mmc);
34-
35-
res = sdhci_suspend_host(host);
36-
if (res)
37-
return res;
38-
clk_disable_unprepare(pltfm_host->clk);
39-
return res;
40-
}
41-
42-
static int sdhci_brcmstb_resume(struct device *dev)
43-
{
44-
struct sdhci_host *host = dev_get_drvdata(dev);
45-
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
46-
int err;
47-
48-
err = clk_prepare_enable(pltfm_host->clk);
49-
if (err)
50-
return err;
51-
return sdhci_resume_host(host);
52-
}
53-
54-
#endif /* CONFIG_PM_SLEEP */
55-
56-
static SIMPLE_DEV_PM_OPS(sdhci_brcmstb_pmops, sdhci_brcmstb_suspend,
57-
sdhci_brcmstb_resume);
58-
5924
static const struct sdhci_ops sdhci_brcmstb_ops = {
6025
.set_clock = sdhci_set_clock,
6126
.set_bus_width = sdhci_set_bus_width,
@@ -131,7 +96,7 @@ MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match);
13196
static struct platform_driver sdhci_brcmstb_driver = {
13297
.driver = {
13398
.name = "sdhci-brcmstb",
134-
.pm = &sdhci_brcmstb_pmops,
99+
.pm = &sdhci_pltfm_pmops,
135100
.of_match_table = of_match_ptr(sdhci_brcm_of_match),
136101
},
137102
.probe = sdhci_brcmstb_probe,

drivers/mmc/host/sdhci-pltfm.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,36 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister);
212212
static int sdhci_pltfm_suspend(struct device *dev)
213213
{
214214
struct sdhci_host *host = dev_get_drvdata(dev);
215+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
216+
int ret;
215217

216218
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
217219
mmc_retune_needed(host->mmc);
218220

219-
return sdhci_suspend_host(host);
221+
ret = sdhci_suspend_host(host);
222+
if (ret)
223+
return ret;
224+
225+
clk_disable_unprepare(pltfm_host->clk);
226+
227+
return 0;
220228
}
221229

222230
static int sdhci_pltfm_resume(struct device *dev)
223231
{
224232
struct sdhci_host *host = dev_get_drvdata(dev);
233+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
234+
int ret;
235+
236+
ret = clk_prepare_enable(pltfm_host->clk);
237+
if (ret)
238+
return ret;
225239

226-
return sdhci_resume_host(host);
240+
ret = sdhci_resume_host(host);
241+
if (ret)
242+
clk_disable_unprepare(pltfm_host->clk);
243+
244+
return ret;
227245
}
228246
#endif
229247

drivers/mmc/host/sdhci-sirf.c

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -230,43 +230,6 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
230230
return ret;
231231
}
232232

233-
#ifdef CONFIG_PM_SLEEP
234-
static int sdhci_sirf_suspend(struct device *dev)
235-
{
236-
struct sdhci_host *host = dev_get_drvdata(dev);
237-
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
238-
int ret;
239-
240-
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
241-
mmc_retune_needed(host->mmc);
242-
243-
ret = sdhci_suspend_host(host);
244-
if (ret)
245-
return ret;
246-
247-
clk_disable(pltfm_host->clk);
248-
249-
return 0;
250-
}
251-
252-
static int sdhci_sirf_resume(struct device *dev)
253-
{
254-
struct sdhci_host *host = dev_get_drvdata(dev);
255-
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
256-
int ret;
257-
258-
ret = clk_enable(pltfm_host->clk);
259-
if (ret) {
260-
dev_dbg(dev, "Resume: Error enabling clock\n");
261-
return ret;
262-
}
263-
264-
return sdhci_resume_host(host);
265-
}
266-
#endif
267-
268-
static SIMPLE_DEV_PM_OPS(sdhci_sirf_pm_ops, sdhci_sirf_suspend, sdhci_sirf_resume);
269-
270233
static const struct of_device_id sdhci_sirf_of_match[] = {
271234
{ .compatible = "sirf,prima2-sdhc" },
272235
{ }
@@ -277,7 +240,7 @@ static struct platform_driver sdhci_sirf_driver = {
277240
.driver = {
278241
.name = "sdhci-sirf",
279242
.of_match_table = sdhci_sirf_of_match,
280-
.pm = &sdhci_sirf_pm_ops,
243+
.pm = &sdhci_pltfm_pmops,
281244
},
282245
.probe = sdhci_sirf_probe,
283246
.remove = sdhci_pltfm_unregister,

0 commit comments

Comments
 (0)