From: Victor Duicu <victor.duicu@microchip.com>
This is the devicetree schema for Microchip MCP998X/33 and
MCP998XD/33D Automotive Temperature Monitor Family.
Signed-off-by: Victor Duicu <victor.duicu@microchip.com>
---
.../iio/temperature/microchip,mcp9982.yaml | 211 ++++++++++++++++++
1 file changed, 211 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml
diff --git a/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml
new file mode 100644
index 000000000000..ec939d463612
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml
@@ -0,0 +1,211 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/temperature/microchip,mcp9982.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip MCP998X/33 and MCP998XD/33D Multichannel Automotive
+ Temperature Monitor Family
+
+maintainers:
+ - Victor Duicu <victor.duicu@microchip.com>
+
+description: |
+ The MCP998X/33 and MCP998XD/33D family is a high-accuracy 2-wire multichannel
+ automotive temperature monitor.
+ The datasheet can be found here:
+ https://ww1.microchip.com/downloads/aemDocuments/documents/MSLD/ProductDocuments/DataSheets/MCP998X-Family-Data-Sheet-DS20006827.pdf
+
+properties:
+ compatible:
+ enum:
+ - microchip,mcp9933
+ - microchip,mcp9933d
+ - microchip,mcp9982
+ - microchip,mcp9982d
+ - microchip,mcp9983
+ - microchip,mcp9983d
+ - microchip,mcp9984
+ - microchip,mcp9984d
+ - microchip,mcp9985
+ - microchip,mcp9985d
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ minItems: 2
+ maxItems: 2
+
+ interrupt-names:
+ description:
+ -alert-therm is used to handle a HIGH or LOW limit.
+ -therm-addr is used to handle a THERM limit on chips
+ without "D" in the name.
+ -sys-shutdown is used to handle a THERM limit on chips
+ with "D" in the name.
+ items:
+ - const: alert-therm
+ - const: therm-addr
+ - const: sys-shutdown
+
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+ microchip,enable-anti-parallel:
+ description:
+ Enable anti-parallel diode mode operation.
+ MCP9984/84D/85/85D and MCP9933/33D support reading two external diodes
+ in anti-parallel connection on the same set of pins.
+ type: boolean
+
+ microchip,beta1:
+ description:
+ Set beta compensation value for external channel 1.
+ <0> 0.050
+ <1> 0.066
+ <2> 0.087
+ <3> 0.114
+ <4> 0.150
+ <5> 0.197
+ <6> 0.260
+ <7> 0.342
+ <8> 0.449
+ <9> 0.591
+ <10> 0.778
+ <11> 1.024
+ <12> 1.348
+ <13> 1.773
+ <14> 2.333
+ <15> Diode_Mode
+ <16> Auto
+ - Diode_Mode is used when measuring a discrete thermal diode
+ or a CPU diode that functions like a discrete thermal diode.
+ - Auto enables beta auto-detection. The chip monitors
+ external diode/transistor and determines the optimum
+ setting.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ default: 16
+
+ microchip,beta2:
+ description:
+ Set beta compensation value for external channel 2.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ default: 16
+
+ microchip,resistance-comp-ch1-2-enable:
+ description:
+ Enable resistance error correction(REC) for external channels 1 and 2.
+ The chip internal hardware counterbalances the parasitic resistance in
+ series with the external diodes. The compensation can be activated or
+ disabled in hardware for both channels 1 and 2 at the same time.
+ type: boolean
+
+ microchip,resistance-comp-ch3-4-enable:
+ description:
+ Enable resistance error correction(REC) for external channels 3 and 4.
+ The chip internal hardware counterbalances the parasitic resistance in
+ series with the external diodes. The compensation can be activated or
+ disabled in hardware for both channels 3 and 4 at the same time.
+ type: boolean
+
+
+ vdd-supply: true
+
+patternProperties:
+ "^channel@[1-4]$":
+ description:
+ Represents the external temperature channels to which
+ a remote diode is connected.
+ type: object
+
+ properties:
+ reg:
+ items:
+ minimum: 1
+ maximum: 4
+
+ microchip,ideality-factor:
+ description:
+ Each channel has an ideality factor.
+ Beta compensation and resistance error correction automatically
+ correct for most ideality errors. So ideality factor does not need
+ to be adjusted in general.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ default: 18
+
+ label:
+ description: Unique name to identify which channel this is.
+
+ required:
+ - reg
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - vdd-supply
+
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - microchip,mcp9982d
+ - microchip,mcp9983d
+ - microchip,mcp9984d
+ - microchip,mcp9985d
+ - microchip,mcp9933d
+ then:
+ properties:
+ interrupts-names:
+ items:
+ - const: alert-therm
+ - const: sys-shutdown
+ else:
+ properties:
+ interrupts-names:
+ items:
+ - const: alert-therm
+ - const: therm-addr
+
+additionalProperties: false
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ temperature-sensor@4c {
+ compatible = "microchip,mcp9985";
+ reg = <0x4c>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ microchip,enable-anti-parallel;
+ microchip,resistance-comp-ch1-2-enable;
+ microchip,resistance-comp-ch3-4-enable;
+ microchip,beta1 = <16>;
+ microchip,beta2 = <16>;
+ vdd-supply = <&vdd>;
+
+ channel@1 {
+ reg = <1>;
+ label = "CPU Temperature";
+ };
+
+ channel@2 {
+ reg = <2>;
+ label = "GPU Temperature";
+ };
+ };
+ };
+
+...
--
2.48.1
Hi everyone, I am writing this message to ask your opinions regarding the placement of temperature range property from the MCP998X/XD family in the devicetree. The reason why I am bringing back this topic is due to a limitation of the chips. When the moving average filter is enabled, the old readings are kept and new readings are added to the average. This is a problem when changing the range of temperatures. The raw temperature values change based on the range so the mixed values will give erroneous results during averaging. One possible workaround for this behavior is to set the temperature range before runtime, to not allow the user to change it. Initially, in the first patch, I have placed the property microchip,extended-temp-range in the devicetree. At that point I mistakenly did not include Conor, Krzysztof and Rob in the discussion and I would like to ask for comments. Below is the discussion between me and Jonathan from patch v1: > > > > + > > > > + microchip,extended-temp-range: > > > > + description: | > > > > + Set the chip to work in the extended temperature range > > > > -64 > > > > degrees C to 191.875 degrees C. > > > > + Omit this tag to set the default range 0 degrees C to > > > > 127.875 degrees C > > > > + type: boolean > > > > > > I'm curious. Why does this belong in the DT binding? > > > > > > > Regarding microchip,extended-temp-range, my perspective is that the > > user knows beforehand which specific range of temperatures he > > needs. > > For example, if the device to be measured is a freezer, the user > > would > > be interested in temperatures below 0 degrees C. If we monitor a > > CPU, > > the user would be interested in temperatures above 0 degrees C. > > Maybe - though also easy to control from userspace by making the > offset writeable. Thank you, Victor Duicu On Fri, 2025-06-13 at 16:02 +0300, victor.duicu@microchip.com wrote: > From: Victor Duicu <victor.duicu@microchip.com> > > This is the devicetree schema for Microchip MCP998X/33 and > MCP998XD/33D Automotive Temperature Monitor Family. > > Signed-off-by: Victor Duicu <victor.duicu@microchip.com> > --- > .../iio/temperature/microchip,mcp9982.yaml | 211 > ++++++++++++++++++ > 1 file changed, 211 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.y > aml > > diff --git > a/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982 > .yaml > b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982 > .yaml > new file mode 100644 > index 000000000000..ec939d463612 > --- /dev/null > +++ > b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982 > .yaml > @@ -0,0 +1,211 @@ > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: > http://devicetree.org/schemas/iio/temperature/microchip,mcp9982.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Microchip MCP998X/33 and MCP998XD/33D Multichannel Automotive > + Temperature Monitor Family > + > +maintainers: > + - Victor Duicu <victor.duicu@microchip.com> > + > +description: | > + The MCP998X/33 and MCP998XD/33D family is a high-accuracy 2-wire > multichannel > + automotive temperature monitor. > + The datasheet can be found here: > + > https://ww1.microchip.com/downloads/aemDocuments/documents/MSLD/ProductDocuments/DataSheets/MCP998X-Family-Data-Sheet-DS20006827.pdf > + > +properties: > + compatible: > + enum: > + - microchip,mcp9933 > + - microchip,mcp9933d > + - microchip,mcp9982 > + - microchip,mcp9982d > + - microchip,mcp9983 > + - microchip,mcp9983d > + - microchip,mcp9984 > + - microchip,mcp9984d > + - microchip,mcp9985 > + - microchip,mcp9985d > + > + reg: > + maxItems: 1 > + > + interrupts: > + minItems: 2 > + maxItems: 2 > + > + interrupt-names: > + description: > + -alert-therm is used to handle a HIGH or LOW limit. > + -therm-addr is used to handle a THERM limit on chips > + without "D" in the name. > + -sys-shutdown is used to handle a THERM limit on chips > + with "D" in the name. > + items: > + - const: alert-therm > + - const: therm-addr > + - const: sys-shutdown > + > + "#address-cells": > + const: 1 > + > + "#size-cells": > + const: 0 > + > + microchip,enable-anti-parallel: > + description: > + Enable anti-parallel diode mode operation. > + MCP9984/84D/85/85D and MCP9933/33D support reading two > external diodes > + in anti-parallel connection on the same set of pins. > + type: boolean > + > + microchip,beta1: > + description: > + Set beta compensation value for external channel 1. > + <0> 0.050 > + <1> 0.066 > + <2> 0.087 > + <3> 0.114 > + <4> 0.150 > + <5> 0.197 > + <6> 0.260 > + <7> 0.342 > + <8> 0.449 > + <9> 0.591 > + <10> 0.778 > + <11> 1.024 > + <12> 1.348 > + <13> 1.773 > + <14> 2.333 > + <15> Diode_Mode > + <16> Auto > + - Diode_Mode is used when measuring a discrete thermal diode > + or a CPU diode that functions like a discrete thermal diode. > + - Auto enables beta auto-detection. The chip monitors > + external diode/transistor and determines the optimum > + setting. > + $ref: /schemas/types.yaml#/definitions/uint32 > + default: 16 > + > + microchip,beta2: > + description: > + Set beta compensation value for external channel 2. > + $ref: /schemas/types.yaml#/definitions/uint32 > + default: 16 > + > + microchip,resistance-comp-ch1-2-enable: > + description: > + Enable resistance error correction(REC) for external channels > 1 and 2. > + The chip internal hardware counterbalances the parasitic > resistance in > + series with the external diodes. The compensation can be > activated or > + disabled in hardware for both channels 1 and 2 at the same > time. > + type: boolean > + > + microchip,resistance-comp-ch3-4-enable: > + description: > + Enable resistance error correction(REC) for external channels > 3 and 4. > + The chip internal hardware counterbalances the parasitic > resistance in > + series with the external diodes. The compensation can be > activated or > + disabled in hardware for both channels 3 and 4 at the same > time. > + type: boolean > + > + > + vdd-supply: true > + > +patternProperties: > + "^channel@[1-4]$": > + description: > + Represents the external temperature channels to which > + a remote diode is connected. > + type: object > + > + properties: > + reg: > + items: > + minimum: 1 > + maximum: 4 > + > + microchip,ideality-factor: > + description: > + Each channel has an ideality factor. > + Beta compensation and resistance error correction > automatically > + correct for most ideality errors. So ideality factor does > not need > + to be adjusted in general. > + $ref: /schemas/types.yaml#/definitions/uint32 > + default: 18 > + > + label: > + description: Unique name to identify which channel this is. > + > + required: > + - reg > + > + additionalProperties: false > + > +required: > + - compatible > + - reg > + - vdd-supply > + > +allOf: > + - if: > + properties: > + compatible: > + contains: > + enum: > + - microchip,mcp9982d > + - microchip,mcp9983d > + - microchip,mcp9984d > + - microchip,mcp9985d > + - microchip,mcp9933d > + then: > + properties: > + interrupts-names: > + items: > + - const: alert-therm > + - const: sys-shutdown > + else: > + properties: > + interrupts-names: > + items: > + - const: alert-therm > + - const: therm-addr > + > +additionalProperties: false > + > +examples: > + - | > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + > + temperature-sensor@4c { > + compatible = "microchip,mcp9985"; > + reg = <0x4c>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + microchip,enable-anti-parallel; > + microchip,resistance-comp-ch1-2-enable; > + microchip,resistance-comp-ch3-4-enable; > + microchip,beta1 = <16>; > + microchip,beta2 = <16>; > + vdd-supply = <&vdd>; > + > + channel@1 { > + reg = <1>; > + label = "CPU Temperature"; > + }; > + > + channel@2 { > + reg = <2>; > + label = "GPU Temperature"; > + }; > + }; > + }; > + > +...
On 7/28/25 8:01 AM, Victor.Duicu@microchip.com wrote: > Hi everyone, > > I am writing this message to ask your opinions regarding the placement > of temperature range property from the MCP998X/XD family in the > devicetree. > > The reason why I am bringing back this topic is due to a limitation of > the chips. When the moving average filter is enabled, the old readings > are kept and new readings are added to the average. This is a problem > when changing the range of temperatures. The raw temperature values > change based on the range so the mixed values will give erroneous > results during averaging. > > One possible workaround for this behavior is to set the temperature > range before runtime, to not allow the user to change it. It looks like it is just a an average of the last 8 samples at most. So if there isn't a way to reset the chip memory that holds those 8 samples, we could just read 8 samples and throw away the values before giving data to userspace any time we start sampling. Even without changing the temperature range, we would still have old values and possibly the same issue of stale data possibly influencing the measurements any time we stop sampling and start again. So I'm not seeing that this temperature range setting should be a special case. It still sounds like something better suited to be set at runtime. > > Initially, in the first patch, I have placed the property > microchip,extended-temp-range in the devicetree. > At that point I mistakenly did not include Conor, Krzysztof and Rob in > the discussion and I would like to ask for comments. >
On Fri, Jun 13, 2025 at 04:02:06PM +0300, victor.duicu@microchip.com wrote: > From: Victor Duicu <victor.duicu@microchip.com> > > This is the devicetree schema for Microchip MCP998X/33 and > MCP998XD/33D Automotive Temperature Monitor Family. > > Signed-off-by: Victor Duicu <victor.duicu@microchip.com> > --- > .../iio/temperature/microchip,mcp9982.yaml | 211 ++++++++++++++++++ > 1 file changed, 211 insertions(+) > create mode 100644 Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml > > diff --git a/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml > new file mode 100644 > index 000000000000..ec939d463612 > --- /dev/null > +++ b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982.yaml > @@ -0,0 +1,211 @@ > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/iio/temperature/microchip,mcp9982.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Microchip MCP998X/33 and MCP998XD/33D Multichannel Automotive > + Temperature Monitor Family > + > +maintainers: > + - Victor Duicu <victor.duicu@microchip.com> > + > +description: | > + The MCP998X/33 and MCP998XD/33D family is a high-accuracy 2-wire multichannel > + automotive temperature monitor. > + The datasheet can be found here: > + https://ww1.microchip.com/downloads/aemDocuments/documents/MSLD/ProductDocuments/DataSheets/MCP998X-Family-Data-Sheet-DS20006827.pdf > + > +properties: > + compatible: > + enum: > + - microchip,mcp9933 > + - microchip,mcp9933d > + - microchip,mcp9982 > + - microchip,mcp9982d > + - microchip,mcp9983 > + - microchip,mcp9983d > + - microchip,mcp9984 > + - microchip,mcp9984d > + - microchip,mcp9985 > + - microchip,mcp9985d > + > + reg: > + maxItems: 1 > + > + interrupts: > + minItems: 2 > + maxItems: 2 > + > + interrupt-names: > + description: > + -alert-therm is used to handle a HIGH or LOW limit. > + -therm-addr is used to handle a THERM limit on chips > + without "D" in the name. > + -sys-shutdown is used to handle a THERM limit on chips > + with "D" in the name. > + items: > + - const: alert-therm > + - const: therm-addr > + - const: sys-shutdown > + > + "#address-cells": > + const: 1 > + > + "#size-cells": > + const: 0 > + > + microchip,enable-anti-parallel: > + description: > + Enable anti-parallel diode mode operation. > + MCP9984/84D/85/85D and MCP9933/33D support reading two external diodes > + in anti-parallel connection on the same set of pins. > + type: boolean > + > + microchip,beta1: > + description: > + Set beta compensation value for external channel 1. > + <0> 0.050 > + <1> 0.066 > + <2> 0.087 > + <3> 0.114 > + <4> 0.150 > + <5> 0.197 > + <6> 0.260 > + <7> 0.342 > + <8> 0.449 > + <9> 0.591 > + <10> 0.778 > + <11> 1.024 > + <12> 1.348 > + <13> 1.773 > + <14> 2.333 > + <15> Diode_Mode > + <16> Auto > + - Diode_Mode is used when measuring a discrete thermal diode > + or a CPU diode that functions like a discrete thermal diode. > + - Auto enables beta auto-detection. The chip monitors > + external diode/transistor and determines the optimum > + setting. > + $ref: /schemas/types.yaml#/definitions/uint32 > + default: 16 Missing max/min constraints on the property. > + > + microchip,beta2: > + description: > + Set beta compensation value for external channel 2. > + $ref: /schemas/types.yaml#/definitions/uint32 > + default: 16 > + > + microchip,resistance-comp-ch1-2-enable: > + description: > + Enable resistance error correction(REC) for external channels 1 and 2. > + The chip internal hardware counterbalances the parasitic resistance in > + series with the external diodes. The compensation can be activated or > + disabled in hardware for both channels 1 and 2 at the same time. > + type: boolean On the previous version I objected to this wording for the property, where it is being used as an enable, and instead said that it should indicate the presence of the parasitic resistance. Did I miss some sort of new justification for it still talking about being an enable? > + microchip,resistance-comp-ch3-4-enable: > + description: > + Enable resistance error correction(REC) for external channels 3 and 4. > + The chip internal hardware counterbalances the parasitic resistance in > + series with the external diodes. The compensation can be activated or > + disabled in hardware for both channels 3 and 4 at the same time. > + type: boolean Cheers, Conor.
On Fri, 2025-06-13 at 15:40 +0100, Conor Dooley wrote: > On Fri, Jun 13, 2025 at 04:02:06PM +0300, > victor.duicu@microchip.com wrote: > > From: Victor Duicu <victor.duicu@microchip.com> > > Hi Conor, > > This is the devicetree schema for Microchip MCP998X/33 and > > MCP998XD/33D Automotive Temperature Monitor Family. > > > > Signed-off-by: Victor Duicu <victor.duicu@microchip.com> > > --- > > .../iio/temperature/microchip,mcp9982.yaml | 211 > > ++++++++++++++++++ > > 1 file changed, 211 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/iio/temperature/microchip,mcp9982 > > .yaml > > > > diff --git > > a/Documentation/devicetree/bindings/iio/temperature/microchip,mcp99 > > 82.yaml > > b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp99 > > 82.yaml > > new file mode 100644 > > index 000000000000..ec939d463612 > > --- /dev/null > > +++ > > b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp99 > > 82.yaml > > @@ -0,0 +1,211 @@ > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) > > > > + > > + microchip,resistance-comp-ch1-2-enable: > > + description: > > + Enable resistance error correction(REC) for external > > channels 1 and 2. > > + The chip internal hardware counterbalances the parasitic > > resistance in > > + series with the external diodes. The compensation can be > > activated or > > + disabled in hardware for both channels 1 and 2 at the same > > time. > > + type: boolean > > On the previous version I objected to this wording for the property, > where it is being used as an enable, and instead said that it should > indicate the presence of the parasitic resistance. Did I miss some > sort > of new justification for it still talking about being an enable? > My apologies, I forgot to modify the name of the variable. I will change the variables to something like: microchip,parasitic-res-on-channel1-2: description: Indicates that the chip and the diodes/transistors are sufficiently far apart that a parasitic resistance is added to the wires, which can affect the measurements. Due to the anti-parallel diode connections, channels 1 and 2 are affected together. > > > + microchip,resistance-comp-ch3-4-enable: > > + description: > > + Enable resistance error correction(REC) for external > > channels 3 and 4. > > + The chip internal hardware counterbalances the parasitic > > resistance in > > + series with the external diodes. The compensation can be > > activated or > > + disabled in hardware for both channels 3 and 4 at the same > > time. > > + type: boolean > With Kind Regards, Victor Duicu > Cheers, > Conor.
© 2016 - 2025 Red Hat, Inc.