Skip to content

Commit f5a1c43

Browse files
committed
mmc: sdhci-of-at91: fix wake-up issue when using runtime pm
It is impossible to wake-up on card detect event because when sdhci controller is runtime suspended, it is assumed that all clocks are disabled so we can't get irqs. If the device is removable and there is no gpio to manage the card detection then polling is used. It doesn't mean card detection is broken. It is curently we only way to wake-up on card event if using runtime pm. Signed-off-by: Ludovic Desroches <[email protected]> Acked-by: Adrian Hunter <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 705b365 commit f5a1c43

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/mmc/host/sdhci-of-at91.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/err.h>
1919
#include <linux/io.h>
2020
#include <linux/mmc/host.h>
21+
#include <linux/mmc/slot-gpio.h>
2122
#include <linux/module.h>
2223
#include <linux/of.h>
2324
#include <linux/of_device.h>
@@ -204,6 +205,25 @@ static int sdhci_at91_probe(struct platform_device *pdev)
204205
if (ret)
205206
goto pm_runtime_disable;
206207

208+
/*
209+
* When calling sdhci_runtime_suspend_host(), the sdhci layer makes
210+
* the assumption that all the clocks of the controller are disabled.
211+
* It means we can't get irq from it when it is runtime suspended.
212+
* For that reason, it is not planned to wake-up on a card detect irq
213+
* from the controller.
214+
* If we want to use runtime PM and to be able to wake-up on card
215+
* insertion, we have to use a GPIO for the card detection or we can
216+
* use polling. Be aware that using polling will resume/suspend the
217+
* controller between each attempt.
218+
* Disable SDHCI_QUIRK_BROKEN_CARD_DETECTION to be sure nobody tries
219+
* to enable polling via device tree with broken-cd property.
220+
*/
221+
if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) &&
222+
IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) {
223+
host->mmc->caps |= MMC_CAP_NEEDS_POLL;
224+
host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
225+
}
226+
207227
pm_runtime_put_autosuspend(&pdev->dev);
208228

209229
return 0;

0 commit comments

Comments
 (0)