linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: abhinavk@codeaurora.org
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
	Jonathan Marek <jonathan@marek.ca>,
	Stephen Boyd <sboyd@kernel.org>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>,
	linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
	freedreno@lists.freedesktop.org
Subject: Re: [Freedreno] [PATCH 1/2] drm/msm/hdmi: use bulk regulator API
Date: Fri, 15 Oct 2021 15:16:44 -0700	[thread overview]
Message-ID: <b4ad0b7f370964da16c282c5fe99d7fd@codeaurora.org> (raw)
In-Reply-To: <20211015001100.4193241-1-dmitry.baryshkov@linaro.org>

On 2021-10-14 17:10, Dmitry Baryshkov wrote:
> Switch to using bulk regulator API instead of hand coding loops.
> 
Nice cleanup!

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Reviewed-by: Abhinav Kumar <abhinavk@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/hdmi/hdmi.c           | 34 +++++++----------------
>  drivers/gpu/drm/msm/hdmi/hdmi.h           |  6 ++--
>  drivers/gpu/drm/msm/hdmi/hdmi_bridge.c    | 20 ++++---------
>  drivers/gpu/drm/msm/hdmi/hdmi_connector.c | 24 ++++++----------
>  drivers/gpu/drm/msm/hdmi/hdmi_phy.c       | 33 ++++++++--------------
>  5 files changed, 40 insertions(+), 77 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c 
> b/drivers/gpu/drm/msm/hdmi/hdmi.c
> index 737453b6e596..db17a000d968 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
> @@ -154,19 +154,13 @@ static struct hdmi *msm_hdmi_init(struct
> platform_device *pdev)
>  		ret = -ENOMEM;
>  		goto fail;
>  	}
> -	for (i = 0; i < config->hpd_reg_cnt; i++) {
> -		struct regulator *reg;
> -
> -		reg = devm_regulator_get(&pdev->dev,
> -				config->hpd_reg_names[i]);
> -		if (IS_ERR(reg)) {
> -			ret = PTR_ERR(reg);
> -			DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %s (%d)\n",
> -					config->hpd_reg_names[i], ret);
> -			goto fail;
> -		}
> +	for (i = 0; i < config->hpd_reg_cnt; i++)
> +		hdmi->hpd_regs[i].supply = config->hpd_reg_names[i];
> 
> -		hdmi->hpd_regs[i] = reg;
> +	ret = devm_regulator_bulk_get(&pdev->dev, config->hpd_reg_cnt,
> hdmi->hpd_regs);
> +	if (ret) {
> +		DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %d\n", ret);
> +		goto fail;
>  	}
> 
>  	hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
> @@ -177,19 +171,11 @@ static struct hdmi *msm_hdmi_init(struct
> platform_device *pdev)
>  		ret = -ENOMEM;
>  		goto fail;
>  	}
> -	for (i = 0; i < config->pwr_reg_cnt; i++) {
> -		struct regulator *reg;
> 
> -		reg = devm_regulator_get(&pdev->dev,
> -				config->pwr_reg_names[i]);
> -		if (IS_ERR(reg)) {
> -			ret = PTR_ERR(reg);
> -			DRM_DEV_ERROR(&pdev->dev, "failed to get pwr regulator: %s (%d)\n",
> -					config->pwr_reg_names[i], ret);
> -			goto fail;
> -		}
> -
> -		hdmi->pwr_regs[i] = reg;
> +	ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt,
> hdmi->pwr_regs);
> +	if (ret) {
> +		DRM_DEV_ERROR(&pdev->dev, "failed to get pwr regulator: %d\n", ret);
> +		goto fail;
>  	}
> 
>  	hdmi->hpd_clks = devm_kcalloc(&pdev->dev,
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h 
> b/drivers/gpu/drm/msm/hdmi/hdmi.h
> index d0b84f0abee1..82261078c6b1 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi.h
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi.h
> @@ -56,8 +56,8 @@ struct hdmi {
>  	void __iomem *qfprom_mmio;
>  	phys_addr_t mmio_phy_addr;
> 
> -	struct regulator **hpd_regs;
> -	struct regulator **pwr_regs;
> +	struct regulator_bulk_data *hpd_regs;
> +	struct regulator_bulk_data *pwr_regs;
>  	struct clk **hpd_clks;
>  	struct clk **pwr_clks;
> 
> @@ -163,7 +163,7 @@ struct hdmi_phy {
>  	void __iomem *mmio;
>  	struct hdmi_phy_cfg *cfg;
>  	const struct hdmi_phy_funcs *funcs;
> -	struct regulator **regs;
> +	struct regulator_bulk_data *regs;
>  	struct clk **clks;
>  };
> 
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
> b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
> index 6e380db9287b..f04eb4a70f0d 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
> @@ -28,13 +28,9 @@ static void msm_hdmi_power_on(struct drm_bridge 
> *bridge)
> 
>  	pm_runtime_get_sync(&hdmi->pdev->dev);
> 
> -	for (i = 0; i < config->pwr_reg_cnt; i++) {
> -		ret = regulator_enable(hdmi->pwr_regs[i]);
> -		if (ret) {
> -			DRM_DEV_ERROR(dev->dev, "failed to enable pwr regulator: %s 
> (%d)\n",
> -					config->pwr_reg_names[i], ret);
> -		}
> -	}
> +	ret = regulator_bulk_enable(config->pwr_reg_cnt, hdmi->pwr_regs);
> +	if (ret)
> +		DRM_DEV_ERROR(dev->dev, "failed to enable pwr regulator: %d\n", 
> ret);
> 
>  	if (config->pwr_clk_cnt > 0) {
>  		DBG("pixclock: %lu", hdmi->pixclock);
> @@ -70,13 +66,9 @@ static void power_off(struct drm_bridge *bridge)
>  	for (i = 0; i < config->pwr_clk_cnt; i++)
>  		clk_disable_unprepare(hdmi->pwr_clks[i]);
> 
> -	for (i = 0; i < config->pwr_reg_cnt; i++) {
> -		ret = regulator_disable(hdmi->pwr_regs[i]);
> -		if (ret) {
> -			DRM_DEV_ERROR(dev->dev, "failed to disable pwr regulator: %s 
> (%d)\n",
> -					config->pwr_reg_names[i], ret);
> -		}
> -	}
> +	ret = regulator_bulk_disable(config->pwr_reg_cnt, hdmi->pwr_regs);
> +	if (ret)
> +		DRM_DEV_ERROR(dev->dev, "failed to disable pwr regulator: %d\n", 
> ret);
> 
>  	pm_runtime_put_autosuspend(&hdmi->pdev->dev);
>  }
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
> b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
> index 58707a1f3878..a7f729cdec7b 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
> @@ -146,16 +146,13 @@ int msm_hdmi_hpd_enable(struct drm_connector 
> *connector)
>  	const struct hdmi_platform_config *config = hdmi->config;
>  	struct device *dev = &hdmi->pdev->dev;
>  	uint32_t hpd_ctrl;
> -	int i, ret;
> +	int ret;
>  	unsigned long flags;
> 
> -	for (i = 0; i < config->hpd_reg_cnt; i++) {
> -		ret = regulator_enable(hdmi->hpd_regs[i]);
> -		if (ret) {
> -			DRM_DEV_ERROR(dev, "failed to enable hpd regulator: %s (%d)\n",
> -					config->hpd_reg_names[i], ret);
> -			goto fail;
> -		}
> +	ret = regulator_bulk_enable(config->hpd_reg_cnt, hdmi->hpd_regs);
> +	if (ret) {
> +		DRM_DEV_ERROR(dev, "failed to enable hpd regulators: %d\n", ret);
> +		goto fail;
>  	}
> 
>  	ret = pinctrl_pm_select_default_state(dev);
> @@ -207,7 +204,7 @@ static void hdp_disable(struct hdmi_connector
> *hdmi_connector)
>  	struct hdmi *hdmi = hdmi_connector->hdmi;
>  	const struct hdmi_platform_config *config = hdmi->config;
>  	struct device *dev = &hdmi->pdev->dev;
> -	int i, ret = 0;
> +	int ret;
> 
>  	/* Disable HPD interrupt */
>  	hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0);
> @@ -225,12 +222,9 @@ static void hdp_disable(struct hdmi_connector
> *hdmi_connector)
>  	if (ret)
>  		dev_warn(dev, "pinctrl state chg failed: %d\n", ret);
> 
> -	for (i = 0; i < config->hpd_reg_cnt; i++) {
> -		ret = regulator_disable(hdmi->hpd_regs[i]);
> -		if (ret)
> -			dev_warn(dev, "failed to disable hpd regulator: %s (%d)\n",
> -					config->hpd_reg_names[i], ret);
> -	}
> +	ret = regulator_bulk_disable(config->hpd_reg_cnt, hdmi->hpd_regs);
> +	if (ret)
> +		dev_warn(dev, "failed to disable hpd regulator: %d\n", ret);
>  }
> 
>  static void
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_phy.c
> b/drivers/gpu/drm/msm/hdmi/hdmi_phy.c
> index 8a38d4b95102..16b0e8836d27 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi_phy.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi_phy.c
> @@ -23,22 +23,15 @@ static int msm_hdmi_phy_resource_init(struct 
> hdmi_phy *phy)
>  	if (!phy->clks)
>  		return -ENOMEM;
> 
> -	for (i = 0; i < cfg->num_regs; i++) {
> -		struct regulator *reg;
> -
> -		reg = devm_regulator_get(dev, cfg->reg_names[i]);
> -		if (IS_ERR(reg)) {
> -			ret = PTR_ERR(reg);
> -			if (ret != -EPROBE_DEFER) {
> -				DRM_DEV_ERROR(dev,
> -					      "failed to get phy regulator: %s (%d)\n",
> -					      cfg->reg_names[i], ret);
> -			}
> +	for (i = 0; i < cfg->num_regs; i++)
> +		phy->regs[i].supply = cfg->reg_names[i];
> 
> -			return ret;
> -		}
> +	ret = devm_regulator_bulk_get(dev, cfg->num_regs, phy->regs);
> +	if (ret) {
> +		if (ret != -EPROBE_DEFER)
> +			DRM_DEV_ERROR(dev, "failed to get phy regulators: %d\n", ret);
> 
> -		phy->regs[i] = reg;
> +		return ret;
>  	}
> 
>  	for (i = 0; i < cfg->num_clks; i++) {
> @@ -66,11 +59,10 @@ int msm_hdmi_phy_resource_enable(struct hdmi_phy 
> *phy)
> 
>  	pm_runtime_get_sync(dev);
> 
> -	for (i = 0; i < cfg->num_regs; i++) {
> -		ret = regulator_enable(phy->regs[i]);
> -		if (ret)
> -			DRM_DEV_ERROR(dev, "failed to enable regulator: %s (%d)\n",
> -				cfg->reg_names[i], ret);
> +	ret = regulator_bulk_enable(cfg->num_regs, phy->regs);
> +	if (ret) {
> +		DRM_DEV_ERROR(dev, "failed to enable regulators: (%d)\n", ret);
> +		return ret;
>  	}
> 
>  	for (i = 0; i < cfg->num_clks; i++) {
> @@ -92,8 +84,7 @@ void msm_hdmi_phy_resource_disable(struct hdmi_phy 
> *phy)
>  	for (i = cfg->num_clks - 1; i >= 0; i--)
>  		clk_disable_unprepare(phy->clks[i]);
> 
> -	for (i = cfg->num_regs - 1; i >= 0; i--)
> -		regulator_disable(phy->regs[i]);
> +	regulator_bulk_disable(cfg->num_regs, phy->regs);
> 
>  	pm_runtime_put_sync(dev);
>  }

      parent reply	other threads:[~2021-10-15 22:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  0:10 [PATCH 1/2] drm/msm/hdmi: use bulk regulator API Dmitry Baryshkov
2021-10-15  0:11 ` [PATCH 2/2] drm/msm/hdmi: switch to drm_bridge_connector Dmitry Baryshkov
2021-10-15 22:25   ` [Freedreno] " abhinavk
2021-10-16 14:21     ` Dmitry Baryshkov
2021-10-18 23:54       ` abhinavk
2021-11-25 12:50         ` Dmitry Baryshkov
2021-12-06 20:42           ` Abhinav Kumar
2021-12-06 22:47             ` Dmitry Baryshkov
2021-12-06 22:58               ` Abhinav Kumar
2021-12-07  0:21                 ` Dmitry Baryshkov
2021-12-07  0:26                   ` Abhinav Kumar
2021-10-15 19:46 ` [PATCH 1/2] drm/msm/hdmi: use bulk regulator API Stephen Boyd
2021-10-15 22:16 ` abhinavk [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=b4ad0b7f370964da16c282c5fe99d7fd@codeaurora.org \
    --to=abhinavk@codeaurora.org \
    --cc=airlied@linux.ie \
    --cc=bjorn.andersson@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jonathan@marek.ca \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=sean@poorly.run \
    /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).