Skip to contentSkip to conversation

hwmon: (pmbus) Use PMBUS_REGULATOR_ONE to declare regulators with single output

PATCH In review Guenter Roeck 3 participants 13 messages Feb 14, 2024 – Feb 22, 2024

Subsystems (3)
lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

cover hwmon: (pmbus) Use PMBUS_REGULATOR_ONE to declare regulators with single output

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulators for chips with a single ouput using PMBUS_REGULATOR_ONE() to make that happen.

----------------------------------------------------------------
Guenter Roeck (3):
hwmon: (pmbus/tda38640) Use PMBUS_REGULATOR_ONE to declare regulator
hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulator
hwmon: (pmbus/ir38064) Use PMBUS_REGULATOR_ONE to declare regulator

 drivers/hwmon/pmbus/ir38064.c  | 2 +-
 drivers/hwmon/pmbus/lm25066.c  | 2 +-
 drivers/hwmon/pmbus/tda38640.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 hwmon: (pmbus/tda38640) Use PMBUS_REGULATOR_ONE to declare regulator

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen.

Cc Conor Dooley <[email protected]>
Cc Naresh Solanki <[email protected]>
Cc Patrick Rudolph <[email protected]>
---
 drivers/hwmon/pmbus/tda38640.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/tda38640.c +1 -1
index 09cd114b1736..c31889a036f0 100644
@@ -15,7 +15,7 @@
 #include "pmbus.h"
 
 static const struct regulator_desc __maybe_unused tda38640_reg_desc[] = {
-	PMBUS_REGULATOR("vout", 0),
+	PMBUS_REGULATOR_ONE("vout"),
 };
 
 struct tda38640_data {
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH 2/3 hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulator

In reply to Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen.

Cc Conor Dooley <[email protected]>
Cc Naresh Solanki <[email protected]>
Cc Zev Weiss <[email protected]>
---
 drivers/hwmon/pmbus/lm25066.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/lm25066.c +1 -1
index 3a20df5a43ec..cfffa4cdc0df 100644
@@ -437,7 +437,7 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
 
 #if IS_ENABLED(CONFIG_SENSORS_LM25066_REGULATOR)
 static const struct regulator_desc lm25066_reg_desc[] = {
-	PMBUS_REGULATOR("vout", 0),
+	PMBUS_REGULATOR_ONE("vout"),
 };
 #endif
 
Signature · 1 line
2.39.2
#3 lore raw

Re: [PATCH 2/3] hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulator

Quoted 4 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen.

Hi Guenter,

This will necessitate a DTS update on at least one platform to maintain compatibility (Delta ahe50dc BMC, [1]). I'm not sure offhand if there are process/policy rules about mixing code changes and device-tree changes in the same commit, but changing either one without the other would break things.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/aspeed/aspeed-bmc-delta-ahe50dc.dts?id=8d3dea210042f54b952b481838c1e7dfc4ec751d#n21

Thanks,
Zev

author maintainer
#4 lore raw

Re: [PATCH 2/3] hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulator

Quoted 6 lines · Zev Weiss
Quoted 4 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen.

Quoted 7 lines

Hi Guenter,

This will necessitate a DTS update on at least one platform to maintain compatibility (Delta ahe50dc BMC, [1]).  I'm not sure offhand if there are process/policy rules about mixing code changes and device-tree changes in the same commit, but changing either one without the other would break things.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/aspeed/aspeed-bmc-delta-ahe50dc.dts?id=8d3dea210042f54b952b481838c1e7dfc4ec751d#n21

Sigh. Agreed, especially since changing the dts file in the kernel won't change the dtb files on actual hardware.

I really have no good solution for this. We (Well, I) didn't realize that there are regulator naming conventions/restrictions when we introduced regulator support into PMBus drivers. My bad. Let's see what others say.

Guenter

#5 lore raw

Re: [PATCH 2/3] hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulator

Quoted 15 lines · Guenter Roeck
Quoted 6 lines · Zev Weiss
Quoted 4 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen.

Quoted 7 lines

Hi Guenter,

This will necessitate a DTS update on at least one platform to maintain compatibility (Delta ahe50dc BMC, [1]).  I'm not sure offhand if there are process/policy rules about mixing code changes and device-tree changes in the same commit, but changing either one without the other would break things.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/aspeed/aspeed-bmc-delta-ahe50dc.dts?id=8d3dea210042f54b952b481838c1e7dfc4ec751d#n21

Quoted 9 lines

Sigh. Agreed, especially since changing the dts file in the kernel won't change the dtb files on actual hardware.

I really have no good solution for this. We (Well, I) didn't realize that there are regulator naming conventions/restrictions when we introduced regulator support into PMBus drivers. My bad. Let's see what others say.

Guenter

Well, perhaps mitigating that slightly: I don't see any obvious cases of any other platforms' device-trees having any dependencies on the regulator naming that would be affected by this (judging by 'git grep vout0 arch/*/boot/dts' anyway), and at least with OpenBMC on the ahe50dc (the primary and AFAIK only user of that device-tree) the dtb would also be updated along with any kernel update.

So I wouldn't expect it to cause anyone any actual problems if we went ahead and changed it anyway; as long as the dts & driver do stay in sync with each other, maybe we could let it slide if it's otherwise a desirable change to make?

Zev

#6 lore raw

Re: [PATCH 2/3] hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulator

Quoted 23 lines · Zev Weiss
Quoted 22 lines · Guenter Roeck
Quoted 6 lines · Zev Weiss
Quoted 4 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen.

Quoted 7 lines

Hi Guenter,

This will necessitate a DTS update on at least one platform to maintain compatibility (Delta ahe50dc BMC, [1]).  I'm not sure offhand if there are process/policy rules about mixing code changes and device-tree changes in the same commit, but changing either one without the other would break things.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/aspeed/aspeed-bmc-delta-ahe50dc.dts?id=8d3dea210042f54b952b481838c1e7dfc4ec751d#n21

Sigh. Agreed, especially since changing the dts file in the kernel won't change the dtb files on actual hardware.

I really have no good solution for this. We (Well, I) didn't realize that there are regulator naming conventions/restrictions when we introduced regulator support into PMBus drivers. My bad. Let's see what others say.

Quoted 7 lines
Quoted 2 lines

Guenter

Well, perhaps mitigating that slightly: I don't see any obvious cases of any other platforms' device-trees having any dependencies on the regulator naming that would be affected by this (judging by 'git grep vout0 arch/*/boot/dts' anyway),

Which is a good thing, as none of these devices' bindings actually allow
regulator. Aspeed devicetrees are a mess of non-compliance with the
bindings, so I suppose that this is not surprising, but somewhere in the
wall of complaints there is a:
aspeed-bmc-delta-ahe50dc.dtb: /ahb/apb/bus@1e78a000/i2c-bus@40/pca9541@79/i2c-arb/efuse@12: failed to match any schema with compatible: ['lm25066']

I mentioned this on the other thread, but I guess the kernel is actually using the i2c_device_ids to probe the driver and not the compatible, since the documented compatible and the compatibles in the driver have a vendor prefix?

Quoted 8 lines

and at least with OpenBMC on the ahe50dc (the
primary and AFAIK only user of that device-tree) the dtb would also be updated along with any kernel update.

So I wouldn't expect it to cause anyone any actual problems if we went ahead and changed it anyway; as long as the dts & driver do stay in sync with each other, maybe we could let it slide if it's otherwise a desirable change to make?

I think having "vout0" when there's nothing else looks a bit odd, but I'm not gonna lose sleep over "vout0" being used if its used in device documentation or is convention.

Whatever is done, please document the regulator child node in the binding for this device and fix the dts to use a real compatible.

Cheers,
Conor.

author maintainer
#7 lore raw

PATCH 3/3 hwmon: (pmbus/ir38064) Use PMBUS_REGULATOR_ONE to declare regulator

In reply to Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen.

Cc Conor Dooley <[email protected]>
Cc Naresh Solanki <[email protected]>
Cc Patrick Rudolph <[email protected]>
---
 drivers/hwmon/pmbus/ir38064.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/ir38064.c +1 -1
index 04185be3fdb6..69e18cb468f6 100644
@@ -22,7 +22,7 @@
 
 #if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
 static const struct regulator_desc ir38064_reg_desc[] = {
-	PMBUS_REGULATOR("vout", 0),
+	PMBUS_REGULATOR_ONE("vout"),
 };
 #endif /* CONFIG_SENSORS_IR38064_REGULATOR */
 
Signature · 1 line
2.39.2
#8 lore raw
In reply to Guenter Roeck
Quoted 3 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulators for chips with a single ouput using PMBUS_REGULATOR_ONE() to make that happen.

If we're gonna do this, we should go ahead and document each of these regulators. If Naresh sends a v2 for the tda, I could do the others.

Quoted 11 lines

----------------------------------------------------------------
Guenter Roeck (3):
hwmon: (pmbus/tda38640) Use PMBUS_REGULATOR_ONE to declare regulator
hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulator
hwmon: (pmbus/ir38064) Use PMBUS_REGULATOR_ONE to declare regulator

 drivers/hwmon/pmbus/ir38064.c  | 2 +-
 drivers/hwmon/pmbus/lm25066.c  | 2 +-
 drivers/hwmon/pmbus/tda38640.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
#9 lore raw
Quoted 7 lines · Conor Dooley
Quoted 3 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulators for chips with a single ouput using PMBUS_REGULATOR_ONE() to make that happen.

If we're gonna do this, we should go ahead and document each of these regulators. If Naresh sends a v2 for the tda, I could do the others.

As it turns out, the infineon devices in question are not PMICs, but regulators themselves. I think something like the following is what we need. Perhaps Zev or the 9elements guys can comment.

Cheers,
Conor.

commit 9cf2671c0b98c0a0dd599fe9152985d1320bf320

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 14:24:48 2024 +0000

dt-bindings: regulator: promote infineon buck converters to their own binding

These devices may need to make use of the common regulator properties, but these are not permitted while only documented in trivial-devices.yaml

Documentation/devicetree/bindings/regulator/infineon,ir38060.yaml new file +46 -0
new file mode 100644
index 000000000000..bb0114f7e13f
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/infineon,ir38060.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Infineon Buck Regulators with PMBUS interfaces
+
+maintainers:
+  - Not Me.
+
+allOf:
+  - $ref: regulator.yaml#
+
+properties:
+  compatible:
+    enum:
+      - infineon,ir38060
+      - infineon,ir38064
+      - infineon,ir38164
+      - infineon,ir38263
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      regulator@34 {
+        compatible = "infineon,ir38060";
+        reg = <0x34>;
+
+        regulator-min-microvolt = <437500>;
+        regulator-max-microvolt = <1387500>;
+      };
+    };
+
Documentation/devicetree/bindings/trivial-devices.yaml +0 -8
index 9cdd5a534120..e07be7bf8395 100644
@@ -130,14 +130,6 @@ properties:
           - infineon,dps310
             # Infineon IR36021 digital POL buck controller
           - infineon,ir36021
-            # Infineon IR38060 Voltage Regulator
-          - infineon,ir38060
-            # Infineon IR38064 Voltage Regulator
-          - infineon,ir38064
-            # Infineon IR38164 Voltage Regulator
-          - infineon,ir38164
-            # Infineon IR38263 Voltage Regulator
-          - infineon,ir38263
             # Infineon IRPS5401 Voltage Regulator (PMIC)
           - infineon,irps5401
             # Infineon TLV493D-A1B6 I2C 3D Magnetic Sensor

commit 597739840d2bc95ebb884d7f5fc4f3cc206d9af6

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 13:29:12 2024 +0000

dt-bindings: hwmon/pmbus: ti,lm25066: document regulators

All devices documented in the lm25066 binding are intended for use with a regulator, be that for purely monitoring purposes (lm25056) or, for the other devices, as the controller of that regulator. The binding does not currently allow regulator child nodes, so add one.

Each of these devices interacts with only a single regulator and documentation refers to it as "Vout", hence the choice of child node name.

Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml +12 -0
index da8292bc32f5..4373e9c86e54 100644
@@ -34,6 +34,18 @@ properties:
       Shunt (sense) resistor value in micro-Ohms
     default: 1000
 
+  regulators:
+    type: object
+
+    properties:
+      vout:
+        $ref: /schemas/regulator/regulator.yaml#
+        type: object
+
+        unevaluatedProperties: false
+
+    additionalProperties: false
+
 required:
   - compatible
   - reg
author maintainer
#10 lore raw
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Conor Dooley
Quoted 3 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulators for chips with a single ouput using PMBUS_REGULATOR_ONE() to make that happen.

Quoted 7 lines
Quoted 2 lines

If we're gonna do this, we should go ahead and document each of these regulators. If Naresh sends a v2 for the tda, I could do the others.

As it turns out, the infineon devices in question are not PMICs, but regulators themselves. I think something like the following is what we need. Perhaps Zev or the 9elements guys can comment.

IMO The lm25066 patch should be separate.

Guenter

Quoted 127 lines

Cheers,
Conor.

commit 9cf2671c0b98c0a0dd599fe9152985d1320bf320

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 14:24:48 2024 +0000

dt-bindings: regulator: promote infineon buck converters to their own binding

These devices may need to make use of the common regulator properties, but these are not permitted while only documented in trivial-devices.yaml

Documentation/devicetree/bindings/regulator/infineon,ir38060.yaml new file +46 -0
new file mode 100644
index 000000000000..bb0114f7e13f
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/infineon,ir38060.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Infineon Buck Regulators with PMBUS interfaces
+
+maintainers:
+  - Not Me.
+
+allOf:
+  - $ref: regulator.yaml#
+
+properties:
+  compatible:
+    enum:
+      - infineon,ir38060
+      - infineon,ir38064
+      - infineon,ir38164
+      - infineon,ir38263
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      regulator@34 {
+        compatible = "infineon,ir38060";
+        reg = <0x34>;
+
+        regulator-min-microvolt = <437500>;
+        regulator-max-microvolt = <1387500>;
+      };
+    };
+
Documentation/devicetree/bindings/trivial-devices.yaml +0 -8
index 9cdd5a534120..e07be7bf8395 100644
@@ -130,14 +130,6 @@ properties:
            - infineon,dps310
              # Infineon IR36021 digital POL buck controller
            - infineon,ir36021
-            # Infineon IR38060 Voltage Regulator
-          - infineon,ir38060
-            # Infineon IR38064 Voltage Regulator
-          - infineon,ir38064
-            # Infineon IR38164 Voltage Regulator
-          - infineon,ir38164
-            # Infineon IR38263 Voltage Regulator
-          - infineon,ir38263
              # Infineon IRPS5401 Voltage Regulator (PMIC)
            - infineon,irps5401
              # Infineon TLV493D-A1B6 I2C 3D Magnetic Sensor

commit 597739840d2bc95ebb884d7f5fc4f3cc206d9af6

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 13:29:12 2024 +0000

dt-bindings: hwmon/pmbus: ti,lm25066: document regulators

All devices documented in the lm25066 binding are intended for use with a regulator, be that for purely monitoring purposes (lm25056) or, for the other devices, as the controller of that regulator. The binding does not currently allow regulator child nodes, so add one.

Each of these devices interacts with only a single regulator and documentation refers to it as "Vout", hence the choice of child node name.

Documentation/devicetree/bindings/hwmon/pmbus/ti,lm25066.yaml +12 -0
@@ -34,6 +34,18 @@ properties:
        Shunt (sense) resistor value in micro-Ohms
      default: 1000
 
+  regulators:
+    type: object
+
+    properties:
+      vout:
+        $ref: /schemas/regulator/regulator.yaml#
+        type: object
+
+        unevaluatedProperties: false
+
+    additionalProperties: false
+
  required:
    - compatible
    - reg
#11 lore raw
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Conor Dooley
Quoted 3 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulators for chips with a single ouput using PMBUS_REGULATOR_ONE() to make that happen.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

If we're gonna do this, we should go ahead and document each of these regulators. If Naresh sends a v2 for the tda, I could do the others.

As it turns out, the infineon devices in question are not PMICs, but regulators themselves. I think something like the following is what we need. Perhaps Zev or the 9elements guys can comment.

IMO The lm25066 patch should be separate.

It should already be a pair of changes - one for the infineon stuff and another for the ti devices:

Quoted 23 lines
Quoted 23 lines

commit 9cf2671c0b98c0a0dd599fe9152985d1320bf320

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 14:24:48 2024 +0000

dt-bindings: regulator: promote infineon buck converters to their own binding These devices may need to make use of the common regulator properties, but these are not permitted while only documented in trivial-devices.yaml

commit 597739840d2bc95ebb884d7f5fc4f3cc206d9af6

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 13:29:12 2024 +0000

dt-bindings: hwmon/pmbus: ti,lm25066: document regulators All devices documented in the lm25066 binding are intended for use with a regulator, be that for purely monitoring purposes (lm25056) or, for the other devices, as the controller of that regulator. The binding does not currently allow regulator child nodes, so add one.
Each of these devices interacts with only a single regulator and documentation refers to it as "Vout", hence the choice of child node name.

Acked-by
#12 lore raw
Quoted 11 lines · Conor Dooley
Quoted 10 lines · Guenter Roeck
Quoted 9 lines · Conor Dooley
Quoted 7 lines · Conor Dooley
Quoted 3 lines · Guenter Roeck

If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulators for chips with a single ouput using PMBUS_REGULATOR_ONE() to make that happen.

If we're gonna do this, we should go ahead and document each of these regulators. If Naresh sends a v2 for the tda, I could do the others.

Quoted 33 lines
Quoted 5 lines
Quoted 4 lines

As it turns out, the infineon devices in question are not PMICs, but regulators themselves. I think something like the following is what we need. Perhaps Zev or the 9elements guys can comment.

IMO The lm25066 patch should be separate.

It should already be a pair of changes - one for the infineon stuff and another for the ti devices:

Quoted 23 lines
Quoted 23 lines

commit 9cf2671c0b98c0a0dd599fe9152985d1320bf320

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 14:24:48 2024 +0000

dt-bindings: regulator: promote infineon buck converters to their own binding These devices may need to make use of the common regulator properties, but these are not permitted while only documented in trivial-devices.yaml

commit 597739840d2bc95ebb884d7f5fc4f3cc206d9af6

Author: Conor Dooley <[email protected]>
Date:   Mon Feb 19 13:29:12 2024 +0000

dt-bindings: hwmon/pmbus: ti,lm25066: document regulators All devices documented in the lm25066 binding are intended for use with a regulator, be that for purely monitoring purposes (lm25056) or, for the other devices, as the controller of that regulator. The binding does not currently allow regulator child nodes, so add one.
Each of these devices interacts with only a single regulator and documentation refers to it as "Vout", hence the choice of child node name.

This looks fine to me -- as far as the lm25066 patch goes,

Thanks,
Zev