xref: /linux/Documentation/devicetree/bindings/iio/adc/adi,ad4170-4.yaml (revision 0d5ec7919f3747193f051036b2301734a4b5e1d6)
1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/iio/adc/adi,ad4170-4.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Analog Devices AD4170-4 and similar Analog to Digital Converters
8
9maintainers:
10  - Marcelo Schmitt <marcelo.schmitt@analog.com>
11
12description: |
13  Analog Devices AD4170-4 series of Sigma-delta Analog to Digital Converters.
14  Specifications can be found at:
15    https://www.analog.com/media/en/technical-documentation/data-sheets/ad4170-4.pdf
16    https://www.analog.com/media/en/technical-documentation/data-sheets/ad4190-4.pdf
17    https://www.analog.com/media/en/technical-documentation/data-sheets/ad4195-4.pdf
18
19$ref: /schemas/spi/spi-peripheral-props.yaml#
20
21$defs:
22  reference-buffer:
23    description: |
24      Enable precharge buffer, full buffer, or skip reference buffering of
25      the positive/negative voltage reference. Because the output impedance
26      of the source driving the voltage reference inputs may be dynamic,
27      resistive/capacitive combinations of those inputs can cause DC gain
28      errors if the reference inputs go unbuffered into the ADC. Enable
29      reference buffering if the provided reference source has dynamic high
30      impedance output. Note the absolute voltage allowed on REFINn+ and REFINn-
31      inputs is from AVSS - 50 mV to AVDD + 50 mV when the reference buffers are
32      disabled but narrows to AVSS to AVDD when reference buffering is enabled
33      or in precharge mode.
34    $ref: /schemas/types.yaml#/definitions/string
35    enum: [ precharge, full, disabled ]
36    default: full
37
38properties:
39  compatible:
40    enum:
41      - adi,ad4170-4
42      - adi,ad4190-4
43      - adi,ad4195-4
44
45  avss-supply:
46    description:
47      Reference voltage supply for AVSS. A2.625V minimum and 0V maximum supply
48      that powers the chip. If not provided, AVSS is assumed to be at system
49      ground (0V).
50
51  avdd-supply:
52    description:
53      A supply of 4.75V to 5.25V relative to AVSS that powers the chip (AVDD).
54
55  iovdd-supply:
56    description: 1.7V to 5.25V reference supply to the serial interface (IOVDD).
57
58  refin1p-supply:
59    description: REFIN+ supply that can be used as reference for conversion.
60
61  refin1n-supply:
62    description: REFIN- supply that can be used as reference for conversion.
63
64  refin2p-supply:
65    description: REFIN2+ supply that can be used as reference for conversion.
66
67  refin2n-supply:
68    description: REFIN2- supply that can be used as reference for conversion.
69
70  spi-cpol: true
71
72  spi-cpha: true
73
74  interrupts:
75    description:
76      Interrupt for signaling the completion of conversion results. The data
77      ready signal (RDY) used as interrupt is by default provided on the SDO
78      pin. Alternatively, it can be provided on the DIG_AUX1 pin in which case
79      the chip disables the RDY function on SDO. Thus, there can be only one
80      data ready interrupt enabled at a time.
81
82  interrupt-names:
83    description:
84      Specify which pin should be configured as Data Ready interrupt.
85    enum:
86      - sdo
87      - dig_aux1
88
89  clocks:
90    maxItems: 1
91    description:
92      Optional external clock source. Can specify either an external clock or
93      external crystal.
94
95  clock-names:
96    enum:
97      - ext-clk
98      - xtal
99    default: ext-clk
100
101  '#clock-cells':
102    const: 0
103
104  clock-output-names:
105    maxItems: 1
106
107  gpio-controller: true
108
109  "#gpio-cells":
110    const: 2
111    description: |
112      The first cell is for the GPIO number: 0 to 3.
113      The second cell takes standard GPIO flags.
114
115  ldac-gpios:
116    description:
117      GPIO connected to DIG_AUX2 pin to be used as LDAC toggle to control the
118      transfer of data from the DAC_INPUT_A register to the DAC.
119    maxItems: 1
120
121  '#address-cells':
122    const: 1
123
124  '#size-cells':
125    const: 0
126
127  adi,vbias-pins:
128    description: Analog inputs to apply a voltage bias of (AVDD − AVSS) / 2 to.
129    $ref: /schemas/types.yaml#/definitions/uint32-array
130    minItems: 1
131    maxItems: 9
132    items:
133      minimum: 0
134      maximum: 8
135
136allOf:
137  # Some devices don't have integrated DAC
138  - if:
139      properties:
140        compatible:
141          contains:
142            enum:
143              - adi,ad4190-4
144              - adi,ad4195-4
145    then:
146      properties:
147        ldac-gpios: false
148
149  # Require to specify the interrupt pin when using interrupts
150  - if:
151      required:
152        - interrupts
153    then:
154      required:
155        - interrupt-names
156
157  # If an external clock is set, the internal clock cannot go out and vice versa
158  - oneOf:
159      - required: [clocks]
160        properties:
161          '#clock-cells': false
162      - required: ['#clock-cells']
163        properties:
164          clocks: false
165
166required:
167  - compatible
168  - reg
169  - avdd-supply
170  - iovdd-supply
171  - spi-cpol
172  - spi-cpha
173
174unevaluatedProperties: false
175
176patternProperties:
177  "^channel@[0-9a-f]$":
178    $ref: /schemas/iio/adc/adc.yaml#
179    unevaluatedProperties: false
180    description:
181      Represents the external channels which are connected to the ADC.
182
183    properties:
184      reg:
185        description:
186          The channel number.
187        minimum: 0
188        maximum: 15
189
190      diff-channels:
191        description: |
192          This property is used for defining the inputs of a differential
193          voltage channel. The first value is the positive input and the second
194          value is the negative input of the channel.
195
196          Besides the analog input pins AIN0 to AIN8, there are special inputs
197          that can be selected with the following values:
198          17: Internal temperature sensor
199          18: (AVDD-AVSS)/5
200          19: (IOVDD-DGND)/5
201          20: DAC output
202          21: ALDO
203          22: DLDO
204          23: AVSS
205          24: DGND
206          25: REFIN+
207          26: REFIN-
208          27: REFIN2+
209          28: REFIN2-
210          29: REFOUT
211          For the internal temperature sensor, use the input number for both
212          inputs (i.e. diff-channels = <17 17>).
213        items:
214          enum: [0, 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19, 20, 21, 22, 23, 24, 25,
215                 26, 27, 28, 29]
216
217      adi,reference-select:
218        description: |
219          Select the reference source to use when converting on the
220          specific channel. Valid values are:
221          0: REFIN+/REFIN-
222          1: REFIN2+/REFIN2−
223          2: REFOUT/AVSS (internal reference)
224          3: AVDD/AVSS
225          If not specified, REFOUT/AVSS is used.
226        $ref: /schemas/types.yaml#/definitions/uint32
227        enum: [0, 1, 2, 3]
228        default: 1
229
230      adi,positive-reference-buffer:
231        $ref: '#/$defs/reference-buffer'
232
233      adi,negative-reference-buffer:
234        $ref: '#/$defs/reference-buffer'
235
236      adi,sensor-type:
237        description:
238          The AD4170-4 and similar designs have features to aid interfacing with
239          load cell weigh scale, RTD, and thermocouple sensors. Each of those
240          sensor types requires either distinct wiring configuration or
241          external circuitry for proper sensor operation and can use different
242          ADC chip functionality on their setups. A key characteristic of those
243          external sensors is that they must be excited either by voltage supply
244          or by ADC chip excitation signals. The sensor can then be read through
245          a pair of analog inputs. This property specifies which particular
246          sensor type is connected to the ADC so it can be properly setup and
247          handled. Omit this property for conventional (not weigh scale, RTD, or
248          thermocouple) ADC channel setups.
249        $ref: /schemas/types.yaml#/definitions/string
250        enum: [ weighscale, rtd, thermocouple ]
251
252      adi,excitation-pin-0:
253        description:
254          Analog input to apply excitation current to while the channel
255          is active.
256        $ref: /schemas/types.yaml#/definitions/uint32
257        minimum: 0
258        maximum: 20
259        default: 0
260
261      adi,excitation-pin-1:
262        description:
263          Analog input to apply excitation current to while the channel
264          is active.
265        $ref: /schemas/types.yaml#/definitions/uint32
266        minimum: 0
267        maximum: 20
268        default: 0
269
270      adi,excitation-pin-2:
271        description:
272          Analog input to apply excitation current to while the channel
273          is active.
274        $ref: /schemas/types.yaml#/definitions/uint32
275        minimum: 0
276        maximum: 20
277        default: 0
278
279      adi,excitation-pin-3:
280        description:
281          Analog input to apply excitation current to while the channel
282          is active.
283        $ref: /schemas/types.yaml#/definitions/uint32
284        minimum: 0
285        maximum: 20
286        default: 0
287
288      adi,excitation-current-0-microamp:
289        description:
290          Excitation current in microamperes to be applied to pin specified in
291          adi,excitation-pin-0 while this channel is active.
292        enum: [0, 10, 50, 100, 250, 500, 1000, 1500]
293        default: 0
294
295      adi,excitation-current-1-microamp:
296        description:
297          Excitation current in microamperes to be applied to pin specified in
298          adi,excitation-pin-1 while this channel is active.
299        enum: [0, 10, 50, 100, 250, 500, 1000, 1500]
300        default: 0
301
302      adi,excitation-current-2-microamp:
303        description:
304          Excitation current in microamperes to be applied to pin specified in
305          adi,excitation-pin-2 while this channel is active.
306        enum: [0, 10, 50, 100, 250, 500, 1000, 1500]
307        default: 0
308
309      adi,excitation-current-3-microamp:
310        description:
311          Excitation current in microamperes to be applied to pin specified in
312          adi,excitation-pin-3 while this channel is active.
313        enum: [0, 10, 50, 100, 250, 500, 1000, 1500]
314        default: 0
315
316      adi,excitation-ac:
317        type: boolean
318        description:
319          Whether the external sensor has to be AC or DC excited. When omitted,
320          it is DC excited.
321
322    allOf:
323      - oneOf:
324          - required: [single-channel, common-mode-channel]
325            properties:
326              diff-channels: false
327          - required: [diff-channels]
328            properties:
329              single-channel: false
330              common-mode-channel: false
331      # Usual ADC channels don't need external circuitry excitation.
332      - if:
333          not:
334            required:
335              - adi,sensor-type
336        then:
337          properties:
338            adi,excitation-pin-0: false
339            adi,excitation-pin-1: false
340            adi,excitation-pin-2: false
341            adi,excitation-pin-3: false
342            adi,excitation-current-0-microamp: false
343            adi,excitation-current-1-microamp: false
344            adi,excitation-current-2-microamp: false
345            adi,excitation-current-3-microamp: false
346            adi,excitation-ac: false
347      # Weigh scale bridge AC excited with one pair of predefined signals.
348      - if:
349          allOf:
350            - properties:
351                adi,sensor-type:
352                  contains:
353                    const: weighscale
354            - required:
355                - adi,excitation-ac
356                - adi,excitation-pin-2
357                - adi,excitation-pin-3
358            - not:
359                required:
360                  - adi,excitation-current-2-microamp
361                  - adi,excitation-current-3-microamp
362        then:
363          properties:
364            adi,excitation-pin-2:
365              const: 19
366            adi,excitation-pin-3:
367              const: 20
368      # Weigh scale bridge AC excited with two pairs of predefined signals.
369      - if:
370          allOf:
371            - properties:
372                adi,sensor-type:
373                  contains:
374                    const: weighscale
375            - required:
376                - adi,excitation-ac
377                - adi,excitation-pin-0
378                - adi,excitation-pin-1
379                - adi,excitation-pin-2
380                - adi,excitation-pin-3
381            - not:
382                required:
383                  - adi,excitation-current-0-microamp
384                  - adi,excitation-current-1-microamp
385                  - adi,excitation-current-2-microamp
386                  - adi,excitation-current-3-microamp
387        then:
388          properties:
389            adi,excitation-pin-0:
390              const: 17
391            adi,excitation-pin-1:
392              const: 18
393            adi,excitation-pin-2:
394              const: 19
395            adi,excitation-pin-3:
396              const: 20
397
398examples:
399  - |
400    #include <dt-bindings/interrupt-controller/irq.h>
401    spi {
402        #address-cells = <1>;
403        #size-cells = <0>;
404
405        adc@0 {
406            compatible = "adi,ad4170-4";
407            reg = <0>;
408            spi-max-frequency = <20000000>;
409            spi-cpol;
410            spi-cpha;
411            avdd-supply = <&avdd>;
412            iovdd-supply = <&iovdd>;
413            clocks = <&clk>;
414            clock-names = "xtal";
415            interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
416            interrupt-names = "dig_aux1";
417            adi,vbias-pins = <8>;
418            #address-cells = <1>;
419            #size-cells = <0>;
420
421            // Sample AIN0 with respect to DGND throughout AVDD/DGND input range
422            // Pseudo-differential unipolar
423            channel@0 {
424                reg = <0>;
425                single-channel = <0>;
426                common-mode-channel = <24>;
427                adi,reference-select = <3>;
428            };
429            // Weigh scale sensor
430            channel@1 {
431                reg = <1>;
432                bipolar;
433                diff-channels = <1 2>;
434                adi,reference-select = <0>;
435                adi,positive-reference-buffer = "precharge";
436                adi,negative-reference-buffer = "precharge";
437                adi,sensor-type = "weighscale";
438                adi,excitation-pin-2 = <19>;
439                adi,excitation-pin-3 = <20>;
440                adi,excitation-ac;
441            };
442            // RTD sensor
443            channel@2 {
444                reg = <2>;
445                bipolar;
446                diff-channels = <3 4>;
447                adi,reference-select = <0>;
448                adi,sensor-type = "rtd";
449                adi,excitation-pin-0 = <5>;
450                adi,excitation-pin-1 = <6>;
451                adi,excitation-current-0-microamp = <500>;
452                adi,excitation-current-1-microamp = <500>;
453                adi,excitation-ac;
454            };
455            // Thermocouple sensor
456            channel@3 {
457                reg = <3>;
458                bipolar;
459                diff-channels = <7 8>;
460                adi,reference-select = <0>;
461                adi,sensor-type = "thermocouple";
462                adi,excitation-pin-0 = <18>;
463                adi,excitation-current-0-microamp = <500>;
464            };
465        };
466    };
467  - |
468    #include <dt-bindings/interrupt-controller/irq.h>
469    spi {
470        #address-cells = <1>;
471        #size-cells = <0>;
472
473        adc@0 {
474            compatible = "adi,ad4170-4";
475            reg = <0>;
476            spi-max-frequency = <20000000>;
477            spi-cpol;
478            spi-cpha;
479            avdd-supply = <&avdd>;
480            iovdd-supply = <&iovdd>;
481            #clock-cells = <0>;
482            clock-output-names = "ad4170-clk16mhz";
483            interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
484            interrupt-names = "dig_aux1";
485            #address-cells = <1>;
486            #size-cells = <0>;
487
488            // Sample AIN0 with respect to AIN1 throughout AVDD/AVSS input range
489            // Differential bipolar. If AVSS < 0V, differential true bipolar
490            channel@0 {
491                reg = <0>;
492                bipolar;
493                diff-channels = <0 1>;
494                adi,reference-select = <3>;
495            };
496            // Sample AIN2 with respect to DGND throughout AVDD/DGND input range
497            // Pseudo-differential unipolar
498            channel@1 {
499                reg = <1>;
500                single-channel = <2>;
501                common-mode-channel = <24>;
502                adi,reference-select = <3>;
503            };
504            // Sample AIN3 with respect to 2.5V throughout AVDD/AVSS input range
505            // Pseudo-differential bipolar
506            channel@2 {
507                reg = <2>;
508                bipolar;
509                single-channel = <3>;
510                common-mode-channel = <29>;
511                adi,reference-select = <3>;
512            };
513            // Sample AIN4 with respect to DGND throughout AVDD/AVSS input range
514            // Pseudo-differential bipolar
515            channel@3 {
516                reg = <3>;
517                bipolar;
518                single-channel = <4>;
519                common-mode-channel = <24>;
520                adi,reference-select = <3>;
521            };
522            // Sample AIN5 with respect to 2.5V throughout AVDD/AVSS input range
523            // Pseudo-differential unipolar (AD4170-4 datasheet page 46 example)
524            channel@4 {
525                reg = <4>;
526                single-channel = <5>;
527                common-mode-channel = <29>;
528                adi,reference-select = <3>;
529            };
530            // Sample AIN6 with respect to 2.5V throughout REFIN+/REFIN- input range
531            // Pseudo-differential bipolar
532            channel@5 {
533                reg = <5>;
534                bipolar;
535                single-channel = <6>;
536                common-mode-channel = <29>;
537                adi,reference-select = <0>;
538            };
539            // Weigh scale sensor
540            channel@6 {
541                reg = <6>;
542                bipolar;
543                diff-channels = <7 8>;
544                adi,reference-select = <0>;
545                adi,sensor-type = "weighscale";
546                adi,excitation-pin-0 = <17>;
547                adi,excitation-pin-1 = <18>;
548                adi,excitation-pin-2 = <19>;
549                adi,excitation-pin-3 = <20>;
550                adi,excitation-ac;
551            };
552        };
553    };
554...
555