Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: sdhci-of-dwcmshc: add suspend/resume support

Add dwcmshc specific system-level suspend and resume support.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Link: https://lore.kernel.org/r/20200515141926.52e088fe@xhacker.debian
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Jisheng Zhang and committed by
Ulf Hansson
bccce2ec 554232e8

+43
+43
drivers/mmc/host/sdhci-of-dwcmshc.c
··· 163 163 return 0; 164 164 } 165 165 166 + #ifdef CONFIG_PM_SLEEP 167 + static int dwcmshc_suspend(struct device *dev) 168 + { 169 + struct sdhci_host *host = dev_get_drvdata(dev); 170 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 171 + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); 172 + int ret; 173 + 174 + ret = sdhci_suspend_host(host); 175 + if (ret) 176 + return ret; 177 + 178 + clk_disable_unprepare(pltfm_host->clk); 179 + if (!IS_ERR(priv->bus_clk)) 180 + clk_disable_unprepare(priv->bus_clk); 181 + 182 + return ret; 183 + } 184 + 185 + static int dwcmshc_resume(struct device *dev) 186 + { 187 + struct sdhci_host *host = dev_get_drvdata(dev); 188 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 189 + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); 190 + int ret; 191 + 192 + ret = clk_prepare_enable(pltfm_host->clk); 193 + if (ret) 194 + return ret; 195 + 196 + if (!IS_ERR(priv->bus_clk)) { 197 + ret = clk_prepare_enable(priv->bus_clk); 198 + if (ret) 199 + return ret; 200 + } 201 + 202 + return sdhci_resume_host(host); 203 + } 204 + #endif 205 + 206 + static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume); 207 + 166 208 static const struct of_device_id sdhci_dwcmshc_dt_ids[] = { 167 209 { .compatible = "snps,dwcmshc-sdhci" }, 168 210 {} ··· 215 173 .driver = { 216 174 .name = "sdhci-dwcmshc", 217 175 .of_match_table = sdhci_dwcmshc_dt_ids, 176 + .pm = &dwcmshc_pmops, 218 177 }, 219 178 .probe = dwcmshc_probe, 220 179 .remove = dwcmshc_remove,