mmc: sdhci-brcmstb: use clk_get_rate(base_clk) in PM resume
authorKamal Dasu <kdasu.kdev@gmail.com>
Thu, 14 Jul 2022 17:41:32 +0000 (13:41 -0400)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 18 Jul 2022 11:32:47 +0000 (13:32 +0200)
Use clk_get_rate for base_clk on resume before setting new rate.
This change ensures that the clock api returns current rate
and sets the clock to the desired rate and honors CLK_GET_NO_CACHE
attribute used by clock api.

Fixes: 97904a59855c (mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0)
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220714174132.18541-1-kdasu.kdev@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-brcmstb.c

index 28e9cf9..aff36a9 100644 (file)
@@ -406,7 +406,14 @@ static int sdhci_brcmstb_resume(struct device *dev)
        ret = sdhci_pltfm_resume(dev);
        if (!ret && priv->base_freq_hz) {
                ret = clk_prepare_enable(priv->base_clk);
-               if (!ret)
+               /*
+                * Note: using clk_get_rate() below as clk_get_rate()
+                * honors CLK_GET_RATE_NOCACHE attribute, but clk_set_rate()
+                * may do implicit get_rate() calls that do not honor
+                * CLK_GET_RATE_NOCACHE.
+                */
+               if (!ret &&
+                   (clk_get_rate(priv->base_clk) != priv->base_freq_hz))
                        ret = clk_set_rate(priv->base_clk, priv->base_freq_hz);
        }