[PATCH 2/2] dt-bindings: hwmon: Add TI TPS389008

Flaviu Nistor posted 2 patches 9 months ago
[PATCH 2/2] dt-bindings: hwmon: Add TI TPS389008
Posted by Flaviu Nistor 9 months ago
Add device tree bindings and an example for the
TI TPS389008 voltage monitor.

Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
---
 .../bindings/hwmon/ti,tps389008.yaml          | 140 ++++++++++++++++++
 1 file changed, 140 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ti,tps389008.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/ti,tps389008.yaml b/Documentation/devicetree/bindings/hwmon/ti,tps389008.yaml
new file mode 100644
index 000000000000..5a32359894cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/ti,tps389008.yaml
@@ -0,0 +1,140 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/ti,tps389008.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TPS389008 voltage monitor
+
+maintainers:
+  - Flaviu Nistor <flaviu.nistor@gmail.com>
+
+description: |
+  Voltage monitor from TI (TPS389008, TPS389006, TPS389004) on I2C bus.
+
+  Datasheets:
+    https://www.ti.com/lit/ds/symlink/tps389006.pdf?ts=1741000787840&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FTPS389006
+
+properties:
+  compatible:
+    oneOf:
+      - const: ti,tps38908
+      - items:
+          - enum:
+              - ti,tps38908
+              - ti,tps38906
+              - ti,tps38904
+          - const: ti,tps38908
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    description: Required only if a child node is present.
+    const: 1
+
+  "#size-cells":
+    description: Required only if a child node is present.
+    const: 0
+
+patternProperties:
+  "^vmon@[1-8]$":
+    description: |
+      The node contains optional child nodes for up to x channels.
+      There are 8 channels for TPS389008, 6 channels for TPS389006,
+      and 4 channels for TPS389004. Each child node describes the information
+      of the input source. Input channels default to disabled in the chip.
+      Unless channels are explicitly enabled in device-tree,
+      input channels will be disabled.
+    type: object
+    additionalProperties: false
+    properties:
+      reg:
+        description: |
+          Must be 1 to 8, corresponding to the VMONx
+          ports of the TPS389008, TPS389006, or TPS389004, respectively.
+        enum: [ 1, 2, 3, 4, 5, 6, 7, 8 ]
+
+      label:
+        description: Name of the input source.
+
+      ti,vrange-mult-4x:
+        description: |
+          Must have values 5 or 20 in order for the analog
+          conversion to be done correctly.
+          Value 5 indicates multiply by 1 (x1), and value 20 indicates
+          multiply by 4 (x4).
+        type: boolean
+
+      ti,vmon-enable:
+        description: |
+          Sets each channel status. By default, all input channels are disabled.
+            - 0 = channel disabled
+            - 1 = channel active
+        type: boolean
+
+    required:
+      - reg
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        vmon@37 {
+            compatible = "ti,tps389008", "ti,tps389006", "ti,tps389004";
+            reg = <0x37>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            vmon1: vmon1@1 {
+                reg = <0x1>;
+                label = "input1";
+                ti,vrange-mult-4x;
+                ti,vmon-enable;
+            };
+            vmon2: vmon2@2 {
+                reg = <0x2>;
+                label = "input2";
+                ti,vrange-mult-4x;
+                ti,vmon-enable;
+            };
+            vmon3: vmon3@3 {
+                reg = <0x3>;
+                label = "input3";
+                ti,vmon-enable;
+            };
+            vmon4: vmon4@4 {
+                reg = <0x4>;
+                label = "input4";
+                ti,vmon-enable;
+            };
+            vmon5: vmon5@5 {
+                reg = <0x5>;
+                label = "input5";
+                status = "disabled";
+            };
+            vmon6: vmon6@6 {
+                reg = <0x6>;
+                label = "input6";
+                ti,vmon-enable;
+            };
+            vmon7: vmon7@7 {
+                reg = <0x7>;
+                label = "input7";
+                ti,vmon-enable;
+            };
+            vmon8: vmon8@8 {
+                reg = <0x8>;
+                label = "input8";
+                ti,vmon-enable;
+            };
+        };
+    };
-- 
2.43.0
Re: [PATCH 2/2] dt-bindings: hwmon: Add TI TPS389008
Posted by Krzysztof Kozlowski 9 months ago
On 19/03/2025 18:02, Flaviu Nistor wrote:
> Add device tree bindings and an example for the
> TI TPS389008 voltage monitor.
> 
> Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
> ---

This wasn't ever tested, so limited review.

BTW, bindings are before the user.

> +properties:
> +  compatible:
> +    oneOf:
> +      - const: ti,tps38908
> +      - items:
> +          - enum:
> +              - ti,tps38908
> +              - ti,tps38906
> +              - ti,tps38904
> +          - const: ti,tps38908
> +
> +  reg:
> +    maxItems: 1
> +
> +  "#address-cells":
> +    description: Required only if a child node is present.

Drop description

> +    const: 1
> +
> +  "#size-cells":
> +    description: Required only if a child node is present.

Drop description


> +    const: 0
> +
> +patternProperties:
> +  "^vmon@[1-8]$":

s/vmon/channel/

> +    description: |
> +      The node contains optional child nodes for up to x channels.
> +      There are 8 channels for TPS389008, 6 channels for TPS389006,
> +      and 4 channels for TPS389004. Each child node describes the information

Then you need allOf:if:then: disallowing these for specific variants.

> +      of the input source. Input channels default to disabled in the chip.
> +      Unless channels are explicitly enabled in device-tree,
> +      input channels will be disabled.
> +    type: object
> +    additionalProperties: false
> +    properties:
> +      reg:
> +        description: |
> +          Must be 1 to 8,

Don't repeat constraints in free form text.

> corresponding to the VMONx
> +          ports of the TPS389008, TPS389006, or TPS389004, respectively.

Drop entire description

> +        enum: [ 1, 2, 3, 4, 5, 6, 7, 8 ]
> +
> +      label:
> +        description: Name of the input source.
> +
> +      ti,vrange-mult-4x:
> +        description: |
> +          Must have values 5 or 20 in order for the analog
> +          conversion to be done correctly.
> +          Value 5 indicates multiply by 1 (x1), and value 20 indicates
> +          multiply by 4 (x4).
> +        type: boolean
> +
> +      ti,vmon-enable:

Drop. Status tells it, no?

> +        description: |
> +          Sets each channel status. By default, all input channels are disabled.
> +            - 0 = channel disabled
> +            - 1 = channel active
> +        type: boolean
> +
> +    required:
> +      - reg
> +
> +required:
> +  - compatible
> +  - reg
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        vmon@37 {

Node names should be generic. See also an explanation and list of
examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation


> +            compatible = "ti,tps389008", "ti,tps389006", "ti,tps389004";

Test your code before sending, not after.



Best regards,
Krzysztof
Re: [PATCH 2/2] dt-bindings: hwmon: Add TI TPS389008
Posted by Rob Herring (Arm) 9 months ago
On Wed, 19 Mar 2025 19:02:29 +0200, Flaviu Nistor wrote:
> Add device tree bindings and an example for the
> TI TPS389008 voltage monitor.
> 
> Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
> ---
>  .../bindings/hwmon/ti,tps389008.yaml          | 140 ++++++++++++++++++
>  1 file changed, 140 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/ti,tps389008.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/hwmon/ti,tps389008.example.dtb: /example-0/i2c/vmon@37: failed to match any schema with compatible: ['ti,tps389008', 'ti,tps389006', 'ti,tps389004']
Documentation/devicetree/bindings/hwmon/ti,tps389008.example.dtb: /example-0/i2c/vmon@37: failed to match any schema with compatible: ['ti,tps389008', 'ti,tps389006', 'ti,tps389004']
Documentation/devicetree/bindings/hwmon/ti,tps389008.example.dtb: /example-0/i2c/vmon@37: failed to match any schema with compatible: ['ti,tps389008', 'ti,tps389006', 'ti,tps389004']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250319170234.63723-3-flaviu.nistor@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.