Skip to contentSkip to conversation

iio: temperature: Add support for LTC2983

PATCH Superseded Nuno Sá 1 participant 2 messages Sep 17, 2019

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Nuno Sá

author maintainer
#0 lore raw

PATCH v2 1/2 iio: temperature: Add support for LTC2983

The LTC2983 is a Multi-Sensor High Accuracy Digital Temperature Measurement System. It measures a wide variety of temperature sensors and digitally outputs the result, in °C or °F, with 0.1°C accuracy and 0.001°C resolution. It can measure the temperature of all standard thermocouples (type B,E,J,K,N,S,R,T), standard 2-,3-,4-wire RTDs, thermistors and diodes.

---
Changes in v2:
* Added some needed blank lines (for readability);
* Allocate iio_chan in the setup() function;
* Rename reset to sleep;
* Remove unneeded dev_dbg calls;
* Remove unneeded line wrapping;
* Remove unneeded comments;
* Remove extend_names. Use the standard ABI;
* Adapt the scales to report in millivolt and milli degrees;
* Adapt the of_property readings to the renaming of the properties;
* For custom thermistors, excitation-current cannot be set to Auto range.

 MAINTAINERS                       |    7 +
 drivers/iio/temperature/Kconfig   |   10 +
 drivers/iio/temperature/Makefile  |    1 +
 drivers/iio/temperature/ltc2983.c | 1436 +++++++++++++++++++++++++++++
 4 files changed, 1454 insertions(+)
 create mode 100644 drivers/iio/temperature/ltc2983.c
MAINTAINERS +7 -0
index f0c03740b9fb..14a256e785ca 100644
@@ -9491,6 +9491,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/iio/dac/ltc1660.txt
 F:	drivers/iio/dac/ltc1660.c
 
+LTC2983 IIO TEMPERATURE DRIVER
+M:	Nuno Sá <[email protected]>
+W:	http://ez.analog.com/community/linux-device-drivers
+L:	[email protected]
+S:	Supported
+F:	drivers/iio/temperature/ltc2983.c
+
 LTC4261 HARDWARE MONITOR DRIVER
 M:	Guenter Roeck <[email protected]>
 L:	[email protected]
drivers/iio/temperature/Kconfig +10 -0
index 737faa0901fe..04b5a67b593c 100644
@@ -4,6 +4,16 @@
 #
 menu "Temperature sensors"
 
+config LTC2983
+	tristate "Analog Devices Multi-Sensor Digital Temperature Measurement System"
+	depends on SPI
+	help
+	  Say yes here to build support for the LTC2983 Multi-Sensor
+	  high accuracy digital temperature measurement system.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called ltc2983.
+
 config MAXIM_THERMOCOUPLE
 	tristate "Maxim thermocouple sensors"
 	depends on SPI
drivers/iio/temperature/Makefile +1 -0
index baca4776ca0d..d6b850b0cf63 100644
@@ -3,6 +3,7 @@
 # Makefile for industrial I/O temperature drivers
 #
 
+obj-$(CONFIG_LTC2983) += ltc2983.o
 obj-$(CONFIG_HID_SENSOR_TEMP) += hid-sensor-temperature.o
 obj-$(CONFIG_MAXIM_THERMOCOUPLE) += maxim_thermocouple.o
 obj-$(CONFIG_MAX31856) += max31856.o
drivers/iio/temperature/ltc2983.c new file +1436 -0

1,436 lines not on this page · raw message

Signature · 1 line
2.23.0
author maintainer
#1 lore raw

PATCH v2 2/2 dt-bindings: iio: Add ltc2983 documentation

Document the LTC2983 temperature sensor devicetree bindings.

---
Changes in v2:
* Drop maxItems in non-array elements;
* Set adi,mux-delay-config-us instead of adi,mux-delay-config;
* Wrapped lines at 80 char;
* Added comas to enum elements;
* Use real units in adi,excitation-current;
* Moved some enums to minimum and maximum;
* Grouped patternProperties and moved reg property as a generic property.

 .../bindings/iio/temperature/adi,ltc2983.yaml | 406 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 2 files changed, 407 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml new file +406 -0
new file mode 100644
index 000000000000..df68b8233e5e
@@ -0,0 +1,406 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/temperature/adi,ltc2983.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices LTC2983 Multi-sensor Temperature system
+
+maintainers:
+  - Nuno Sá <[email protected]>
+
+description: |
+  Analog Devices LTC2983 Multi-Sensor Digital Temperature Measurement System
+  https://www.analog.com/media/en/technical-documentation/data-sheets/2983fc.pdf
+
+properties:
+  compatible:
+    enum:
+      - adi,ltc2983
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  adi,temperature-celcius:
+    description:
+      If this property is present, the temperature is reported in Celsius.
+    type: boolean
+
+  adi,mux-delay-config-us:
+    description:
+      The LTC2983 performs 2 or 3 internal conversion cycles per temperature
+      result. Each conversion cycle is performed with different excitation and
+      input multiplexer configurations. Prior to each conversion, these
+      excitation circuits and input switch configurations are changed and an
+      internal 1ms delay ensures settling prior to the conversion cycle in most
+      cases. An extra delay can be configured using this property. The value is
+      rounded to nearest 100us.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - maximum: 255
+
+  adi,filter-notch-freq:
+    description:
+      Set's the default setting of the digital filter. The default is
+      simultaneous 50/60Hz rejection.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 0
+      - maximum: 2
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+patternProperties:
+  ".*@([1-9]|1[0-9]|20)$":
+    type: object
+
+    properties:
+      reg:
+        description: |
+          The channel number. It can be connected to one of the 20 channels of
+          the device.
+        minimum: 1
+        maximum: 20
+
+    required:
+      - reg
+
+    patternProperties:
+      "^thermocouple@.*":
+        type: object
+        description: |
+          Represents a thermocouple sensor which is connected to one of the device
+          channels.
+
+        properties:
+          adi,sensor-type:
+            description: |
+              Identifies the type of thermocouple connected to the device.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - minimum: 1
+              - maximum: 8
+
+          adi,sensor-config:
+            description: |
+              Raw value which set's the sensor configuration. Look at table 14
+              of the datasheet for how to set this value for thermocouples.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - minimum: 1
+              - maximun: 15
+
+          adi,cold-junction-handle:
+            description: |
+              Phandle which points to a sensor object responsible for measuring
+              the thermocouple cold junction temperature.
+            $ref: "/schemas/types.yaml#/definitions/phandle"
+
+          adi,custom-sensor:
+            description: |
+              This is a table, where each entry should be a pair of
+              voltage(mv)-temperature(K). The entries must be given in nv and uK
+              so that, the original values must be multiplied by 1000000. For
+              more details look at table 69 and 70.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/int64-array
+              - minItems: 6
+              - maxItems: 128
+
+        required:
+          - adi,sensor-type
+
+      "^diode@.*":
+        type: object
+        description: |
+          Represents a diode sensor which is connected to one of the device
+          channels.
+
+        properties:
+          adi,sensor-type:
+            description: Identifies the sensor as a diode.
+            const: 28
+
+          adi,sensor-config:
+            description: |
+              Raw value which set's the sensor configuration. Look at table 17
+              of the datasheet for how to set this value for diodes.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - minimum: 0
+              - maximum: 7
+
+          adi,excitation-current-microamp:
+            description: |
+              This property controls the magnitude of the excitation current
+              applied to the diode. Depending on the number of conversions
+              cycles, this property will assume different predefined values on
+              each cycle. Just set the value of the first cycle (1l).
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - enum: [10, 20, 40, 80]
+
+          adi,ideal-factor-value:
+            description: |
+              This property sets the diode ideality factor. The real value must
+              be multiplied by 1000000 to remove the fractional part. For more
+              information look at table 20 of the datasheet.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+
+        required:
+          - adi,sensor-type
+
+      "^rtd@.*":
+        type: object
+        description: |
+          Represents a rtd sensor which is connected to one of the device channels.
+
+        properties:
+          reg:
+            minimum: 2
+
+          adi,sensor-type:
+            description: Identifies the type of RTD connected to the device.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - minimum: 10
+              - maximum: 17
+
+          adi,rsense-handle:
+            description: |
+              Phandle pointing to a rsense object associated with this RTD.
+            $ref: "/schemas/types.yaml#/definitions/phandle"
+
+          adi,sensor-config:
+            description: |
+              Raw value which set's the sensor configuration. Look at table 28
+              of the datasheet for how to set this value for RTD's.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - enum: [0, 1, 4, 5, 8, 9, 10, 12, 13, 14]
+
+          adi,excitation-current-microamp:
+            description: |
+              This property controls the magnitude of the excitation current
+              applied to the RTD.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - enum: [5, 10, 25, 50, 100, 250, 500, 1000]
+
+          adi,rtd-curve:
+            description: |
+              This property set the RTD curve used and the corresponding
+              Callendar-VanDusen constants. Look at table 30 of the datasheet.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - minimum: 0
+              - maximum: 3
+
+          adi,custom-sensor:
+            description: |
+              This is a table, where each entry should be a pair of
+              resistance(ohm)-temperature(K). The entries added here are in uohm
+              and uK. For more details values look at table 74 and 75.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint64-array
+              - minItems: 6
+              - maxItems: 128
+
+        required:
+          - adi,sensor-type
+          - adi,rsense-handle
+
+      "^thermistor@.*":
+        type: object
+        description: |
+          Represents a thermistor sensor which is connected to one of the device
+          channels.
+
+        properties:
+          adi,sensor-type:
+            description: |
+              Identifies the type of thermistor connected to the
+              device.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - minimum: 19
+              - maximum: 25
+
+          adi,rsense-handle:
+            description: |
+              Phandle pointing to a rsense object associated with this
+              thermistor.
+            $ref: "/schemas/types.yaml#/definitions/phandle"
+
+          adi,sensor-config:
+            description: |
+              Raw value which set's the sensor configuration. Look at table 52
+              of the datasheet for how to set this value for thermistors.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - minimum: 0
+              - maximum: 4
+
+          adi,excitation-current-nanoamp:
+            description: |
+              This property controls the magnitude of the excitation current
+              applied to the thermistor. Value 0 set's the sensor in auto-range
+              mode.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint32
+              - enum: [0, 250, 500, 1000, 5000, 10000, 25000, 50000, 100000,
+                       250000, 500000, 1000000]
+
+          adi,custom-sensor:
+            description: |
+              This is a table, where each entry should be a pair of
+              resistance(ohm)-temperature(K). The entries added here are in uohm
+              and uK only for custom thermistors. For more details look at table
+              78 and 79. Steinhart-Hart coefficients are also supported and can
+              be programmed into the device memory using this property. For
+              Steinhart sensors, this table has a constant size of 6 entries
+              (defining the coefficients) and the values are given in the raw
+              format. Look at table 82 for more information.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint64-array
+              - minItems: 6
+              - maxItems: 128
+
+        required:
+          - adi,sensor-type
+          - adi,rsense-handle
+
+      "^adc@.*":
+        type: object
+        description: Represents a channel which is being used as a direct adc.
+
+        properties:
+          adi,sensor-type:
+            description: Identifies the sensor as a direct adc.
+            const: 30
+
+          adi,single-ended:
+            description: Boolean property which set's the adc as single-ended.
+            type: boolean
+
+        required:
+          - adi,sensor-type
+
+      "^rsense@.*":
+        type: object
+        description: |
+          Represents a rsense which is connected to one of the device channels.
+          Rsense are used by thermistors and RTD's.
+
+        properties:
+          reg:
+            minimum: 2
+
+          adi,sensor-type:
+            description: Identifies the sensor as a rsense.
+            const: 29
+
+          adi,rsense-val-micro-ohms:
+            description: |
+              Sets the value of the sense resistor. Look at table 20 of the
+              datasheet for information.
+            allOf:
+              - $ref: /schemas/types.yaml#/definitions/uint64
+
+        required:
+          - adi,sensor-type
+          - adi, rsense-val
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    spi0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        sensor_ltc2983: ltc2983@0 {
+                compatible = "adi,ltc2983";
+                reg = <0>;
+
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                adi,temperature-celcius;
+                interrupts = <20 IRQ_TYPE_EDGE_RISING>;
+                interrupt-parent = <&gpio>;
+
+                thermocouple@18 {
+                        reg = <18>;
+                        adi,sensor-type = <8>; //Type B
+                        adi,sensor-config = <1>; //Differential, open-circuit current
+                        adi,cold-junction-handle = <&diode5>;
+                };
+
+                diode5: diode@5 {
+                        reg = <5>;
+                        adi,sensor-type = <28>;
+                };
+
+                rsense2: rsense@2 {
+                        reg = <2>;
+                        adi,sensor-type = <29>;
+                        adi,rsense-val-micro-ohms = /bits/ 64 <1200000000>; //1.2Kohms
+                };
+
+                rtd@14 {
+                        reg = <14>;
+                        adi,sensor-type = <15>; //PT1000
+                        /*2-wire, internal gnd, no current rotation*/
+                        adi,sensor-config = <1>;
+                        adi,excitation-current = <7>; //500uA
+                        adi,rsense-handle = <&rsense2>;
+                };
+
+                adc@10 {
+                        reg = <10>;
+                        adi,sensor-type = <30>;
+                        adi,single-ended;
+                };
+
+                thermistor@12 {
+                        reg = <12>;
+                        adi,sensor-type = <26>; //Steinhart
+                        adi,rsense-handle = <&rsense2>;
+                        adi,custom-sensor = /bits/ 64 <0x00F371EC 0x12345678
+                                        0x2C0F8733 0x10018C66 0xA0FEACCD
+                                        0x90021D99>; //6 entries
+                };
+
+                thermocouple@20 {
+                        reg = <20>;
+                        adi,sensor-type = <9>; //custom thermocouple
+                        adi,sensor-config = <8>; //single-ended
+                        adi,custom-sensor = /bits/ 64
+                                 <(-50220000) 0
+                                  (-30200000) 99100000
+                                  (-5300000) 135400000
+                                  0 273150000
+                                  40200000 361200000
+                                  55300000 522100000
+                                  88300000 720300000
+                                  132200000 811200000
+                                  188700000 922500000
+                                  460400000 1000000000>; //10 pairs
+               };
+
+        };
+    };
+...
MAINTAINERS +1 -0
index 14a256e785ca..f747a9dc27f5 100644
@@ -9497,6 +9497,7 @@ W:	http://ez.analog.com/community/linux-device-drivers
 L:	[email protected]
 S:	Supported
 F:	drivers/iio/temperature/ltc2983.c
+F:	Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
 
 LTC4261 HARDWARE MONITOR DRIVER
 M:	Guenter Roeck <[email protected]>
Signature · 1 line
2.23.0