summaryrefslogtreecommitdiffstats
path: root/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
blob: 7f4f827c57a7e9c425b6bcb054b23deb54de4359 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# SPDX-License-Identifier: GPL-2.0-only
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/adc/qcom,spmi-vadc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Qualcomm's SPMI PMIC ADC

maintainers:
  - Andy Gross <agross@kernel.org>
  - Bjorn Andersson <bjorn.andersson@linaro.org>

description: |
  SPMI PMIC voltage ADC (VADC) provides interface to clients to read
  voltage. The VADC is a 15-bit sigma-delta ADC.
  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
  voltage. The VADC is a 16-bit sigma-delta ADC.

properties:
  compatible:
    oneOf:
      - items:
          - const: qcom,pms405-adc
          - const: qcom,spmi-adc-rev2

      - items:
          - enum:
              - qcom,spmi-vadc
              - qcom,spmi-adc5
              - qcom,spmi-adc-rev2
              - qcom,spmi-adc7

  reg:
    description: VADC base address in the SPMI PMIC register map
    maxItems: 1

  '#address-cells':
    const: 1

  '#size-cells':
    const: 0

  '#io-channel-cells':
    const: 1

  interrupts:
    maxItems: 1
    description:
      End of conversion interrupt.

  io-channel-ranges: true

required:
  - compatible
  - reg
  - '#address-cells'
  - '#size-cells'
  - '#io-channel-cells'

patternProperties:
  "^.*@[0-9a-f]+$":
    type: object
    description: |
      Represents the external channels which are connected to the ADC.
      For compatible property "qcom,spmi-vadc" following channels, also known as
      reference point channels, are used for result calibration and their channel
      configuration nodes should be defined:
      VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
      VADC_GND_REF and VADC_VDD_VADC.

    properties:
      reg:
        description: |
          ADC channel number.
          See include/dt-bindings/iio/qcom,spmi-vadc.h
          For PMIC7 ADC, the channel numbers are specified separately per PMIC
          in the PMIC-specific files in include/dt-bindings/iio/.

      label:
        $ref: /schemas/types.yaml#/definitions/string
        description: |
            ADC input of the platform as seen in the schematics.
            For thermistor inputs connected to generic AMUX or GPIO inputs
            these can vary across platform for the same pins. Hence select
            the platform schematics name for this channel.

      qcom,decimation:
        $ref: /schemas/types.yaml#/definitions/uint32
        description: |
            This parameter is used to decrease ADC sampling rate.
            Quicker measurements can be made by reducing decimation ratio.

      qcom,pre-scaling:
        description: |
            Used for scaling the channel input signal before the signal is
            fed to VADC. The configuration for this node is to know the
            pre-determined ratio and use it for post scaling. It is a pair of
            integers, denoting the numerator and denominator of the fraction by which
            input signal is multiplied. For example, <1 3> indicates the signal is scaled
            down to 1/3 of its value before ADC measurement.
            If property is not found default value depending on chip will be used.
        $ref: /schemas/types.yaml#/definitions/uint32-array
        oneOf:
          - items:
              - const: 1
              - enum: [ 1, 3, 4, 6, 20, 8, 10 ]
          - items:
              - const: 10
              - const: 81

      qcom,ratiometric:
        description: |
            Channel calibration type.
            - For compatible property "qcom,spmi-vadc", if this property is
              specified VADC will use the VDD reference (1.8V) and GND for
              channel calibration. If property is not found, channel will be
              calibrated with 0.625V and 1.25V reference channels, also
              known as absolute calibration.
            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" and
              "qcom,spmi-adc-rev2", if this property is specified VADC will use
              the VDD reference (1.875V) and GND for channel calibration. If
              property is not found, channel will be calibrated with 0V and 1.25V
              reference channels, also known as absolute calibration.
        type: boolean

      qcom,hw-settle-time:
        $ref: /schemas/types.yaml#/definitions/uint32
        description: |
            Time between AMUX getting configured and the ADC starting
            conversion. The 'hw_settle_time' is an index used from valid values
            and programmed in hardware to achieve the hardware settling delay.

      qcom,avg-samples:
        $ref: /schemas/types.yaml#/definitions/uint32
        description: |
            Number of samples to be used for measurement.
            Averaging provides the option to obtain a single measurement
            from the ADC that is an average of multiple samples. The value
            selected is 2^(value).

    required:
      - reg

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: qcom,spmi-vadc

    then:
      patternProperties:
        "^.*@[0-9a-f]+$":
          properties:
            qcom,decimation:
              enum: [ 512, 1024, 2048, 4096 ]
              default: 512

            qcom,hw-settle-time:
              enum: [ 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
                      4, 6, 8, 10 ]
              default: 0

            qcom,avg-samples:
              enum: [ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 ]
              default: 1

  - if:
      properties:
        compatible:
          contains:
            const: qcom,spmi-adc-rev2

    then:
      patternProperties:
        "^.*@[0-9a-f]+$":
          properties:
            qcom,decimation:
              enum: [ 256, 512, 1024 ]
              default: 1024

            qcom,hw-settle-time:
              enum: [ 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
                      4, 6, 8, 10 ]
              default: 0

            qcom,avg-samples:
              enum: [ 1, 2, 4, 8, 16 ]
              default: 1

  - if:
      properties:
        compatible:
          contains:
            const: qcom,spmi-adc5

    then:
      patternProperties:
        "^.*@[0-9a-f]+$":
          properties:
            qcom,decimation:
              enum: [ 250, 420, 840 ]
              default: 840

            qcom,hw-settle-time:
              enum: [ 15, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
                      4, 6, 8, 10, 16, 32, 64, 128 ]
              default: 15

            qcom,avg-samples:
              enum: [ 1, 2, 4, 8, 16 ]
              default: 1

  - if:
      properties:
        compatible:
          contains:
            const: qcom,spmi-adc7

    then:
      patternProperties:
        "^.*@[0-9a-f]+$":
          properties:
            qcom,decimation:
              enum: [ 85, 340, 1360 ]
              default: 1360

            qcom,hw-settle-time:
              enum: [ 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000, 4000,
                      8000, 16000, 32000, 64000, 128000 ]
              default: 15

            qcom,avg-samples:
              enum: [ 1, 2, 4, 8, 16 ]
              default: 1

additionalProperties: false

examples:
  - |
    spmi_bus {
      #address-cells = <1>;
      #size-cells = <0>;
      /* VADC node */
      pmic_vadc: adc@3100 {
        compatible = "qcom,spmi-vadc";
        reg = <0x3100>;
        interrupts = <0x0 0x31 0x0 0x1>;
        #address-cells = <1>;
        #size-cells = <0>;
        #io-channel-cells = <1>;
        io-channel-ranges;

        /* Channel node */
        adc-chan@39 {
          reg = <0x39>;
          qcom,decimation = <512>;
          qcom,ratiometric;
          qcom,hw-settle-time = <200>;
          qcom,avg-samples = <1>;
          qcom,pre-scaling = <1 3>;
        };

        adc-chan@9 {
          reg = <0x9>;
        };

        adc-chan@a {
          reg = <0xa>;
        };

        adc-chan@e {
          reg = <0xe>;
        };

        adc-chan@f {
          reg = <0xf>;
        };
      };
    };