diff mbox series

[07/14] mmc: sdhci-esdhc-imx: restore the per_clk rate in PM_RUNTIME

Message ID 1573816361-26535-4-git-send-email-haibo.chen@nxp.com (mailing list archive)
State New, archived
Headers show
Series [01/14] mmc: sdhci: do not enable card detect interrupt for gpio cd type | expand

Commit Message

Bough Chen Nov. 15, 2019, 11:12 a.m. UTC
From: Haibo Chen <haibo.chen@nxp.com>

When pm_runtime_suspend is run, a call to SCFW power off the SS (SS is a
power domain, usdhc belong to this SS power domain) in which the resource
resides is made. The SCFW can power off the SS if no other resource in
active in that SS. If so, all state associated with all the resources within
the SS that is powered off is lost, this includes the clock rates, clock state
etc. When pm_runtime_resume is called, the SS associated with that resource
is powered up. But the clocks are left in the default state.

This patch restore clock rate in pm_runtime_resume, make sure the
clock is right rather than depending on the default state setting
by SCFW.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Adrian Hunter Nov. 26, 2019, 12:54 p.m. UTC | #1
On 15/11/19 1:12 PM, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> When pm_runtime_suspend is run, a call to SCFW power off the SS (SS is a
> power domain, usdhc belong to this SS power domain) in which the resource
> resides is made. The SCFW can power off the SS if no other resource in
> active in that SS. If so, all state associated with all the resources within
> the SS that is powered off is lost, this includes the clock rates, clock state
> etc. When pm_runtime_resume is called, the SS associated with that resource
> is powered up. But the clocks are left in the default state.
> 
> This patch restore clock rate in pm_runtime_resume, make sure the
> clock is right rather than depending on the default state setting
> by SCFW.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 2c8a78218c8e..448b29b2da62 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -162,6 +162,8 @@
>  #define ESDHC_FLAG_PMQOS		BIT(13)
>  /* The IP state got lost in low power mode */
>  #define ESDHC_FLAG_STATE_LOST_IN_LPMODE		BIT(14)
> +/* The IP lost clock rate in PM_RUNTIME */
> +#define ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME	BIT(15)
>  
>  struct esdhc_soc_data {
>  	u32 flags;
> @@ -225,7 +227,8 @@ static struct esdhc_soc_data usdhc_imx8qxp_data = {
>  			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
>  			| ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES
>  			| ESDHC_FLAG_CQHCI
> -			| ESDHC_FLAG_STATE_LOST_IN_LPMODE,
> +			| ESDHC_FLAG_STATE_LOST_IN_LPMODE
> +			| ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME,
>  };
>  
>  struct pltfm_imx_data {
> @@ -1711,6 +1714,9 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)
>  		pm_qos_add_request(&imx_data->pm_qos_req,
>  			PM_QOS_CPU_DMA_LATENCY, 0);
>  
> +	if (imx_data->socdata->flags & ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME)
> +		clk_set_rate(imx_data->clk_per, pltfm_host->clock);
> +
>  	err = clk_prepare_enable(imx_data->clk_ahb);
>  	if (err)
>  		goto remove_pm_qos_request;
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 2c8a78218c8e..448b29b2da62 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -162,6 +162,8 @@ 
 #define ESDHC_FLAG_PMQOS		BIT(13)
 /* The IP state got lost in low power mode */
 #define ESDHC_FLAG_STATE_LOST_IN_LPMODE		BIT(14)
+/* The IP lost clock rate in PM_RUNTIME */
+#define ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME	BIT(15)
 
 struct esdhc_soc_data {
 	u32 flags;
@@ -225,7 +227,8 @@  static struct esdhc_soc_data usdhc_imx8qxp_data = {
 			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
 			| ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES
 			| ESDHC_FLAG_CQHCI
-			| ESDHC_FLAG_STATE_LOST_IN_LPMODE,
+			| ESDHC_FLAG_STATE_LOST_IN_LPMODE
+			| ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME,
 };
 
 struct pltfm_imx_data {
@@ -1711,6 +1714,9 @@  static int sdhci_esdhc_runtime_resume(struct device *dev)
 		pm_qos_add_request(&imx_data->pm_qos_req,
 			PM_QOS_CPU_DMA_LATENCY, 0);
 
+	if (imx_data->socdata->flags & ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME)
+		clk_set_rate(imx_data->clk_per, pltfm_host->clock);
+
 	err = clk_prepare_enable(imx_data->clk_ahb);
 	if (err)
 		goto remove_pm_qos_request;