From: Ulf Hansson <ulf.hansson@linaro.org>
To: Faiz Abbas <faiz_abbas@ti.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
linux-omap <linux-omap@vger.kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>, Kishon <kishon@ti.com>,
Tony Lindgren <tony@atomide.com>
Subject: Re: [PATCH] mmc: sdhci-omap: Add Support for Suspend/Resume
Date: Wed, 19 Feb 2020 16:32:34 +0100 [thread overview]
Message-ID: <CAPDyKFqQPwugTc0GtCa=5oU1Y5s2Z=0UNiyW7KubYkZtQ_Sn9A@mail.gmail.com> (raw)
In-Reply-To: <20200218141018.24456-1-faiz_abbas@ti.com>
On Tue, 18 Feb 2020 at 15:08, Faiz Abbas <faiz_abbas@ti.com> wrote:
>
> Add power management ops which save and restore the driver context and
> facilitate a system suspend and resume.
>
> Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
> ---
> drivers/mmc/host/sdhci-omap.c | 59 +++++++++++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
> index 882053151a47..a524c01da8de 100644
> --- a/drivers/mmc/host/sdhci-omap.c
> +++ b/drivers/mmc/host/sdhci-omap.c
> @@ -108,6 +108,11 @@ struct sdhci_omap_host {
> struct pinctrl *pinctrl;
> struct pinctrl_state **pinctrl_state;
> bool is_tuning;
> + /* Omap specific context save */
> + u32 con;
> + u32 hctl;
> + u32 sysctl;
> + u32 capa;
> };
>
> static void sdhci_omap_start_clock(struct sdhci_omap_host *omap_host);
> @@ -1233,11 +1238,65 @@ static int sdhci_omap_remove(struct platform_device *pdev)
> return 0;
> }
>
> +static void sdhci_omap_context_save(struct sdhci_omap_host *omap_host)
> +{
> + omap_host->con = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON);
> + omap_host->hctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL);
> + omap_host->sysctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCTL);
> + omap_host->capa = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA);
> +}
> +
> +static void sdhci_omap_context_restore(struct sdhci_omap_host *omap_host)
> +{
> + sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, omap_host->con);
> + sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, omap_host->hctl);
> + sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCTL, omap_host->sysctl);
> + sdhci_omap_writel(omap_host, SDHCI_OMAP_CAPA, omap_host->capa);
> +}
> +
> +static int __maybe_unused sdhci_omap_suspend(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
> +
> + sdhci_suspend_host(host);
> +
> + sdhci_omap_context_save(omap_host);
> +
> + pinctrl_pm_select_idle_state(dev);
> +
> + pm_runtime_put_sync(dev);
What exactly do you want to achieve by calling pm_runtime_put_sync() here?
Restoring the usage count from the pm_runtime_get_sync() during
->probe(), makes little sense to me. This because, the PM core is
preventing the device from being runtime suspended anyway, as it calls
pm_runtime_get_noresume() in device_prepare().
Or maybe there are other reasons?
> +
> + return 0;
> +}
> +
> +static int __maybe_unused sdhci_omap_resume(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
> +
> + pm_runtime_get_sync(dev);
> +
> + pinctrl_pm_select_default_state(dev);
> +
> + sdhci_omap_context_restore(omap_host);
> +
> + sdhci_resume_host(host);
> +
> + return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(sdhci_omap_dev_pm_ops, sdhci_omap_suspend,
> + sdhci_omap_resume);
> +
> static struct platform_driver sdhci_omap_driver = {
> .probe = sdhci_omap_probe,
> .remove = sdhci_omap_remove,
> .driver = {
> .name = "sdhci-omap",
> + .pm = &sdhci_omap_dev_pm_ops,
> .of_match_table = omap_sdhci_match,
> },
> };
> --
> 2.19.2
>
Kind regards
Uffe
prev parent reply other threads:[~2020-02-19 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 14:10 [PATCH] mmc: sdhci-omap: Add Support for Suspend/Resume Faiz Abbas
2020-02-19 8:05 ` Kishon Vijay Abraham I
2020-02-19 15:32 ` Ulf Hansson [this message]
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='CAPDyKFqQPwugTc0GtCa=5oU1Y5s2Z=0UNiyW7KubYkZtQ_Sn9A@mail.gmail.com' \
--to=ulf.hansson@linaro.org \
--cc=adrian.hunter@intel.com \
--cc=faiz_abbas@ti.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).