Skip to contentSkip to conversation

dt-bindings: hwmon: add tmp464.yaml

PATCH Superseded Guenter Roeck 2 participants 4 messages Feb 16, 2022

Subsystems (3)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH v3 1/2 dt-bindings: hwmon: add tmp464.yaml

From: Agathe Porte <[email protected]>

Add basic description of the tmp464 driver DT bindings.

---
Note:
I had previously asked to add more detailed bindings, but concluded that those should be provided in a generic temperature sensor schema. I'll try to introduce such a schema separately.

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
Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml new file +109 -0
new file mode 100644
index 000000000000..8ce4be729494
@@ -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 <[email protected]>
+
+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";
+        };
+      };
+    };
MAINTAINERS +7 -0
index fca970a46e77..f51bc7c7e439 100644
@@ -19489,6 +19489,13 @@ S:	Maintained
 F:	Documentation/hwmon/tmp401.rst
 F:	drivers/hwmon/tmp401.c
 
+TMP464 HARDWARE MONITOR DRIVER
+M:	Agathe Porte <[email protected]>
+M:	Guenter Roeck <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
+
 TMP513 HARDWARE MONITOR DRIVER
 M:	Eric Tremblay <[email protected]>
 L:	[email protected]
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH v3 2/2 hwmon: Add driver for Texas Instruments TMP464 and TMP468

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 <[email protected]>

Cc Agathe Porte <[email protected]>
Cc Krzysztof Adamski <[email protected]>

---
v3:
- Added support for TMP468
- Added support for various limits, temperature hysteresis, alarm attributes, and update interval
- Use regmap instead of local caching
- Use static chip configuration
- Unlock check if needed when loading driver, and lock it when unloading it
- Call tmp464_init_client() before calling tmp464_probe_from_dt() since the latter changes registers, which requires the chip to be unlocked.
- Restore configuration register when unloading driver
- ti,n-factor is optional, so don't fail if the property is not present

Notes:
- Tested with real TMP468. Module tested for TMP464.
- I was not able to test with a system supporting devicetree; especially negative values for "ti,n-factor" need testing (and I wonder if of_property_read_s8() would be needed to support this properly).

 Documentation/hwmon/index.rst  |   1 +
 Documentation/hwmon/tmp464.rst |  73 ++++
 MAINTAINERS                    |   2 +
 drivers/hwmon/Kconfig          |  11 +
 drivers/hwmon/Makefile         |   1 +
 drivers/hwmon/tmp464.c         | 693 +++++++++++++++++++++++++++++++++
 6 files changed, 781 insertions(+)
 create mode 100644 Documentation/hwmon/tmp464.rst
 create mode 100644 drivers/hwmon/tmp464.c
Documentation/hwmon/index.rst +1 -0
index df20022c741f..37590db85e65 100644
@@ -193,6 +193,7 @@ Hardware Monitoring Kernel Drivers
    tmp108
    tmp401
    tmp421
+   tmp464
    tmp513
    tps23861
    tps40422
Documentation/hwmon/tmp464.rst new file +73 -0

73 lines not on this page · raw message

MAINTAINERS +2 -0
index f51bc7c7e439..9b51bf5ca3b8 100644
@@ -19495,6 +19495,8 @@ M:	Guenter Roeck <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/hwmon/ti,tmp464.yaml
+F:	Documentation/hwmon/tmp464.rst
+F:	drivers/hwmon/tmp464.c
 
 TMP513 HARDWARE MONITOR DRIVER
 M:	Eric Tremblay <[email protected]>
drivers/hwmon/Kconfig +11 -0
index 8df25f1079ba..b84932fd0c13 100644
@@ -1979,6 +1979,17 @@ config SENSORS_TMP421
 	  This driver can also be built as a module. If so, the module
 	  will be called tmp421.
 
+config SENSORS_TMP464
+	tristate "Texas Instruments TMP464 and compatible"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  If you say yes here you get support for Texas Instruments TMP464
+	  and TMP468 temperature sensor chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called tmp464.
+
 config SENSORS_TMP513
 	tristate "Texas Instruments TMP513 and compatibles"
 	depends on I2C
drivers/hwmon/Makefile +1 -0
index 185f946d698b..a1f2d6686227 100644
@@ -194,6 +194,7 @@ obj-$(CONFIG_SENSORS_TMP103)	+= tmp103.o
 obj-$(CONFIG_SENSORS_TMP108)	+= tmp108.o
 obj-$(CONFIG_SENSORS_TMP401)	+= tmp401.o
 obj-$(CONFIG_SENSORS_TMP421)	+= tmp421.o
+obj-$(CONFIG_SENSORS_TMP464)	+= tmp464.o
 obj-$(CONFIG_SENSORS_TMP513)	+= tmp513.o
 obj-$(CONFIG_SENSORS_VEXPRESS)	+= vexpress-hwmon.o
 obj-$(CONFIG_SENSORS_VIA_CPUTEMP)+= via-cputemp.o
drivers/hwmon/tmp464.c new file +693 -0

693 lines not on this page · raw message

Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH v3 2/2] hwmon: Add driver for Texas Instruments TMP464 and TMP468

Hi Guenter,

Le 16/02/2022 à 08:07, Guenter Roeck a écrit :

Quoted 27 lines

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 <[email protected]>

Cc Agathe Porte <[email protected]>
Cc Krzysztof Adamski <[email protected]>

---
v3:
- Added support for TMP468
- Added support for various limits, temperature hysteresis, alarm attributes, and update interval
- Use regmap instead of local caching
- Use static chip configuration
- Unlock check if needed when loading driver, and lock it when unloading it
- Call tmp464_init_client() before calling tmp464_probe_from_dt() since the latter changes registers, which requires the chip to be unlocked.
- Restore configuration register when unloading driver
- ti,n-factor is optional, so don't fail if the property is not present

Quoted 6 lines

Notes:
- Tested with real TMP468. Module tested for TMP464.
- I was not able to test with a system supporting devicetree; especially negative values for "ti,n-factor" need testing (and I wonder if of_property_read_s8() would be needed to support this properly).

I just did the test on our system and both positive and negative value n-factor fails.

With the following overlay:

/dts-v1/;
/plugin/;
/ {
        fragment@0 {
                target-path = "/soc/.../i2c@4/tmp464@49"; __overlay__ {
                        #address-cells = <1>; #size-cells = <0>;

                        channel@0 {
                                reg = <0x0>;
                                label = "local"; ti,n-factor = /bits/ 8 <(-10)>; };

                        channel@1 {
                                reg = <0x1>;
                                label = "ch1";
                        };

                        channel@2 {
                                reg = <0x2>;
                                label = "ch2";
                        };

                        channel@3 {
                                reg = <0x3>;
                                label = "ch3";
                        };

                        channel@4 {
                                reg = <0x4>;
                                label = "ch4";
                        };
                };
        };

};

I get the following probing error:

[ 3580.557425] tmp464: probe of 16-0049 failed with error -75

With a positive n-factor in the overlay (<(10)> instead of <(-10)>), the driver *does not load either*, with the same error message.

Without any n-factor set, the v3 driver you proposed loads just fine with the DT.

Any idea of where this could come from? This was probably not working in my own implementation either.

PS: check your spam folder eventually for my mail asking delivery details of the TMP464 samples.

Bests,

Agathe.

author maintainer
#3 lore raw

Re: [PATCH v3 2/2] hwmon: Add driver for Texas Instruments TMP464 and TMP468

Quoted 78 lines · Agathe Porte

Hi Guenter,

Le 16/02/2022 à 08:07, Guenter Roeck a écrit :

Quoted 27 lines

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 <[email protected]>

Cc Agathe Porte <[email protected]>
Cc Krzysztof Adamski <[email protected]>

---
v3:
- Added support for TMP468
- Added support for various limits, temperature hysteresis, alarm attributes, and update interval
- Use regmap instead of local caching
- Use static chip configuration
- Unlock check if needed when loading driver, and lock it when unloading it
   - Call tmp464_init_client() before calling tmp464_probe_from_dt() since the latter changes registers, which requires the chip to be unlocked.
- Restore configuration register when unloading driver
- ti,n-factor is optional, so don't fail if the property is not present

Quoted 6 lines

Notes:
- Tested with real TMP468. Module tested for TMP464.
- I was not able to test with a system supporting devicetree; especially negative values for "ti,n-factor" need testing (and I wonder if of_property_read_s8() would be needed to support this properly).

I just did the test on our system and both positive and negative value n-factor fails.

With the following overlay:

/dts-v1/;
/plugin/;
/ {
        fragment@0 {
                target-path = "/soc/.../i2c@4/tmp464@49"; __overlay__ {
                        #address-cells = <1>; #size-cells = <0>;

                        channel@0 {
                                reg = <0x0>;
                                label = "local"; ti,n-factor = /bits/ 8 <(-10)>; };

                        channel@1 {
                                reg = <0x1>;
                                label = "ch1";
                        };

                        channel@2 {
                                reg = <0x2>;
                                label = "ch2";
                        };

                        channel@3 {
                                reg = <0x3>;
                                label = "ch3";
                        };

                        channel@4 {
                                reg = <0x4>;
                                label = "ch4";
                        };
                };
        };

Quoted 6 lines

};

I get the following probing error:

[ 3580.557425] tmp464: probe of 16-0049 failed with error -75

I think that may be caused by using of_property_read_s32() for reading an 8-bit property. Can you try and replace of_property_read_s32() with of_property_read_u8() and the variable it points to to s8 ?

	s8 val;
	...
	err = of_property_read_u8(child, "ti,n-factor", &val);

There is no of_property_read_s8(), so we can not use that, but maybe using of_property_read_u8() does the trick.

Thanks,
Guenter

Quoted 12 lines

With a positive n-factor in the overlay (<(10)> instead of <(-10)>), the driver *does not load either*, with the same error message.

Without any n-factor set, the v3 driver you proposed loads just fine with the DT.

Any idea of where this could come from? This was probably not working in my own implementation either.

PS: check your spam folder eventually for my mail asking delivery details of the TMP464 samples.

Bests,

Agathe.