linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup
@ 2025-09-22 13:59 Faisal Hassan
  2025-09-22 23:42 ` Dmitry Baryshkov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Faisal Hassan @ 2025-09-22 13:59 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I, Dmitry Baryshkov,
	Neil Armstrong, Johan Hovold, Krzysztof Kozlowski, Wesley Cheng,
	Konrad Dybcio, linux-arm-msm, linux-phy, linux-kernel
  Cc: Faisal Hassan

Replace the custom qmp_regulator_data structure with the standard
regulator_bulk_data and use the init_load_uA field to set regulator
load during initialization.

This change simplifies the regulator setup by removing manual
allocation and load configuration logic, and leverages
devm_regulator_bulk_get_const() to automatically apply load settings
before enabling regulators.

Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 49 +++--------------------
 1 file changed, 6 insertions(+), 43 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index f07d097b129f..97262ed63700 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -1636,14 +1636,9 @@ static const struct qmp_phy_init_tbl x1e80100_usb43dp_pcs_usb_tbl[] = {
 };
 
 /* list of regulators */
-struct qmp_regulator_data {
-	const char *name;
-	unsigned int enable_load;
-};
-
-static struct qmp_regulator_data qmp_phy_vreg_l[] = {
-	{ .name = "vdda-phy", .enable_load = 21800 },
-	{ .name = "vdda-pll", .enable_load = 36000 },
+static struct regulator_bulk_data qmp_phy_vreg_l[] = {
+	{ .supply = "vdda-phy", .init_load_uA = 21800, },
+	{ .supply = "vdda-pll", .init_load_uA = 36000, },
 };
 
 static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4][4] = {
@@ -1801,7 +1796,7 @@ struct qmp_phy_cfg {
 	const char * const *reset_list;
 	int num_resets;
 	/* regulators to be requested */
-	const struct qmp_regulator_data *vreg_list;
+	const struct regulator_bulk_data *vreg_list;
 	int num_vregs;
 
 	/* array of registers with different offsets */
@@ -3403,39 +3398,6 @@ static const struct dev_pm_ops qmp_combo_pm_ops = {
 			   qmp_combo_runtime_resume, NULL)
 };
 
-static int qmp_combo_vreg_init(struct qmp_combo *qmp)
-{
-	const struct qmp_phy_cfg *cfg = qmp->cfg;
-	struct device *dev = qmp->dev;
-	int num = cfg->num_vregs;
-	int ret, i;
-
-	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
-	if (!qmp->vregs)
-		return -ENOMEM;
-
-	for (i = 0; i < num; i++)
-		qmp->vregs[i].supply = cfg->vreg_list[i].name;
-
-	ret = devm_regulator_bulk_get(dev, num, qmp->vregs);
-	if (ret) {
-		dev_err(dev, "failed at devm_regulator_bulk_get\n");
-		return ret;
-	}
-
-	for (i = 0; i < num; i++) {
-		ret = regulator_set_load(qmp->vregs[i].consumer,
-					cfg->vreg_list[i].enable_load);
-		if (ret) {
-			dev_err(dev, "failed to set load at %s\n",
-				qmp->vregs[i].supply);
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
 static int qmp_combo_reset_init(struct qmp_combo *qmp)
 {
 	const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -4003,7 +3965,8 @@ static int qmp_combo_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = qmp_combo_vreg_init(qmp);
+	ret = devm_regulator_bulk_get_const(dev, qmp->cfg->num_vregs,
+					qmp->cfg->vreg_list, &qmp->vregs);
 	if (ret)
 		return ret;
 
-- 
2.17.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup
  2025-09-22 13:59 [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup Faisal Hassan
@ 2025-09-22 23:42 ` Dmitry Baryshkov
  2025-11-19  8:41 ` Neil Armstrong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dmitry Baryshkov @ 2025-09-22 23:42 UTC (permalink / raw)
  To: Faisal Hassan
  Cc: Vinod Koul, Kishon Vijay Abraham I, Neil Armstrong, Johan Hovold,
	Krzysztof Kozlowski, Wesley Cheng, Konrad Dybcio, linux-arm-msm,
	linux-phy, linux-kernel

On Mon, Sep 22, 2025 at 07:29:01PM +0530, Faisal Hassan wrote:
> Replace the custom qmp_regulator_data structure with the standard
> regulator_bulk_data and use the init_load_uA field to set regulator
> load during initialization.
> 
> This change simplifies the regulator setup by removing manual
> allocation and load configuration logic, and leverages
> devm_regulator_bulk_get_const() to automatically apply load settings
> before enabling regulators.
> 
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
> ---
>  drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 49 +++--------------------
>  1 file changed, 6 insertions(+), 43 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup
  2025-09-22 13:59 [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup Faisal Hassan
  2025-09-22 23:42 ` Dmitry Baryshkov
@ 2025-11-19  8:41 ` Neil Armstrong
  2025-11-19 22:04 ` Bjorn Andersson
  2025-11-20 17:11 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Neil Armstrong @ 2025-11-19  8:41 UTC (permalink / raw)
  To: Faisal Hassan, Vinod Koul, Kishon Vijay Abraham I,
	Dmitry Baryshkov, Johan Hovold, Krzysztof Kozlowski, Wesley Cheng,
	Konrad Dybcio, linux-arm-msm, linux-phy, linux-kernel

On 9/22/25 15:59, Faisal Hassan wrote:
> Replace the custom qmp_regulator_data structure with the standard
> regulator_bulk_data and use the init_load_uA field to set regulator
> load during initialization.
> 
> This change simplifies the regulator setup by removing manual
> allocation and load configuration logic, and leverages
> devm_regulator_bulk_get_const() to automatically apply load settings
> before enabling regulators.
> 
> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
> ---
>   drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 49 +++--------------------
>   1 file changed, 6 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> index f07d097b129f..97262ed63700 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> @@ -1636,14 +1636,9 @@ static const struct qmp_phy_init_tbl x1e80100_usb43dp_pcs_usb_tbl[] = {
>   };
>   
>   /* list of regulators */
> -struct qmp_regulator_data {
> -	const char *name;
> -	unsigned int enable_load;
> -};
> -
> -static struct qmp_regulator_data qmp_phy_vreg_l[] = {
> -	{ .name = "vdda-phy", .enable_load = 21800 },
> -	{ .name = "vdda-pll", .enable_load = 36000 },
> +static struct regulator_bulk_data qmp_phy_vreg_l[] = {
> +	{ .supply = "vdda-phy", .init_load_uA = 21800, },
> +	{ .supply = "vdda-pll", .init_load_uA = 36000, },
>   };
>   
>   static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4][4] = {
> @@ -1801,7 +1796,7 @@ struct qmp_phy_cfg {
>   	const char * const *reset_list;
>   	int num_resets;
>   	/* regulators to be requested */
> -	const struct qmp_regulator_data *vreg_list;
> +	const struct regulator_bulk_data *vreg_list;
>   	int num_vregs;
>   
>   	/* array of registers with different offsets */
> @@ -3403,39 +3398,6 @@ static const struct dev_pm_ops qmp_combo_pm_ops = {
>   			   qmp_combo_runtime_resume, NULL)
>   };
>   
> -static int qmp_combo_vreg_init(struct qmp_combo *qmp)
> -{
> -	const struct qmp_phy_cfg *cfg = qmp->cfg;
> -	struct device *dev = qmp->dev;
> -	int num = cfg->num_vregs;
> -	int ret, i;
> -
> -	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
> -	if (!qmp->vregs)
> -		return -ENOMEM;
> -
> -	for (i = 0; i < num; i++)
> -		qmp->vregs[i].supply = cfg->vreg_list[i].name;
> -
> -	ret = devm_regulator_bulk_get(dev, num, qmp->vregs);
> -	if (ret) {
> -		dev_err(dev, "failed at devm_regulator_bulk_get\n");
> -		return ret;
> -	}
> -
> -	for (i = 0; i < num; i++) {
> -		ret = regulator_set_load(qmp->vregs[i].consumer,
> -					cfg->vreg_list[i].enable_load);
> -		if (ret) {
> -			dev_err(dev, "failed to set load at %s\n",
> -				qmp->vregs[i].supply);
> -			return ret;
> -		}
> -	}
> -
> -	return 0;
> -}
> -
>   static int qmp_combo_reset_init(struct qmp_combo *qmp)
>   {
>   	const struct qmp_phy_cfg *cfg = qmp->cfg;
> @@ -4003,7 +3965,8 @@ static int qmp_combo_probe(struct platform_device *pdev)
>   	if (ret)
>   		return ret;
>   
> -	ret = qmp_combo_vreg_init(qmp);
> +	ret = devm_regulator_bulk_get_const(dev, qmp->cfg->num_vregs,
> +					qmp->cfg->vreg_list, &qmp->vregs);
>   	if (ret)
>   		return ret;
>   

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup
  2025-09-22 13:59 [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup Faisal Hassan
  2025-09-22 23:42 ` Dmitry Baryshkov
  2025-11-19  8:41 ` Neil Armstrong
@ 2025-11-19 22:04 ` Bjorn Andersson
  2025-11-20 17:11 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Andersson @ 2025-11-19 22:04 UTC (permalink / raw)
  To: Faisal Hassan
  Cc: Vinod Koul, Kishon Vijay Abraham I, Dmitry Baryshkov,
	Neil Armstrong, Johan Hovold, Krzysztof Kozlowski, Wesley Cheng,
	Konrad Dybcio, linux-arm-msm, linux-phy, linux-kernel

On Mon, Sep 22, 2025 at 07:29:01PM +0530, Faisal Hassan wrote:
> Replace the custom qmp_regulator_data structure with the standard
> regulator_bulk_data and use the init_load_uA field to set regulator
> load during initialization.
> 
> This change simplifies the regulator setup by removing manual
> allocation and load configuration logic, and leverages
> devm_regulator_bulk_get_const() to automatically apply load settings
> before enabling regulators.
> 

Reviewed-by: Bjorn Andersson <andersson@kernel.org>

Regards,
Bjorn

> Signed-off-by: Faisal Hassan <faisal.hassan@oss.qualcomm.com>
> ---
>  drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 49 +++--------------------
>  1 file changed, 6 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> index f07d097b129f..97262ed63700 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> @@ -1636,14 +1636,9 @@ static const struct qmp_phy_init_tbl x1e80100_usb43dp_pcs_usb_tbl[] = {
>  };
>  
>  /* list of regulators */
> -struct qmp_regulator_data {
> -	const char *name;
> -	unsigned int enable_load;
> -};
> -
> -static struct qmp_regulator_data qmp_phy_vreg_l[] = {
> -	{ .name = "vdda-phy", .enable_load = 21800 },
> -	{ .name = "vdda-pll", .enable_load = 36000 },
> +static struct regulator_bulk_data qmp_phy_vreg_l[] = {
> +	{ .supply = "vdda-phy", .init_load_uA = 21800, },
> +	{ .supply = "vdda-pll", .init_load_uA = 36000, },
>  };
>  
>  static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4][4] = {
> @@ -1801,7 +1796,7 @@ struct qmp_phy_cfg {
>  	const char * const *reset_list;
>  	int num_resets;
>  	/* regulators to be requested */
> -	const struct qmp_regulator_data *vreg_list;
> +	const struct regulator_bulk_data *vreg_list;
>  	int num_vregs;
>  
>  	/* array of registers with different offsets */
> @@ -3403,39 +3398,6 @@ static const struct dev_pm_ops qmp_combo_pm_ops = {
>  			   qmp_combo_runtime_resume, NULL)
>  };
>  
> -static int qmp_combo_vreg_init(struct qmp_combo *qmp)
> -{
> -	const struct qmp_phy_cfg *cfg = qmp->cfg;
> -	struct device *dev = qmp->dev;
> -	int num = cfg->num_vregs;
> -	int ret, i;
> -
> -	qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
> -	if (!qmp->vregs)
> -		return -ENOMEM;
> -
> -	for (i = 0; i < num; i++)
> -		qmp->vregs[i].supply = cfg->vreg_list[i].name;
> -
> -	ret = devm_regulator_bulk_get(dev, num, qmp->vregs);
> -	if (ret) {
> -		dev_err(dev, "failed at devm_regulator_bulk_get\n");
> -		return ret;
> -	}
> -
> -	for (i = 0; i < num; i++) {
> -		ret = regulator_set_load(qmp->vregs[i].consumer,
> -					cfg->vreg_list[i].enable_load);
> -		if (ret) {
> -			dev_err(dev, "failed to set load at %s\n",
> -				qmp->vregs[i].supply);
> -			return ret;
> -		}
> -	}
> -
> -	return 0;
> -}
> -
>  static int qmp_combo_reset_init(struct qmp_combo *qmp)
>  {
>  	const struct qmp_phy_cfg *cfg = qmp->cfg;
> @@ -4003,7 +3965,8 @@ static int qmp_combo_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	ret = qmp_combo_vreg_init(qmp);
> +	ret = devm_regulator_bulk_get_const(dev, qmp->cfg->num_vregs,
> +					qmp->cfg->vreg_list, &qmp->vregs);
>  	if (ret)
>  		return ret;
>  
> -- 
> 2.17.1
> 
> 

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup
  2025-09-22 13:59 [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup Faisal Hassan
                   ` (2 preceding siblings ...)
  2025-11-19 22:04 ` Bjorn Andersson
@ 2025-11-20 17:11 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2025-11-20 17:11 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Dmitry Baryshkov, Neil Armstrong,
	Johan Hovold, Krzysztof Kozlowski, Wesley Cheng, Konrad Dybcio,
	linux-arm-msm, linux-phy, linux-kernel, Faisal Hassan


On Mon, 22 Sep 2025 19:29:01 +0530, Faisal Hassan wrote:
> Replace the custom qmp_regulator_data structure with the standard
> regulator_bulk_data and use the init_load_uA field to set regulator
> load during initialization.
> 
> This change simplifies the regulator setup by removing manual
> allocation and load configuration logic, and leverages
> devm_regulator_bulk_get_const() to automatically apply load settings
> before enabling regulators.
> 
> [...]

Applied, thanks!

[1/1] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup
      commit: 81d75558406609f311766a37ec4b2c74d7b11ea0

Best regards,
-- 
~Vinod



-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-20 17:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 13:59 [PATCH] phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup Faisal Hassan
2025-09-22 23:42 ` Dmitry Baryshkov
2025-11-19  8:41 ` Neil Armstrong
2025-11-19 22:04 ` Bjorn Andersson
2025-11-20 17:11 ` Vinod Koul

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).