[PATCH net-next v5 09/12] net: pse-pd: pd692x0: Add support for controller and manager power supplies

Kory Maincent posted 12 patches 7 months, 2 weeks ago
There is a newer version of this series
[PATCH net-next v5 09/12] net: pse-pd: pd692x0: Add support for controller and manager power supplies
Posted by Kory Maincent 7 months, 2 weeks ago
From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>

Add support for managing the VDD and VDDA power supplies for the PD692x0
PSE controller, as well as the VAUX5 and VAUX3P3 power supplies for the
PD6920x PSE managers.

Signed-off-by: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
---

Changes in v5:
- New patch
---
 drivers/net/pse-pd/pd692x0.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c
index 44ded2aa6fca..c9fa60b314ce 100644
--- a/drivers/net/pse-pd/pd692x0.c
+++ b/drivers/net/pse-pd/pd692x0.c
@@ -976,8 +976,10 @@ pd692x0_register_managers_regulator(struct pd692x0_priv *priv,
 	reg_name_len = strlen(dev_name(dev)) + 23;
 
 	for (i = 0; i < nmanagers; i++) {
+		static const char * const regulators[] = { "vaux5", "vaux3p3" };
 		struct regulator_dev *rdev;
 		char *reg_name;
+		int ret;
 
 		reg_name = devm_kzalloc(dev, reg_name_len, GFP_KERNEL);
 		if (!reg_name)
@@ -988,6 +990,17 @@ pd692x0_register_managers_regulator(struct pd692x0_priv *priv,
 		if (IS_ERR(rdev))
 			return PTR_ERR(rdev);
 
+		/* VMAIN is described as main supply for the manager.
+		 * Add other VAUX power supplies and link them to the
+		 * virtual device rdev->dev.
+		 */
+		ret = devm_regulator_bulk_get_enable(&rdev->dev,
+						     ARRAY_SIZE(regulators),
+						     regulators);
+		if (ret)
+			return dev_err_probe(&rdev->dev, ret,
+					     "Failed to enable regulators\n");
+
 		priv->manager_reg[i] = rdev;
 	}
 
@@ -1640,6 +1653,7 @@ static const struct fw_upload_ops pd692x0_fw_ops = {
 
 static int pd692x0_i2c_probe(struct i2c_client *client)
 {
+	static const char * const regulators[] = { "vdd", "vdda" };
 	struct pd692x0_msg msg, buf = {0}, zero = {0};
 	struct device *dev = &client->dev;
 	struct pd692x0_msg_ver ver;
@@ -1647,6 +1661,12 @@ static int pd692x0_i2c_probe(struct i2c_client *client)
 	struct fw_upload *fwl;
 	int ret;
 
+	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators),
+					     regulators);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Failed to enable regulators\n");
+
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		dev_err(dev, "i2c check functionality failed\n");
 		return -ENXIO;

-- 
2.34.1
Re: [PATCH net-next v5 09/12] net: pse-pd: pd692x0: Add support for controller and manager power supplies
Posted by Maxime Chevallier 7 months, 1 week ago
Hi Köry,

On Tue, 18 Feb 2025 17:19:13 +0100
Kory Maincent <kory.maincent@bootlin.com> wrote:

> From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
> 
> Add support for managing the VDD and VDDA power supplies for the PD692x0
> PSE controller, as well as the VAUX5 and VAUX3P3 power supplies for the
> PD6920x PSE managers.
> 
> Signed-off-by: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
> ---
> 
> Changes in v5:
> - New patch
> ---
>  drivers/net/pse-pd/pd692x0.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c
> index 44ded2aa6fca..c9fa60b314ce 100644
> --- a/drivers/net/pse-pd/pd692x0.c
> +++ b/drivers/net/pse-pd/pd692x0.c
> @@ -976,8 +976,10 @@ pd692x0_register_managers_regulator(struct pd692x0_priv *priv,
>  	reg_name_len = strlen(dev_name(dev)) + 23;
>  
>  	for (i = 0; i < nmanagers; i++) {
> +		static const char * const regulators[] = { "vaux5", "vaux3p3" };

Looks like the 'static' is not needed here :)

>  		struct regulator_dev *rdev;
>  		char *reg_name;
> +		int ret;
>  
>  		reg_name = devm_kzalloc(dev, reg_name_len, GFP_KERNEL);
>  		if (!reg_name)
> @@ -988,6 +990,17 @@ pd692x0_register_managers_regulator(struct pd692x0_priv *priv,
>  		if (IS_ERR(rdev))
>  			return PTR_ERR(rdev);
>  
> +		/* VMAIN is described as main supply for the manager.
> +		 * Add other VAUX power supplies and link them to the
> +		 * virtual device rdev->dev.
> +		 */
> +		ret = devm_regulator_bulk_get_enable(&rdev->dev,
> +						     ARRAY_SIZE(regulators),
> +						     regulators);
> +		if (ret)
> +			return dev_err_probe(&rdev->dev, ret,
> +					     "Failed to enable regulators\n");
> +
>  		priv->manager_reg[i] = rdev;
>  	}
>  
> @@ -1640,6 +1653,7 @@ static const struct fw_upload_ops pd692x0_fw_ops = {
>  
>  static int pd692x0_i2c_probe(struct i2c_client *client)
>  {
> +	static const char * const regulators[] = { "vdd", "vdda" };

And here as well

Thanks,

Maxime
Re: [PATCH net-next v5 09/12] net: pse-pd: pd692x0: Add support for controller and manager power supplies
Posted by Russell King (Oracle) 7 months, 1 week ago
On Mon, Feb 24, 2025 at 01:42:22PM +0100, Maxime Chevallier wrote:
> On Tue, 18 Feb 2025 17:19:13 +0100
> Kory Maincent <kory.maincent@bootlin.com> wrote:
> > diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c
> > index 44ded2aa6fca..c9fa60b314ce 100644
> > --- a/drivers/net/pse-pd/pd692x0.c
> > +++ b/drivers/net/pse-pd/pd692x0.c
> > @@ -976,8 +976,10 @@ pd692x0_register_managers_regulator(struct pd692x0_priv *priv,
> >  	reg_name_len = strlen(dev_name(dev)) + 23;
> >  
> >  	for (i = 0; i < nmanagers; i++) {
> > +		static const char * const regulators[] = { "vaux5", "vaux3p3" };
> 
> Looks like the 'static' is not needed here :)

Have you checked the compiler output before saying that?

I've seen plenty of instances where "static" should be there but isn't,
leading to the compiler generating inline code to create the
array/struct on the stack.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next v5 09/12] net: pse-pd: pd692x0: Add support for controller and manager power supplies
Posted by Maxime Chevallier 7 months, 1 week ago
On Mon, 24 Feb 2025 12:49:19 +0000
"Russell King (Oracle)" <linux@armlinux.org.uk> wrote:

> On Mon, Feb 24, 2025 at 01:42:22PM +0100, Maxime Chevallier wrote:
> > On Tue, 18 Feb 2025 17:19:13 +0100
> > Kory Maincent <kory.maincent@bootlin.com> wrote:  
> > > diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c
> > > index 44ded2aa6fca..c9fa60b314ce 100644
> > > --- a/drivers/net/pse-pd/pd692x0.c
> > > +++ b/drivers/net/pse-pd/pd692x0.c
> > > @@ -976,8 +976,10 @@ pd692x0_register_managers_regulator(struct pd692x0_priv *priv,
> > >  	reg_name_len = strlen(dev_name(dev)) + 23;
> > >  
> > >  	for (i = 0; i < nmanagers; i++) {
> > > +		static const char * const regulators[] = { "vaux5", "vaux3p3" };  
> > 
> > Looks like the 'static' is not needed here :)  
> 
> Have you checked the compiler output before saying that?

No I have not

> I've seen plenty of instances where "static" should be there but isn't,
> leading to the compiler generating inline code to create the
> array/struct on the stack.

Makes sense then, so it should be good here.

Thanks,

Maxime