xref: /freebsd/sys/contrib/device-tree/Bindings/iio/adc/qcom,spmi-vadc.yaml (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1# SPDX-License-Identifier: GPL-2.0-only
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/iio/adc/qcom,spmi-vadc.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Qualcomm's SPMI PMIC ADC
8
9maintainers:
10  - Andy Gross <agross@kernel.org>
11  - Bjorn Andersson <bjorn.andersson@linaro.org>
12
13description: |
14  SPMI PMIC voltage ADC (VADC) provides interface to clients to read
15  voltage. The VADC is a 15-bit sigma-delta ADC.
16  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
17  voltage. The VADC is a 16-bit sigma-delta ADC.
18
19properties:
20  compatible:
21    oneOf:
22      - items:
23          - const: qcom,pms405-adc
24          - const: qcom,spmi-adc-rev2
25
26      - items:
27          - enum:
28              - qcom,spmi-vadc
29              - qcom,spmi-adc5
30              - qcom,spmi-adc-rev2
31              - qcom,spmi-adc7
32
33  reg:
34    description: VADC base address in the SPMI PMIC register map
35    maxItems: 1
36
37  '#address-cells':
38    const: 1
39
40  '#size-cells':
41    const: 0
42
43  '#io-channel-cells':
44    const: 1
45
46  interrupts:
47    maxItems: 1
48    description:
49      End of conversion interrupt.
50
51required:
52  - compatible
53  - reg
54  - '#address-cells'
55  - '#size-cells'
56  - '#io-channel-cells'
57
58patternProperties:
59  "^.*@[0-9a-f]+$":
60    type: object
61    description: |
62      Represents the external channels which are connected to the ADC.
63      For compatible property "qcom,spmi-vadc" following channels, also known as
64      reference point channels, are used for result calibration and their channel
65      configuration nodes should be defined:
66      VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
67      VADC_GND_REF and VADC_VDD_VADC.
68
69    properties:
70      reg:
71        maxItems: 1
72        description: |
73          ADC channel number.
74          See include/dt-bindings/iio/qcom,spmi-vadc.h
75          For PMIC7 ADC, the channel numbers are specified separately per PMIC
76          in the PMIC-specific files in include/dt-bindings/iio/.
77
78      label:
79        $ref: /schemas/types.yaml#/definitions/string
80        description: |
81            ADC input of the platform as seen in the schematics.
82            For thermistor inputs connected to generic AMUX or GPIO inputs
83            these can vary across platform for the same pins. Hence select
84            the platform schematics name for this channel.
85
86      qcom,decimation:
87        $ref: /schemas/types.yaml#/definitions/uint32
88        description: |
89            This parameter is used to decrease ADC sampling rate.
90            Quicker measurements can be made by reducing decimation ratio.
91
92      qcom,pre-scaling:
93        description: |
94            Used for scaling the channel input signal before the signal is
95            fed to VADC. The configuration for this node is to know the
96            pre-determined ratio and use it for post scaling. It is a pair of
97            integers, denoting the numerator and denominator of the fraction by which
98            input signal is multiplied. For example, <1 3> indicates the signal is scaled
99            down to 1/3 of its value before ADC measurement.
100            If property is not found default value depending on chip will be used.
101        $ref: /schemas/types.yaml#/definitions/uint32-array
102        oneOf:
103          - items:
104              - const: 1
105              - enum: [ 1, 3, 4, 6, 20, 8, 10 ]
106          - items:
107              - const: 10
108              - const: 81
109
110      qcom,ratiometric:
111        description: |
112            Channel calibration type.
113            - For compatible property "qcom,spmi-vadc", if this property is
114              specified VADC will use the VDD reference (1.8V) and GND for
115              channel calibration. If property is not found, channel will be
116              calibrated with 0.625V and 1.25V reference channels, also
117              known as absolute calibration.
118            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" and
119              "qcom,spmi-adc-rev2", if this property is specified VADC will use
120              the VDD reference (1.875V) and GND for channel calibration. If
121              property is not found, channel will be calibrated with 0V and 1.25V
122              reference channels, also known as absolute calibration.
123        type: boolean
124
125      qcom,hw-settle-time:
126        $ref: /schemas/types.yaml#/definitions/uint32
127        description: |
128            Time between AMUX getting configured and the ADC starting
129            conversion. The 'hw_settle_time' is an index used from valid values
130            and programmed in hardware to achieve the hardware settling delay.
131
132      qcom,avg-samples:
133        $ref: /schemas/types.yaml#/definitions/uint32
134        description: |
135            Number of samples to be used for measurement.
136            Averaging provides the option to obtain a single measurement
137            from the ADC that is an average of multiple samples. The value
138            selected is 2^(value).
139
140    required:
141      - reg
142
143allOf:
144  - if:
145      properties:
146        compatible:
147          contains:
148            const: qcom,spmi-vadc
149
150    then:
151      patternProperties:
152        "^.*@[0-9a-f]+$":
153          properties:
154            qcom,decimation:
155              enum: [ 512, 1024, 2048, 4096 ]
156              default: 512
157
158            qcom,hw-settle-time:
159              enum: [ 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
160                      4, 6, 8, 10 ]
161              default: 0
162
163            qcom,avg-samples:
164              enum: [ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 ]
165              default: 1
166
167  - if:
168      properties:
169        compatible:
170          contains:
171            const: qcom,spmi-adc-rev2
172
173    then:
174      patternProperties:
175        "^.*@[0-9a-f]+$":
176          properties:
177            qcom,decimation:
178              enum: [ 256, 512, 1024 ]
179              default: 1024
180
181            qcom,hw-settle-time:
182              enum: [ 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
183                      4, 6, 8, 10 ]
184              default: 0
185
186            qcom,avg-samples:
187              enum: [ 1, 2, 4, 8, 16 ]
188              default: 1
189
190  - if:
191      properties:
192        compatible:
193          contains:
194            const: qcom,spmi-adc5
195
196    then:
197      patternProperties:
198        "^.*@[0-9a-f]+$":
199          properties:
200            qcom,decimation:
201              enum: [ 250, 420, 840 ]
202              default: 840
203
204            qcom,hw-settle-time:
205              enum: [ 15, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
206                      4, 6, 8, 10, 16, 32, 64, 128 ]
207              default: 15
208
209            qcom,avg-samples:
210              enum: [ 1, 2, 4, 8, 16 ]
211              default: 1
212
213  - if:
214      properties:
215        compatible:
216          contains:
217            const: qcom,spmi-adc7
218
219    then:
220      patternProperties:
221        "^.*@[0-9a-f]+$":
222          properties:
223            qcom,decimation:
224              enum: [ 85, 340, 1360 ]
225              default: 1360
226
227            qcom,hw-settle-time:
228              enum: [ 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000, 4000,
229                      8000, 16000, 32000, 64000, 128000 ]
230              default: 15
231
232            qcom,avg-samples:
233              enum: [ 1, 2, 4, 8, 16 ]
234              default: 1
235
236additionalProperties: false
237
238examples:
239  - |
240    spmi_bus {
241      #address-cells = <1>;
242      #size-cells = <0>;
243      /* VADC node */
244      pmic_vadc: adc@3100 {
245        compatible = "qcom,spmi-vadc";
246        reg = <0x3100>;
247        interrupts = <0x0 0x31 0x0 0x1>;
248        #address-cells = <1>;
249        #size-cells = <0>;
250        #io-channel-cells = <1>;
251
252        /* Channel node */
253        adc-chan@39 {
254          reg = <0x39>;
255          qcom,decimation = <512>;
256          qcom,ratiometric;
257          qcom,hw-settle-time = <200>;
258          qcom,avg-samples = <1>;
259          qcom,pre-scaling = <1 3>;
260        };
261
262        adc-chan@9 {
263          reg = <0x9>;
264        };
265
266        adc-chan@a {
267          reg = <0xa>;
268        };
269
270        adc-chan@e {
271          reg = <0xe>;
272        };
273
274        adc-chan@f {
275          reg = <0xf>;
276        };
277      };
278    };
279