clk: qcom: dispcc-sm8250: use runtime PM for the clock controller
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sun, 29 Aug 2021 15:47:52 +0000 (18:47 +0300)
committerStephen Boyd <sboyd@kernel.org>
Fri, 15 Oct 2021 00:50:48 +0000 (17:50 -0700)
On sm8250 dispcc and videocc registers are powered up by the MMCX power
domain. Use runtime PM calls to make sure that required power domain is
powered on while we access clock controller's registers.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20210829154757.784699-4-dmitry.baryshkov@linaro.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/qcom/dispcc-sm8250.c

index bf9ffe1a1cf47b1812cdb27785cc21b31efa4023..566fdfa0a15bb2f92b27b4269e1d4e6c2b65fc74 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/clk-provider.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/reset-controller.h>
 
@@ -1228,13 +1229,31 @@ static const struct of_device_id disp_cc_sm8250_match_table[] = {
 };
 MODULE_DEVICE_TABLE(of, disp_cc_sm8250_match_table);
 
+static void disp_cc_sm8250_pm_runtime_disable(void *data)
+{
+       pm_runtime_disable(data);
+}
+
 static int disp_cc_sm8250_probe(struct platform_device *pdev)
 {
        struct regmap *regmap;
+       int ret;
+
+       pm_runtime_enable(&pdev->dev);
+
+       ret = devm_add_action_or_reset(&pdev->dev, disp_cc_sm8250_pm_runtime_disable, &pdev->dev);
+       if (ret)
+               return ret;
+
+       ret = pm_runtime_resume_and_get(&pdev->dev);
+       if (ret)
+               return ret;
 
        regmap = qcom_cc_map(pdev, &disp_cc_sm8250_desc);
-       if (IS_ERR(regmap))
+       if (IS_ERR(regmap)) {
+               pm_runtime_put(&pdev->dev);
                return PTR_ERR(regmap);
+       }
 
        /* note: trion == lucid, except for the prepare() op */
        BUILD_BUG_ON(CLK_ALPHA_PLL_TYPE_TRION != CLK_ALPHA_PLL_TYPE_LUCID);
@@ -1259,7 +1278,11 @@ static int disp_cc_sm8250_probe(struct platform_device *pdev)
        /* DISP_CC_XO_CLK always-on */
        regmap_update_bits(regmap, 0x605c, BIT(0), BIT(0));
 
-       return qcom_cc_really_probe(pdev, &disp_cc_sm8250_desc, regmap);
+       ret = qcom_cc_really_probe(pdev, &disp_cc_sm8250_desc, regmap);
+
+       pm_runtime_put(&pdev->dev);
+
+       return ret;
 }
 
 static struct platform_driver disp_cc_sm8250_driver = {