mmc: host: sdhci-pltfm: Add suspend and resume hooks to sdhci platform
Varun Wadekar [Thu, 19 Apr 2012 13:16:40 +0000 (18:16 +0530)]
Change-Id: I062fbe91d8af14366a92af1a27e9dab49869905c
Signed-off-by: Colin Cross <ccross@android.com>

Rebase-Id: R3eb206857e57a61e445a1dd6b7efdc63ab1e0dd5

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Change-Id: I7b71b41d2f95639ac9f189a848fd0eb36602e31d
Reviewed-on: http://git-master/r/97654
Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>

drivers/mmc/host/sdhci-pltfm.c
drivers/mmc/host/sdhci.h

index c5c2a48..9bf6444 100644 (file)
@@ -205,15 +205,41 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister);
 static int sdhci_pltfm_suspend(struct device *dev)
 {
        struct sdhci_host *host = dev_get_drvdata(dev);
+       int ret;
+
+       ret = sdhci_suspend_host(host);
+       if (ret) {
+               dev_err(dev, "suspend failed, error = %d\n", ret);
+               return ret;
+       }
 
-       return sdhci_suspend_host(host);
+       if (host->ops && host->ops->suspend)
+               ret = host->ops->suspend(host);
+       if (ret) {
+               dev_err(dev, "suspend hook failed, error = %d\n", ret);
+               sdhci_resume_host(host);
+       }
+
+       return ret;
 }
 
 static int sdhci_pltfm_resume(struct device *dev)
 {
        struct sdhci_host *host = dev_get_drvdata(dev);
+       int ret = 0;
+
+       if (host->ops && host->ops->resume)
+               ret = host->ops->resume(host);
+       if (ret) {
+               dev_err(dev, "resume hook failed, error = %d\n", ret);
+               return ret;
+       }
 
-       return sdhci_resume_host(host);
+       ret = sdhci_resume_host(host);
+       if (ret)
+               dev_err(dev, "resume failed, error = %d\n", ret);
+
+       return ret;
 }
 
 const struct dev_pm_ops sdhci_pltfm_pmops = {
index 9c678cf..9e2b41e 100644 (file)
@@ -282,6 +282,8 @@ struct sdhci_ops {
        int     (*switch_signal_voltage)(struct sdhci_host *host,
                                unsigned int signal_voltage);
        int     (*execute_freq_tuning)(struct sdhci_host *sdhci);
+       int     (*suspend)(struct sdhci_host *host);
+       int     (*resume)(struct sdhci_host *host);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS