drm/msm/mdp4: use bulk regulators API for LCDC encoder
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sat, 8 Jul 2023 01:04:01 +0000 (04:04 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sun, 3 Dec 2023 00:13:05 +0000 (03:13 +0300)
Switch mdp4_lcdc_encoder to using regulator_bulk_* API instead of
enumerating regulators by hand.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/546173/
Link: https://lore.kernel.org/r/20230708010407.3871346-12-dmitry.baryshkov@linaro.org
drivers/gpu/drm/msm/disp/mdp4/mdp4_lcdc_encoder.c

index 10eb3e5..67c118b 100644 (file)
@@ -18,7 +18,7 @@ struct mdp4_lcdc_encoder {
        struct drm_panel *panel;
        struct clk *lcdc_clk;
        unsigned long int pixclock;
-       struct regulator *regs[3];
+       struct regulator_bulk_data regs[3];
        bool enabled;
        uint32_t bsc;
 };
@@ -271,12 +271,10 @@ static void mdp4_lcdc_encoder_mode_set(struct drm_encoder *encoder,
 
 static void mdp4_lcdc_encoder_disable(struct drm_encoder *encoder)
 {
-       struct drm_device *dev = encoder->dev;
        struct mdp4_lcdc_encoder *mdp4_lcdc_encoder =
                        to_mdp4_lcdc_encoder(encoder);
        struct mdp4_kms *mdp4_kms = get_kms(encoder);
        struct drm_panel *panel;
-       int i, ret;
 
        if (WARN_ON(!mdp4_lcdc_encoder->enabled))
                return;
@@ -301,11 +299,8 @@ static void mdp4_lcdc_encoder_disable(struct drm_encoder *encoder)
 
        clk_disable_unprepare(mdp4_lcdc_encoder->lcdc_clk);
 
-       for (i = 0; i < ARRAY_SIZE(mdp4_lcdc_encoder->regs); i++) {
-               ret = regulator_disable(mdp4_lcdc_encoder->regs[i]);
-               if (ret)
-                       DRM_DEV_ERROR(dev->dev, "failed to disable regulator: %d\n", ret);
-       }
+       regulator_bulk_disable(ARRAY_SIZE(mdp4_lcdc_encoder->regs),
+                              mdp4_lcdc_encoder->regs);
 
        mdp4_lcdc_encoder->enabled = false;
 }
@@ -319,7 +314,7 @@ static void mdp4_lcdc_encoder_enable(struct drm_encoder *encoder)
        struct mdp4_kms *mdp4_kms = get_kms(encoder);
        struct drm_panel *panel;
        uint32_t config;
-       int i, ret;
+       int ret;
 
        if (WARN_ON(mdp4_lcdc_encoder->enabled))
                return;
@@ -339,11 +334,10 @@ static void mdp4_lcdc_encoder_enable(struct drm_encoder *encoder)
        mdp4_crtc_set_config(encoder->crtc, config);
        mdp4_crtc_set_intf(encoder->crtc, INTF_LCDC_DTV, 0);
 
-       for (i = 0; i < ARRAY_SIZE(mdp4_lcdc_encoder->regs); i++) {
-               ret = regulator_enable(mdp4_lcdc_encoder->regs[i]);
-               if (ret)
-                       DRM_DEV_ERROR(dev->dev, "failed to enable regulator: %d\n", ret);
-       }
+       ret = regulator_bulk_enable(ARRAY_SIZE(mdp4_lcdc_encoder->regs),
+                                   mdp4_lcdc_encoder->regs);
+       if (ret)
+               DRM_DEV_ERROR(dev->dev, "failed to enable regulators: %d\n", ret);
 
        DBG("setting lcdc_clk=%lu", pc);
        ret = clk_set_rate(mdp4_lcdc_encoder->lcdc_clk, pc);
@@ -385,7 +379,6 @@ struct drm_encoder *mdp4_lcdc_encoder_init(struct drm_device *dev,
 {
        struct drm_encoder *encoder = NULL;
        struct mdp4_lcdc_encoder *mdp4_lcdc_encoder;
-       struct regulator *reg;
        int ret;
 
        mdp4_lcdc_encoder = kzalloc(sizeof(*mdp4_lcdc_encoder), GFP_KERNEL);
@@ -411,29 +404,15 @@ struct drm_encoder *mdp4_lcdc_encoder_init(struct drm_device *dev,
        }
 
        /* TODO: different regulators in other cases? */
-       reg = devm_regulator_get(dev->dev, "lvds-vccs-3p3v");
-       if (IS_ERR(reg)) {
-               ret = PTR_ERR(reg);
-               DRM_DEV_ERROR(dev->dev, "failed to get lvds-vccs-3p3v: %d\n", ret);
-               goto fail;
-       }
-       mdp4_lcdc_encoder->regs[0] = reg;
-
-       reg = devm_regulator_get(dev->dev, "lvds-pll-vdda");
-       if (IS_ERR(reg)) {
-               ret = PTR_ERR(reg);
-               DRM_DEV_ERROR(dev->dev, "failed to get lvds-pll-vdda: %d\n", ret);
-               goto fail;
-       }
-       mdp4_lcdc_encoder->regs[1] = reg;
+       mdp4_lcdc_encoder->regs[0].supply = "lvds-vccs-3p3v";
+       mdp4_lcdc_encoder->regs[1].supply = "lvds-vccs-3p3v";
+       mdp4_lcdc_encoder->regs[2].supply = "lvds-vdda";
 
-       reg = devm_regulator_get(dev->dev, "lvds-vdda");
-       if (IS_ERR(reg)) {
-               ret = PTR_ERR(reg);
-               DRM_DEV_ERROR(dev->dev, "failed to get lvds-vdda: %d\n", ret);
+       ret = devm_regulator_bulk_get(dev->dev,
+                                     ARRAY_SIZE(mdp4_lcdc_encoder->regs),
+                                     mdp4_lcdc_encoder->regs);
+       if (ret)
                goto fail;
-       }
-       mdp4_lcdc_encoder->regs[2] = reg;
 
        return encoder;