* [PATCH v2] mmc: sdhci-of-at91: fix wake-up issue when using runtime pm
@ 2016-03-17 13:54 Ludovic Desroches
2016-03-17 14:00 ` Ulf Hansson
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Desroches @ 2016-03-17 13:54 UTC (permalink / raw)
To: ulf.hansson, adrian.hunter
Cc: linux-kernel, linux-mmc, nicolas.ferre, Ludovic Desroches
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 <ludovic.desroches@atmel.com>
---
Changes:
- v2:
- remove SDHCI_QUIRK_BROKEN_CARD_DETECTION quirk if set by the broken-cd
property.
drivers/mmc/host/sdhci-of-at91.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index 35c02fc..2703aa9 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -18,6 +18,7 @@
#include <linux/err.h>
#include <linux/io.h>
#include <linux/mmc/host.h>
+#include <linux/mmc/slot-gpio.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
@@ -204,6 +205,25 @@ static int sdhci_at91_probe(struct platform_device *pdev)
if (ret)
goto pm_runtime_disable;
+ /*
+ * When calling sdhci_runtime_suspend_host(), the sdhci layer makes
+ * the assumption that all the clocks of the controller are disabled.
+ * It means we can't get irq from it when it is runtime suspended.
+ * For that reason, it is not planned to wake-up on a card detect irq
+ * from the controller.
+ * If we want to use runtime PM and to be able to wake-up on card
+ * insertion, we have to use a GPIO for the card detection or we can
+ * use polling. Be aware that using polling will resume/suspend the
+ * controller between each attempt.
+ * Disable SDHCI_QUIRK_BROKEN_CARD_DETECTION to be sure nobody tries
+ * to enable polling via device tree with broken-cd property.
+ */
+ if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) &&
+ IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) {
+ host->mmc->caps |= MMC_CAP_NEEDS_POLL;
+ host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+ }
+
pm_runtime_put_autosuspend(&pdev->dev);
return 0;
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mmc: sdhci-of-at91: fix wake-up issue when using runtime pm
2016-03-17 13:54 [PATCH v2] mmc: sdhci-of-at91: fix wake-up issue when using runtime pm Ludovic Desroches
@ 2016-03-17 14:00 ` Ulf Hansson
2016-03-17 14:15 ` Adrian Hunter
0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2016-03-17 14:00 UTC (permalink / raw)
To: Ludovic Desroches, Adrian Hunter
Cc: linux-kernel@vger.kernel.org, linux-mmc, Nicolas Ferre
On 17 March 2016 at 14:54, Ludovic Desroches
<ludovic.desroches@atmel.com> wrote:
> 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 <ludovic.desroches@atmel.com>
I have applied this for next (4.6) so to get it tested in linux-next.
Adrian, please tell me if you have any objections then I will drop it
(or add your ack).
Thanks and kind regards
Uffe
> ---
>
> Changes:
> - v2:
> - remove SDHCI_QUIRK_BROKEN_CARD_DETECTION quirk if set by the broken-cd
> property.
>
> drivers/mmc/host/sdhci-of-at91.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index 35c02fc..2703aa9 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -18,6 +18,7 @@
> #include <linux/err.h>
> #include <linux/io.h>
> #include <linux/mmc/host.h>
> +#include <linux/mmc/slot-gpio.h>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> @@ -204,6 +205,25 @@ static int sdhci_at91_probe(struct platform_device *pdev)
> if (ret)
> goto pm_runtime_disable;
>
> + /*
> + * When calling sdhci_runtime_suspend_host(), the sdhci layer makes
> + * the assumption that all the clocks of the controller are disabled.
> + * It means we can't get irq from it when it is runtime suspended.
> + * For that reason, it is not planned to wake-up on a card detect irq
> + * from the controller.
> + * If we want to use runtime PM and to be able to wake-up on card
> + * insertion, we have to use a GPIO for the card detection or we can
> + * use polling. Be aware that using polling will resume/suspend the
> + * controller between each attempt.
> + * Disable SDHCI_QUIRK_BROKEN_CARD_DETECTION to be sure nobody tries
> + * to enable polling via device tree with broken-cd property.
> + */
> + if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) &&
> + IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) {
> + host->mmc->caps |= MMC_CAP_NEEDS_POLL;
> + host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> + }
> +
> pm_runtime_put_autosuspend(&pdev->dev);
>
> return 0;
> --
> 2.5.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mmc: sdhci-of-at91: fix wake-up issue when using runtime pm
2016-03-17 14:00 ` Ulf Hansson
@ 2016-03-17 14:15 ` Adrian Hunter
0 siblings, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2016-03-17 14:15 UTC (permalink / raw)
To: Ulf Hansson, Ludovic Desroches
Cc: linux-kernel@vger.kernel.org, linux-mmc, Nicolas Ferre
On 17/03/16 16:00, Ulf Hansson wrote:
> On 17 March 2016 at 14:54, Ludovic Desroches
> <ludovic.desroches@atmel.com> wrote:
>> 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 <ludovic.desroches@atmel.com>
>
> I have applied this for next (4.6) so to get it tested in linux-next.
>
> Adrian, please tell me if you have any objections then I will drop it
> (or add your ack).
It is fine by me.
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>
> Thanks and kind regards
> Uffe
>
>> ---
>>
>> Changes:
>> - v2:
>> - remove SDHCI_QUIRK_BROKEN_CARD_DETECTION quirk if set by the broken-cd
>> property.
>>
>> drivers/mmc/host/sdhci-of-at91.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>>
>> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
>> index 35c02fc..2703aa9 100644
>> --- a/drivers/mmc/host/sdhci-of-at91.c
>> +++ b/drivers/mmc/host/sdhci-of-at91.c
>> @@ -18,6 +18,7 @@
>> #include <linux/err.h>
>> #include <linux/io.h>
>> #include <linux/mmc/host.h>
>> +#include <linux/mmc/slot-gpio.h>
>> #include <linux/module.h>
>> #include <linux/of.h>
>> #include <linux/of_device.h>
>> @@ -204,6 +205,25 @@ static int sdhci_at91_probe(struct platform_device *pdev)
>> if (ret)
>> goto pm_runtime_disable;
>>
>> + /*
>> + * When calling sdhci_runtime_suspend_host(), the sdhci layer makes
>> + * the assumption that all the clocks of the controller are disabled.
>> + * It means we can't get irq from it when it is runtime suspended.
>> + * For that reason, it is not planned to wake-up on a card detect irq
>> + * from the controller.
>> + * If we want to use runtime PM and to be able to wake-up on card
>> + * insertion, we have to use a GPIO for the card detection or we can
>> + * use polling. Be aware that using polling will resume/suspend the
>> + * controller between each attempt.
>> + * Disable SDHCI_QUIRK_BROKEN_CARD_DETECTION to be sure nobody tries
>> + * to enable polling via device tree with broken-cd property.
>> + */
>> + if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) &&
>> + IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) {
>> + host->mmc->caps |= MMC_CAP_NEEDS_POLL;
>> + host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
>> + }
>> +
>> pm_runtime_put_autosuspend(&pdev->dev);
>>
>> return 0;
>> --
>> 2.5.0
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-17 14:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-17 13:54 [PATCH v2] mmc: sdhci-of-at91: fix wake-up issue when using runtime pm Ludovic Desroches
2016-03-17 14:00 ` Ulf Hansson
2016-03-17 14:15 ` Adrian Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).