diff mbox series

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

Message ID 20220218065856.1899086-1-linux@roeck-us.net
State Superseded, archived
Headers show
Series [v4,1/2] dt-bindings: hwmon: add tmp464.yaml | expand

Checks

Context Check Description
robh/patch-applied success
robh/checkpatch success
robh/dtbs-check success
robh/dt-meta-schema success

Commit Message

Guenter Roeck Feb. 18, 2022, 6:58 a.m. UTC
From: Agathe Porte <agathe.porte@nokia.com>

Add basic description of the tmp464 driver DT bindings.

Signed-off-by: Agathe Porte <agathe.porte@nokia.com>
Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v4:
- No changes

v3:
- Addedd support for TMP468.
- Changed number of channels from 0..3 (which was wrong anyway) to 0..8.
- Changed value range for ti,n-factor to int8, with an example for
  a negative value.
- Added myself as driver maintainer.

 .../devicetree/bindings/hwmon/ti,tmp464.yaml  | 109 ++++++++++++++++++
 MAINTAINERS                                   |   7 ++
 2 files changed, 116 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml

Comments

Agathe Porte Feb. 18, 2022, 9:41 a.m. UTC | #1
Hi Guenter,

Le 18/02/2022 à 07:58, Guenter Roeck a écrit :
> From: Agathe Porte <agathe.porte@nokia.com>
>
> Add basic description of the tmp464 driver DT bindings.
>
> Signed-off-by: Agathe Porte <agathe.porte@nokia.com>
> Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v4:
> - No changes
>
> +        channel@0 {
> +          reg = <0x0>;
> +          ti,n-factor = /bits/ 8 <(-10)>;
> +          label = "local";
> +        };

Setting the n-factor for the local channel is not supported, so we 
should remove this attribute for this example and move it to another 
channel.

Here is the output on a hardware test:

[165599.122883] tmp464 16-0049: n-factor can't be set for internal channel
[165599.123833] tmp464: probe of 16-0049 failed with error -22

> +
> +        channel@1 {
> +          reg = <0x1>;
> +          ti,n-factor = /bits/ 8 <0x0>;
> +          label = "somelabel";
> +        };
No particular issue when defining a property for channel that is not 
internal during driver probe.
> +
> +        channel@2 {
> +          reg = <0x2>;
> +          status = "disabled";
> +        };

Works as expected on target:

root@fct-0a:/sys/class/hwmon/hwmon2 >cat temp3_input
cat: temp3_input: No data available

Best regards,

Agathe.
Agathe Porte Feb. 18, 2022, 9:50 a.m. UTC | #2
Hi Guenter,

Le 18/02/2022 à 07:58, Guenter Roeck a écrit :
> Add support for Texas Instruments TMP464 and TMP468 temperature sensor
> ICs.
>
> TI's TMP464 is an I2C temperature sensor chip. This chip is similar
> to TI's TMP421 chip, but with 16bit-wide registers (instead of
> 8bit-wide registers). The chip has one local sensor and four remote
> sensors. TMP468 is similar to TMP464 but has one local and eight
> remote sensors.
>
> Originally-from: Agathe Porte <agathe.porte@nokia.com>
> Cc: Agathe Porte <agathe.porte@nokia.com>
> Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v4:
> - Fixed reading n-factor information from devicetree
>    [Use of_property_read_u8 instead of of_property_read_s32 to read the
>     property value, and write n-factor value into the upper 8 bit of the
>     n-factor register]

Changing n-factor with DT seems to work:

temp2_input=38500 (nfactor=10)
temp2_input=35500 (nfactor=-10)

Driver probes just fine with this attribute set.

> +static int tmp464_probe_child_from_dt(struct device *dev,
> +				      struct device_node *child,
> +				      struct tmp464_data *data)
> +
> +{
> +	struct regmap *regmap = data->regmap;
> +	u32 channel;
> +	u8 nfactor;
> +	s32 val;

val is not used according to the compiler, and thus should be removed 
(module does not compile with -Werror)

PS: TMP464 samples will be sent by DHL today and should arrive to you on 
Feb, 23rd.

Best regards,

Agathe.
Guenter Roeck Feb. 18, 2022, 3:06 p.m. UTC | #3
On 2/18/22 01:41, Agathe Porte wrote:
> Hi Guenter,
> 
> Le 18/02/2022 à 07:58, Guenter Roeck a écrit :
>> From: Agathe Porte <agathe.porte@nokia.com>
>>
>> Add basic description of the tmp464 driver DT bindings.
>>
>> Signed-off-by: Agathe Porte <agathe.porte@nokia.com>
>> Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> v4:
>> - No changes
>>
>> +        channel@0 {
>> +          reg = <0x0>;
>> +          ti,n-factor = /bits/ 8 <(-10)>;
>> +          label = "local";
>> +        };
> 
> Setting the n-factor for the local channel is not supported, so we should remove this attribute for this example and move it to another channel.
> 

Done, thanks!

Guenter

> Here is the output on a hardware test:
> 
> [165599.122883] tmp464 16-0049: n-factor can't be set for internal channel
> [165599.123833] tmp464: probe of 16-0049 failed with error -22
> 
>> +
>> +        channel@1 {
>> +          reg = <0x1>;
>> +          ti,n-factor = /bits/ 8 <0x0>;
>> +          label = "somelabel";
>> +        };
> No particular issue when defining a property for channel that is not internal during driver probe.
>> +
>> +        channel@2 {
>> +          reg = <0x2>;
>> +          status = "disabled";
>> +        };
> 
> Works as expected on target:
> 
> root@fct-0a:/sys/class/hwmon/hwmon2 >cat temp3_input
> cat: temp3_input: No data available
> 
> Best regards,
> 
> Agathe.
>
Guenter Roeck Feb. 18, 2022, 3:07 p.m. UTC | #4
On 2/18/22 01:50, Agathe Porte wrote:
> Hi Guenter,
> 
> Le 18/02/2022 à 07:58, Guenter Roeck a écrit :
>> Add support for Texas Instruments TMP464 and TMP468 temperature sensor
>> ICs.
>>
>> TI's TMP464 is an I2C temperature sensor chip. This chip is similar
>> to TI's TMP421 chip, but with 16bit-wide registers (instead of
>> 8bit-wide registers). The chip has one local sensor and four remote
>> sensors. TMP468 is similar to TMP464 but has one local and eight
>> remote sensors.
>>
>> Originally-from: Agathe Porte <agathe.porte@nokia.com>
>> Cc: Agathe Porte <agathe.porte@nokia.com>
>> Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> v4:
>> - Fixed reading n-factor information from devicetree
>>    [Use of_property_read_u8 instead of of_property_read_s32 to read the
>>     property value, and write n-factor value into the upper 8 bit of the
>>     n-factor register]
> 
> Changing n-factor with DT seems to work:
> 
> temp2_input=38500 (nfactor=10)
> temp2_input=35500 (nfactor=-10)
> 
> Driver probes just fine with this attribute set.
> 
>> +static int tmp464_probe_child_from_dt(struct device *dev,
>> +                      struct device_node *child,
>> +                      struct tmp464_data *data)
>> +
>> +{
>> +    struct regmap *regmap = data->regmap;
>> +    u32 channel;
>> +    u8 nfactor;
>> +    s32 val;
> 
> val is not used according to the compiler, and thus should be removed (module does not compile with -Werror)
> 

Fixed.

> PS: TMP464 samples will be sent by DHL today and should arrive to you on Feb, 23rd.
> 
Thanks a lot!

Guenter
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..8ce4be729494
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
@@ -0,0 +1,109 @@ 
+# 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 and TMP468 temperature sensors
+
+maintainers:
+  - Agathe Porte <agathe.porte@nokia.com>
+
+description: |
+  ±0.0625°C Remote and Local temperature sensor
+  https://www.ti.com/lit/ds/symlink/tmp464.pdf
+  https://www.ti.com/lit/ds/symlink/tmp468.pdf
+
+properties:
+  compatible:
+    enum:
+      - ti,tmp464
+      - ti,tmp468
+
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+patternProperties:
+  "^channel@([0-8])$":
+    type: object
+    description: |
+      Represents channels of the device and their specific configuration.
+
+    properties:
+      reg:
+        description: |
+          The channel number. 0 is local channel, 1-8 are remote channels.
+        items:
+          minimum: 0
+          maximum: 8
+
+      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/int8
+        items:
+          minimum: -128
+          maximum: 127
+
+    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 = /bits/ 8 <(-10)>;
+          label = "local";
+        };
+
+        channel@1 {
+          reg = <0x1>;
+          ti,n-factor = /bits/ 8 <0x0>;
+          label = "somelabel";
+        };
+
+        channel@2 {
+          reg = <0x2>;
+          status = "disabled";
+        };
+      };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index fca970a46e77..f51bc7c7e439 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19489,6 +19489,13 @@  S:	Maintained
 F:	Documentation/hwmon/tmp401.rst
 F:	drivers/hwmon/tmp401.c
 
+TMP464 HARDWARE MONITOR DRIVER
+M:	Agathe Porte <agathe.porte@nokia.com>
+M:	Guenter Roeck <linux@roeck-us.net>
+L:	linux-hwmon@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
+
 TMP513 HARDWARE MONITOR DRIVER
 M:	Eric Tremblay <etremblay@distech-controls.com>
 L:	linux-hwmon@vger.kernel.org