static int sdhci_pm_suspend(struct device *dev) {
    int retval = 0;
    unsigned long flags;
    struct platform_device *pdev = container_of(dev, struct platform_device, dev);
    struct sdhci_host *host = platform_get_drvdata(pdev);
    struct mmc_host *mmc = host->mmc;
#ifdef CONFIG_PM_RUNTIME
    if(pm_runtime_enabled(dev))
            retval = pm_runtime_get_sync(dev);
#endif
    if(retval >= 0) {
            retval = sdhci_suspend_host(host, PMSG_SUSPEND);
            if(!retval) {
#ifdef CONFIG_MMC_HOST_WAKEUP_SUPPORTED
                if( !strcmp(host->hw_name, "Spread SDIO host1") ) {
                    sdhci_host_wakeup_set(host);
                }
#endif
                            spin_lock_irqsave(&host->lock, flags);
                            if(host->ops->set_clock)
                                host->ops->set_clock(host, 0);
                            spin_unlock_irqrestore(&host->lock, flags);
                        } else {
#ifdef CONFIG_PM_RUNTIME
                            if(pm_runtime_enabled(dev))
                                pm_runtime_put_autosuspend(dev);
#endif

            }
    }
    return retval;
}
Example #2
0
static int sdhci_pm_suspend(struct device *dev) {
    int				 retval = 0;
    struct platform_device	*pdev	= container_of(dev, struct platform_device, dev);
    struct sdhci_host		*host	= platform_get_drvdata(pdev);
    printk("%s: %s enter\n", mmc_hostname(host->mmc), __func__);
    if(is_wifi_slot(host))
      {
        printk("[WLAN] suspend read REG_AP_CLK_AP_AHB_CFG is %x\n",__raw_readl(REG_AP_CLK_AP_AHB_CFG));
	dhd_mmc_suspend = 1;
	printk("[WLAN] %s,dhd_mmc_suspend=%d\n",__func__,dhd_mmc_suspend);
      }
#ifdef CONFIG_PM_RUNTIME
    if(pm_runtime_enabled(dev))
        retval = pm_runtime_get_sync(dev);
#endif
    if(retval >= 0) {
            retval = sdhci_suspend_host(host, PMSG_SUSPEND);
            if(!retval) {
                unsigned long flags;
#ifdef CONFIG_MMC_HOST_WAKEUP_SUPPORTED
                if (pdev->id == 1)
                    sdhci_host_wakeup_set(host);
#endif
                spin_lock_irqsave(&host->lock, flags);
                if(host->ops->set_clock)
                    host->ops->set_clock(host, 0);
                spin_unlock_irqrestore(&host->lock, flags);
            } else {
#ifdef CONFIG_PM_RUNTIME
                if(pm_runtime_enabled(dev))
                    pm_runtime_put_autosuspend(dev);
#endif
            }
    }

    printk("%s: %s leave retval %d\n", mmc_hostname(host->mmc), __func__, retval);
    return retval;
}