linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Tony Lindgren <tony@atomide.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	Chunyan Zhang <zhang.chunyan@linaro.org>,
	Faiz Abbas <faiz_abbas@ti.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	linux-omap <linux-omap@vger.kernel.org>,
	Rob Herring <robh@kernel.org>, DTML <devicetree@vger.kernel.org>
Subject: Re: [PATCH 6/6] mmc: sdhci-omap: Configure optional wakeirq
Date: Tue, 12 Oct 2021 17:02:13 +0200	[thread overview]
Message-ID: <CAPDyKFqXsTCTmqggiN3iDXTu=fZwCwDbFVacN=FLasQVTgFB-g@mail.gmail.com> (raw)
In-Reply-To: <20211012103750.38328-7-tony@atomide.com>

On Tue, 12 Oct 2021 at 12:38, Tony Lindgren <tony@atomide.com> wrote:
>
> Configure optional wakeirq. This may be optionally configured for SDIO
> dat1 pin for wake-up events for SoCs that support deeper idle states.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/mmc/host/sdhci-omap.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
> --- a/drivers/mmc/host/sdhci-omap.c
> +++ b/drivers/mmc/host/sdhci-omap.c
> @@ -12,8 +12,10 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> +#include <linux/of_irq.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/sys_soc.h>
> @@ -117,6 +119,7 @@ struct sdhci_omap_host {
>
>         struct pinctrl          *pinctrl;
>         struct pinctrl_state    **pinctrl_state;
> +       int                     wakeirq;
>         bool                    is_tuning;
>
>         /* Offset for omap specific registers from base */
> @@ -1360,6 +1363,25 @@ static int sdhci_omap_probe(struct platform_device *pdev)
>
>         sdhci_omap_context_save(omap_host);
>
> +       /*
> +        * SDIO devices can use the dat1 pin as a wake-up interrupt. Some
> +        * devices like wl1xxx, use an out-of-band GPIO interrupt instead.
> +        */

Ah, right I recall this now. Very clever.

> +       omap_host->wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
> +       if (omap_host->wakeirq == -EPROBE_DEFER) {
> +               ret = -EPROBE_DEFER;
> +               goto err_cleanup_host;
> +       }
> +       if (omap_host->wakeirq > 0) {
> +               device_init_wakeup(dev, true);
> +               ret = dev_pm_set_dedicated_wake_irq(dev, omap_host->wakeirq);
> +               if (ret) {
> +                       device_init_wakeup(dev, false);
> +                       goto err_cleanup_host;
> +               }
> +               host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;

To prevent the mmc core from powering off the SDIO card in system
suspend (which certainly must be prevented if wakeups should be
delivered), you need to set MMC_PM_KEEP_POWER, too.

FYI: We also have common mmc DT properties for these caps, which are
being parsed in mmc_of_parse().

These are the DT properties:
"keep-power-in-suspend" - > MMC_PM_KEEP_POWER
"wakeup-source" || "enable-sdio-wakeup" (/* legacy */) -> MMC_PM_WAKE_SDIO_IRQ;

> +       }
> +
>         pm_runtime_mark_last_busy(dev);
>         pm_runtime_put_autosuspend(dev);
>
> @@ -1387,6 +1409,8 @@ static int sdhci_omap_remove(struct platform_device *pdev)
>
>         pm_runtime_get_sync(dev);
>         sdhci_remove_host(host, true);
> +       device_init_wakeup(dev, false);
> +       dev_pm_clear_wake_irq(dev);
>         pm_runtime_dont_use_autosuspend(dev);
>         pm_runtime_put_sync(dev);
>         /* Ensure device gets idled despite userspace sysfs config */
> --
> 2.33.0

I now think I better understand what is needed during system
suspend/resume to support system wakeups. I will comment on patch 4,
let's see what that brings us to.

Kind regards
Uffe

  reply	other threads:[~2021-10-12 15:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 10:37 [PATCHv3 0/6] More SoCs for sdhci-omap to deprecate omap_hsmmc Tony Lindgren
2021-10-12 10:37 ` [PATCH 1/6] dt-bindings: sdhci-omap: Update binding for legacy SoCs Tony Lindgren
2021-10-12 10:37 ` [PATCH 2/6] mmc: sdhci-omap: Handle voltages to add support omap4 Tony Lindgren
2021-10-12 14:16   ` kernel test robot
2021-10-12 10:37 ` [PATCH 3/6] mmc: sdhci-omap: Add omap_offset to support omap3 and earlier Tony Lindgren
2021-10-12 10:37 ` [PATCH 4/6] mmc: sdhci-omap: Implement PM runtime functions Tony Lindgren
2021-10-12 15:11   ` kernel test robot
2021-10-12 15:16   ` Ulf Hansson
2021-10-15  9:34     ` Tony Lindgren
2021-10-12 10:37 ` [PATCH 5/6] sdhci: omap: Enable aggressive PM Tony Lindgren
2021-10-12 14:14   ` Ulf Hansson
2021-10-12 10:37 ` [PATCH 6/6] mmc: sdhci-omap: Configure optional wakeirq Tony Lindgren
2021-10-12 15:02   ` Ulf Hansson [this message]
2021-10-15 10:47 [PATCHv4 0/6] More SoCs for sdhci-omap to deprecate omap_hsmmc Tony Lindgren
2021-10-15 10:47 ` [PATCH 6/6] mmc: sdhci-omap: Configure optional wakeirq Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPDyKFqXsTCTmqggiN3iDXTu=fZwCwDbFVacN=FLasQVTgFB-g@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=faiz_abbas@ti.com \
    --cc=kishon@ti.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=ssantosh@kernel.org \
    --cc=tony@atomide.com \
    --cc=zhang.chunyan@linaro.org \
    --subject='Re: [PATCH 6/6] mmc: sdhci-omap: Configure optional wakeirq' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).