Skip to content

Commit f614046

Browse files
Haibo Chenstorulf
authored andcommitted
mmc: host: sdhci-esdhc-imx: add wakeup feature for GPIO CD pin
When use the specific GPIO to detect the card insert/remove, we can also add the GPIO as a wakeup source. When system suspend, insert or remove the card can wakeup the system. Signed-off-by: Haibo Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 942d5e7 commit f614046

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
15991599
if (esdhc_is_usdhc(imx_data)) {
16001600
host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN;
16011601
host->mmc->caps |= MMC_CAP_1_8V_DDR | MMC_CAP_3_3V_DDR;
1602+
1603+
/* GPIO CD can be set as a wakeup source */
1604+
host->mmc->caps |= MMC_CAP_CD_WAKE;
1605+
16021606
if (!(imx_data->socdata->flags & ESDHC_FLAG_HS200))
16031607
host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;
16041608

@@ -1734,8 +1738,14 @@ static int sdhci_esdhc_suspend(struct device *dev)
17341738
mmc_retune_needed(host->mmc);
17351739

17361740
ret = sdhci_suspend_host(host);
1737-
if (!ret)
1738-
return pinctrl_pm_select_sleep_state(dev);
1741+
if (ret)
1742+
return ret;
1743+
1744+
ret = pinctrl_pm_select_sleep_state(dev);
1745+
if (ret)
1746+
return ret;
1747+
1748+
ret = mmc_gpio_set_cd_wake(host->mmc, true);
17391749

17401750
return ret;
17411751
}
@@ -1759,6 +1769,9 @@ static int sdhci_esdhc_resume(struct device *dev)
17591769
if (host->mmc->caps2 & MMC_CAP2_CQE)
17601770
ret = cqhci_resume(host->mmc);
17611771

1772+
if (!ret)
1773+
ret = mmc_gpio_set_cd_wake(host->mmc, false);
1774+
17621775
return ret;
17631776
}
17641777
#endif

0 commit comments

Comments
 (0)