Skip to contentSkip to conversation

Add supply into PWBUS_REGULATOR macro

PATCH Applied Marcello Sylvester Bauer 3 participants 6 messages Feb 21, 2022 – Nov 5, 2022 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

v2 cover Add supply into PWBUS_REGULATOR macro

Hi,

I would like to extend the PWBUS_REGULATOR macro to be able to define a vin-supply. This makes it possible to regulate the voltage input supply and even turn it off, if not required.

Change in v2:
- Adapt commit message.

Marcello Sylvester Bauer (1):
hwmon: (pmbus) Add regulator supply into macro

 drivers/hwmon/pmbus/pmbus.h | 1 +
 1 file changed, 1 insertion(+)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 hwmon: (pmbus) Add regulator supply into macro

Add regulator supply into PWBUS_REGULATOR macro. This makes it optional to define a vin-supply in DT. Not defining a supply will add a dummy regulator supply instead and only cause the following debug output:

```
Looking up vin-supply property in node [...] failed
```
---
 drivers/hwmon/pmbus/pmbus.h | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/pmbus/pmbus.h +1 -0
index e0aa8aa46d8c..38f049d68d32 100644
@@ -464,6 +464,7 @@ extern const struct regulator_ops pmbus_regulator_ops;
 #define PMBUS_REGULATOR(_name, _id)				\
 	[_id] = {						\
 		.name = (_name # _id),				\
+		.supply_name = "vin",				\
 		.id = (_id),					\
 		.of_match = of_match_ptr(_name # _id),		\
 		.regulators_node = of_match_ptr("regulators"),	\
Signature · 1 line
2.34.1
maintainer Applied
#2 lore raw

Re: [PATCH v2 1/1] hwmon: (pmbus) Add regulator supply into macro

Quoted 9 lines · Marcello Sylvester Bauer

Add regulator supply into PWBUS_REGULATOR macro. This makes it optional to define a vin-supply in DT. Not defining a supply will add a dummy regulator supply instead and only cause the following debug output:

```
Looking up vin-supply property in node [...] failed
```

Applied to hwmon-next. That should give it some time to mature, and we can pull or modify it if it causes any problems.

Thanks,
Guenter

Quoted 16 lines
---
 drivers/hwmon/pmbus/pmbus.h | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/pmbus/pmbus.h +1 -0
index e0aa8aa46d8c..38f049d68d32 100644
@@ -464,6 +464,7 @@ extern const struct regulator_ops pmbus_regulator_ops;
 #define PMBUS_REGULATOR(_name, _id)				\
 	[_id] = {						\
 		.name = (_name # _id),				\
+		.supply_name = "vin",				\
 		.id = (_id),					\
 		.of_match = of_match_ptr(_name # _id),		\
 		.regulators_node = of_match_ptr("regulators"),	\
#3 lore raw

Re: [PATCH v2 1/1] hwmon: (pmbus) Add regulator supply into macro

Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Marcello Sylvester Bauer

Add regulator supply into PWBUS_REGULATOR macro. This makes it optional to define a vin-supply in DT. Not defining a supply will add a dummy regulator supply instead and only cause the following debug output:

Quoted 9 lines
Quoted 5 lines
```
Looking up vin-supply property in node [...] failed
```

Applied to hwmon-next. That should give it some time to mature, and we can pull or modify it if it causes any problems.

Wish I'd caught this sooner, but unfortunately I've just discovered that this does in fact cause breakage on my systems -- having regulator-dummy set as a supply on my PMBus regulators (instead of having them as their own top-level regulators without an upstream supply) leads to enable-count underflow errors when disabling them:

    # echo 0 > /sys/bus/platform/devices/efuse01/state
    [  906.094477] regulator-dummy: Underflow of regulator enable count
    [  906.100563] Failed to disable vout: -EINVAL
    [  136.992676] reg-userspace-consumer efuse01: Failed to configure state: -22

A simple revert solves the problem for me, but since I'm honestly a little unclear on the intent of the patch itself I'm not sure what a revert might break and hence I don't know if that's necessarily the right fix. Marcello (or others), any thoughts?

Thanks,
Zev

maintainer
#4 lore raw

Re: [PATCH v2 1/1] hwmon: (pmbus) Add regulator supply into macro

Quoted 27 lines · Zev Weiss
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Marcello Sylvester Bauer

Add regulator supply into PWBUS_REGULATOR macro. This makes it optional to define a vin-supply in DT. Not defining a supply will add a dummy regulator supply instead and only cause the following debug output:

Quoted 9 lines
Quoted 5 lines
```
Looking up vin-supply property in node [...] failed
```

Applied to hwmon-next. That should give it some time to mature, and we can pull or modify it if it causes any problems.

Wish I'd caught this sooner, but unfortunately I've just discovered that this does in fact cause breakage on my systems -- having regulator-dummy set as a supply on my PMBus regulators (instead of having them as their own top-level regulators without an upstream supply) leads to enable-count underflow errors when disabling them:

    # echo 0 > /sys/bus/platform/devices/efuse01/state
    [  906.094477] regulator-dummy: Underflow of regulator enable count
    [  906.100563] Failed to disable vout: -EINVAL
    [  136.992676] reg-userspace-consumer efuse01: Failed to configure state: -22
Quoted 4 lines

A simple revert solves the problem for me, but since I'm honestly a little unclear on the intent of the patch itself I'm not sure what a revert might break and hence I don't know if that's necessarily the right fix. Marcello (or others), any thoughts?

Revert now, ask questions later. I'll send a patch.

Guenter

Quoted 5 lines

Thanks,
Zev

#5 lore raw

Re: [PATCH v2 1/1] hwmon: (pmbus) Add regulator supply into macro

Quoted 26 lines · Guenter Roeck
Quoted 25 lines · Zev Weiss
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Marcello Sylvester Bauer

Add regulator supply into PWBUS_REGULATOR macro. This makes it optional to define a vin-supply in DT. Not defining a supply will add a dummy regulator supply instead and only cause the following debug output:

Quoted 8 lines
Quoted 5 lines
```
Looking up vin-supply property in node [...] failed
```

Applied to hwmon-next. That should give it some time to mature, and we can pull or modify it if it causes any problems.

Wish I'd caught this sooner, but unfortunately I've just discovered that this does in fact cause breakage on my systems -- having regulator-dummy set as a supply on my PMBus regulators (instead of having them as their own top-level regulators without an upstream supply) leads to enable-count underflow errors when disabling them:

     # echo 0 > /sys/bus/platform/devices/efuse01/state
     [  906.094477] regulator-dummy: Underflow of regulator enable count
     [  906.100563] Failed to disable vout: -EINVAL
     [  136.992676] reg-userspace-consumer efuse01: Failed to configure state: -22
Quoted 4 lines
Quoted 4 lines

A simple revert solves the problem for me, but since I'm honestly a little unclear on the intent of the patch itself I'm not sure what a revert might break and hence I don't know if that's necessarily the right fix. Marcello (or others), any thoughts?

Oh, my bad. I thought this makes it optional to add a supply without having a negative effect. Reverting this patch makes sense, but I'm not sure how else to integrate this.

Thanks,
Marcello

Quoted 8 lines

Revert now, ask questions later. I'll send a patch.

Guenter

Quoted 4 lines

Thanks,
Zev