diff mbox series

[1/2] dt-bindings: hwmon: add tmp464.yaml

Message ID 20220209133617.67297-1-agathe.porte@nokia.com (mailing list archive)
State Superseded
Headers show
Series [1/2] dt-bindings: hwmon: add tmp464.yaml | expand

Commit Message

Agathe Porte Feb. 9, 2022, 1:36 p.m. UTC
Add basic description of the tmp464 driver DT bindings.

Signed-off-by: Agathe Porte <agathe.porte@nokia.com>
---
 .../devicetree/bindings/hwmon/ti,tmp464.yaml  | 106 ++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml

Comments

Guenter Roeck Feb. 9, 2022, 3:11 p.m. UTC | #1
On 2/9/22 05:36, Agathe Porte wrote:
> Add basic description of the tmp464 driver DT bindings.
> 
> Signed-off-by: Agathe Porte <agathe.porte@nokia.com>
> ---
>   .../devicetree/bindings/hwmon/ti,tmp464.yaml  | 106 ++++++++++++++++++
>   1 file changed, 106 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml b/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
> new file mode 100644
> index 000000000000..aaee652c0067
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
> @@ -0,0 +1,106 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/hwmon/ti,tmp464.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TMP464 temperature sensor
> +
> +maintainers:
> +  - Guenter Roeck <linux@roeck-us.net>
> +
> +description: |
> +  ±0.0625°C Remote and Local temperature sensor
> +  https://www.ti.com/lit/ds/symlink/tmp464.pdf
> +
> +properties:
> +  compatible:
> +    enum:
> +      - ti,tmp464
> +  reg:
> +    maxItems: 1
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +required:
> +  - compatible
> +  - reg
> +
> +additionalProperties: false
> +
> +patternProperties:
> +  "^channel@([0-3])$":
> +    type: object
> +    description: |
> +      Represents channels of the device and their specific configuration.
> +
> +    properties:
> +      reg:
> +        description: |
> +          The channel number. 0 is local channel, 1-3 are remote channels
> +        items:
> +          minimum: 0
> +          maximum: 3

The chip has 1 local and 4 remote channels.

> +
> +      label:
> +        description: |
> +          A descriptive name for this channel, like "ambient" or "psu".
> +
> +      ti,n-factor:
> +        description: |
> +          The value (two's complement) to be programmed in the channel specific N correction register.
> +          For remote channels only.
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        items:
> +          minimum: 0
> +          maximum: 255
> +

This does not seem to match the implementation, which calls
of_property_read_s32() and accepts values from -128 .. 127.
It seems unlikely that 255 is interpreted as -1.

Hmm, is that a bug in the tmp421 driver ? I wonder if anyone
checked that, and if there is an official means to express
negative numbers in devicetree. I see other drivers use
of_property_read_s32(), but I did not find a clear explanation
how to describe negative numbers in devicetree files.

Also, I think other chip configuration properties need to be
described here as well for completeness.

- temperature offsets
- hysteresis
- temperature limits
- conversion rate

> +    required:
> +      - reg
> +
> +    additionalProperties: false
> +
> +examples:
> +  - |
> +    i2c {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      sensor@4b {
> +        compatible = "ti,tmp464";
> +        reg = <0x4b>;
> +      };
> +    };
> +  - |
> +    i2c {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      sensor@4b {
> +        compatible = "ti,tmp464";
> +        reg = <0x4b>;
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        channel@0 {
> +          reg = <0x0>;
> +          ti,n-factor = <0x1>;
> +          label = "local";
> +        };
> +
> +        channel@1 {
> +          reg = <0x1>;
> +          ti,n-factor = <0x0>;
> +          label = "somelabel";
> +        };
> +
> +        channel@2 {
> +          reg = <0x2>;
> +          status = "disabled";
> +        };
> +      };
> +    };
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml b/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
new file mode 100644
index 000000000000..aaee652c0067
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
@@ -0,0 +1,106 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/ti,tmp464.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TMP464 temperature sensor
+
+maintainers:
+  - Guenter Roeck <linux@roeck-us.net>
+
+description: |
+  ±0.0625°C Remote and Local temperature sensor
+  https://www.ti.com/lit/ds/symlink/tmp464.pdf
+
+properties:
+  compatible:
+    enum:
+      - ti,tmp464
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+patternProperties:
+  "^channel@([0-3])$":
+    type: object
+    description: |
+      Represents channels of the device and their specific configuration.
+
+    properties:
+      reg:
+        description: |
+          The channel number. 0 is local channel, 1-3 are remote channels
+        items:
+          minimum: 0
+          maximum: 3
+
+      label:
+        description: |
+          A descriptive name for this channel, like "ambient" or "psu".
+
+      ti,n-factor:
+        description: |
+          The value (two's complement) to be programmed in the channel specific N correction register.
+          For remote channels only.
+        $ref: /schemas/types.yaml#/definitions/uint32
+        items:
+          minimum: 0
+          maximum: 255
+
+    required:
+      - reg
+
+    additionalProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      sensor@4b {
+        compatible = "ti,tmp464";
+        reg = <0x4b>;
+      };
+    };
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      sensor@4b {
+        compatible = "ti,tmp464";
+        reg = <0x4b>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        channel@0 {
+          reg = <0x0>;
+          ti,n-factor = <0x1>;
+          label = "local";
+        };
+
+        channel@1 {
+          reg = <0x1>;
+          ti,n-factor = <0x0>;
+          label = "somelabel";
+        };
+
+        channel@2 {
+          reg = <0x2>;
+          status = "disabled";
+        };
+      };
+    };