dt-bindings: iio: Add MCP9600 thermocouple EMF converter bindings
Subsystems (2)
PATCH v3 1/2 dt-bindings: iio: Add MCP9600 thermocouple EMF converter bindings
Add support for the MCP9600 thermocouple EMF converter.
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf
---
Changes for v3:
- Added dt-bindings
--- .../iio/temperature/microchip,mcp9600.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +72 -0
@@ -0,0 +1,72 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/microchip,mcp9600.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip MCP9600 thermocouple EMF converter + +maintainers: + - Andrew Hepp <[email protected]> + +description: | + https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf + +properties: + compatible: + const: microchip,mcp9600 + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 6 + + interrupt-names: + minItems: 1 + maxItems: 6 + items: + enum: + - open + - short + - alert1 + - alert2 + - alert3 + - alert4 + + thermocouple-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Type of thermocouple (THERMOCOUPLE_TYPE_K if omitted). + Use defines in dt-bindings/iio/temperature/thermocouple.h. + Supported types are B, E, J, K, N, R, S, T. + + vdd-supply: + description: Regulator that provides power to the sensor. + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/iio/temperature/thermocouple.h> + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + mcp9600@60 { + compatible = "microchip,mcp9600"; + reg = <0x60>; + interrupt-parent = <&gpio>; + interrupts = <25 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "open"; + thermocouple-type = <THERMOCOUPLE_TYPE_K>; + vdd-supply = <&vdd>; + }; + };
Signature · 1 line
2.30.2
PATCH v3 2/2 iio: temperature: Add MCP9600 thermocouple EMF converter driver
Add support for the MCP9600 thermocouple EMF converter.
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf
---
Changes for v3:
- none
Changes for v2:
- remove unused sysfs include
- remove unused scan fields from channel
- warn rather than fail when probing unknown device
- register device through devm
- clean up style and prints
--- drivers/iio/temperature/Kconfig | 10 ++ drivers/iio/temperature/Makefile | 1 + drivers/iio/temperature/mcp9600.c | 146 ++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 drivers/iio/temperature/mcp9600.c
drivers/iio/temperature/Kconfig +10 -0
@@ -158,4 +158,14 @@ config MAX31865 This driver can also be build as a module. If so, the module will be called max31865. +config MCP9600 + tristate "MCP9600 thermocouple EMF converter" + depends on I2C + help + If you say yes here you get support for MCP9600 + thermocouple EMF converter connected via I2C. + + This driver can also be built as a module. If so, the module + will be called mcp9600. + endmenu
drivers/iio/temperature/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_MAXIM_THERMOCOUPLE) += maxim_thermocouple.o obj-$(CONFIG_MAX30208) += max30208.o obj-$(CONFIG_MAX31856) += max31856.o obj-$(CONFIG_MAX31865) += max31865.o +obj-$(CONFIG_MCP9600) += mcp9600.o obj-$(CONFIG_MLX90614) += mlx90614.o obj-$(CONFIG_MLX90632) += mlx90632.o obj-$(CONFIG_TMP006) += tmp006.o
drivers/iio/temperature/mcp9600.c new file +146 -0
146 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 4 lines · Andrew Hepp
Add support for the MCP9600 thermocouple EMF converter.
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf
Signed-off-by Andrew Hepp <[email protected]>
Thank you for your patch. There is something to discuss/improve.
Quoted 1 line
+description: |
Drop '|'
Quoted 8 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +8
-0+ https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf + +properties: + compatible: + const: microchip,mcp9600 + + reg: + maxItems: 1
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 30
Quoted 10 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +10
-0+ + interrupts: + minItems: 1 + maxItems: 6 + + interrupt-names: + minItems: 1 + maxItems: 6 + items: + enum:
The interrupts should be usually strictly ordered and you allow any combinations. Why?
Why are they optional?
Quoted 16 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +16
-0+ - open + - short + - alert1 + - alert2 + - alert3 + - alert4 + + thermocouple-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Type of thermocouple (THERMOCOUPLE_TYPE_K if omitted). + Use defines in dt-bindings/iio/temperature/thermocouple.h. + Supported types are B, E, J, K, N, R, S, T. + + vdd-supply: + description: Regulator that provides power to the sensor.
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +10
-0+ +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h>
No need for this header.
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 63
Quoted 7 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +7
-0+ #include <dt-bindings/iio/temperature/thermocouple.h> + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + mcp9600@60 {
Node names should be generic, so temp-sensor, thermocouple or something else matching the type.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 65
Quoted 2 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +2
-0+ compatible = "microchip,mcp9600"; + reg = <0x60>;
Best regards,
Krzysztof
Hi Krzysztof,
Appreciate the feedback! Snipping for brevity.
On 3/4/23 3:20 AM, Krzysztof Kozlowski wrote:
...
Quoted 15 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 30
Quoted 11 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +11
-0+ maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 6 + + interrupt-names: + minItems: 1 + maxItems: 6 + items: + enum:The interrupts should be usually strictly ordered and you allow any combinations. Why?
Quoted 1 line
Why are they optional?
The driver as currently written doesn’t support any interrupts. The device does not require interrupts to function.
This is the first dt-binding I’ve written, so it’s very possible that I’ve made a mistake, but I believe any combination of interrupts should be valid. Each of the interrupts listed represent an independent physical pin of the mcp960x chip. That pin might not be connected at all, so it seems to me that any combination of interrupts should be allowed.
MCP9600 and MCP9601 chips have four alert interrupts that trigger when temperature crosses a threshold (with configurable hysteresis). The MCP9601 adds short and open circuit detection interrupts.
Quoted 10 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 38
Quoted 10 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +8
-0+ - open + - short + - alert1 + - alert2 + - alert3 + - alert4 + + thermocouple-type:
...
Thanks,
Andy
Jonathan Cameron
maintainerQuoted 33 lines · On Sat, 4 Mar 2023 04:36:49 -0800 Andrew Hepp <[email protected]> wrote:
Hi Krzysztof,
Appreciate the feedback! Snipping for brevity.
On 3/4/23 3:20 AM, Krzysztof Kozlowski wrote:
...
Quoted 15 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 30
Quoted 11 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +11
-0+ maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 6 + + interrupt-names: + minItems: 1 + maxItems: 6 + items: + enum:The interrupts should be usually strictly ordered and you allow any combinations. Why?
Quoted 1 line
Why are they optional?
The driver as currently written doesn’t support any interrupts. The device does not require interrupts to function.
This is the first dt-binding I’ve written, so it’s very possible that I’ve made a mistake, but I believe any combination of interrupts should be valid. Each of the interrupts listed represent an independent physical pin of the mcp960x chip. That pin might not be connected at all, so it seems to me that any combination of interrupts should be allowed.
Quoted 3 lines
MCP9600 and MCP9601 chips have four alert interrupts that trigger when temperature crosses a threshold (with configurable hysteresis). The MCP9601 adds short and open circuit detection interrupts.
This is a very common situation for sensors, hence the use of interrupt-names to allow us to specify any subset. A driver using these will then need to cope with a random subset (of course it's allowed to just not use any of them at all if only some are wired, or any other policy the driver author wants to use).
Board designers love to save pins on their interrupt controller so not wiring them all up is very common.
Jonathan
Quoted 15 lines
Quoted 11 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 38
Quoted 11 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +8
-0+ - open + - short + - alert1 + - alert2 + - alert3 + - alert4 + + thermocouple-type:...
Thanks,
Andy
Jonathan Cameron
maintainerQuoted 39 lines · On Fri, 3 Mar 2023 16:41:08 -0800 Andrew Hepp <[email protected]> wrote:
Add support for the MCP9600 thermocouple EMF converter.
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf
Signed-off-by Andrew Hepp <[email protected]>---
Changes for v3:
- Added dt-bindings--- .../iio/temperature/microchip,mcp9600.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yamlDocumentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +21
-0@@ -0,0 +1,72 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/microchip,mcp9600.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip MCP9600 thermocouple EMF converter + +maintainers: + - Andrew Hepp <[email protected]> + +description: | + https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf + +properties: + compatible: + const: microchip,mcp9600 + + reg: + maxItems: 1 +
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 31
Quoted 10 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +10
-0+ interrupts: + minItems: 1 + maxItems: 6 + + interrupt-names: + minItems: 1 + maxItems: 6 + items: + enum: + - open
Perhaps make it more explicit? open-circuit
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 32
Quoted 1 line
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +1
-0+ - short
Same here? short-circuit
Quoted 4 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +4
-0+ - alert1 + - alert2 + - alert3 + - alert4
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml line 46
Quoted 10 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +10
-0+ + thermocouple-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Type of thermocouple (THERMOCOUPLE_TYPE_K if omitted). + Use defines in dt-bindings/iio/temperature/thermocouple.h. + Supported types are B, E, J, K, N, R, S, T. + + vdd-supply: + description: Regulator that provides power to the sensor.
I'd count that one as so common it doesn't need a description.
vdd-supply: true
would be sufficient.
Quoted 26 lines
Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file +26
-0+ +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/iio/temperature/thermocouple.h> + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + mcp9600@60 { + compatible = "microchip,mcp9600"; + reg = <0x60>; + interrupt-parent = <&gpio>; + interrupts = <25 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "open"; + thermocouple-type = <THERMOCOUPLE_TYPE_K>; + vdd-supply = <&vdd>; + }; + };