18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci%YAML 1.2
38c2ecf20Sopenharmony_ci---
48c2ecf20Sopenharmony_ci$id: http://devicetree.org/schemas/iio/adc/qcom,spmi-vadc.yaml#
58c2ecf20Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cititle: Qualcomm's SPMI PMIC ADC
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cimaintainers:
108c2ecf20Sopenharmony_ci  - Andy Gross <agross@kernel.org>
118c2ecf20Sopenharmony_ci  - Bjorn Andersson <bjorn.andersson@linaro.org>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cidescription: |
148c2ecf20Sopenharmony_ci  SPMI PMIC voltage ADC (VADC) provides interface to clients to read
158c2ecf20Sopenharmony_ci  voltage. The VADC is a 15-bit sigma-delta ADC.
168c2ecf20Sopenharmony_ci  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
178c2ecf20Sopenharmony_ci  voltage. The VADC is a 16-bit sigma-delta ADC.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciproperties:
208c2ecf20Sopenharmony_ci  compatible:
218c2ecf20Sopenharmony_ci    oneOf:
228c2ecf20Sopenharmony_ci      - items:
238c2ecf20Sopenharmony_ci          - const: qcom,pms405-adc
248c2ecf20Sopenharmony_ci          - const: qcom,spmi-adc-rev2
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci      - items:
278c2ecf20Sopenharmony_ci          - enum:
288c2ecf20Sopenharmony_ci              - qcom,spmi-vadc
298c2ecf20Sopenharmony_ci              - qcom,spmi-adc5
308c2ecf20Sopenharmony_ci              - qcom,spmi-adc-rev2
318c2ecf20Sopenharmony_ci              - qcom,spmi-adc7
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci  reg:
348c2ecf20Sopenharmony_ci    description: VADC base address in the SPMI PMIC register map
358c2ecf20Sopenharmony_ci    maxItems: 1
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci  '#address-cells':
388c2ecf20Sopenharmony_ci    const: 1
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci  '#size-cells':
418c2ecf20Sopenharmony_ci    const: 0
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci  '#io-channel-cells':
448c2ecf20Sopenharmony_ci    const: 1
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci  interrupts:
478c2ecf20Sopenharmony_ci    maxItems: 1
488c2ecf20Sopenharmony_ci    description:
498c2ecf20Sopenharmony_ci      End of conversion interrupt.
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci  io-channel-ranges: true
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cirequired:
548c2ecf20Sopenharmony_ci  - compatible
558c2ecf20Sopenharmony_ci  - reg
568c2ecf20Sopenharmony_ci  - '#address-cells'
578c2ecf20Sopenharmony_ci  - '#size-cells'
588c2ecf20Sopenharmony_ci  - '#io-channel-cells'
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cipatternProperties:
618c2ecf20Sopenharmony_ci  "^.*@[0-9a-f]+$":
628c2ecf20Sopenharmony_ci    type: object
638c2ecf20Sopenharmony_ci    description: |
648c2ecf20Sopenharmony_ci      Represents the external channels which are connected to the ADC.
658c2ecf20Sopenharmony_ci      For compatible property "qcom,spmi-vadc" following channels, also known as
668c2ecf20Sopenharmony_ci      reference point channels, are used for result calibration and their channel
678c2ecf20Sopenharmony_ci      configuration nodes should be defined:
688c2ecf20Sopenharmony_ci      VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
698c2ecf20Sopenharmony_ci      VADC_GND_REF and VADC_VDD_VADC.
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci    properties:
728c2ecf20Sopenharmony_ci      reg:
738c2ecf20Sopenharmony_ci        description: |
748c2ecf20Sopenharmony_ci          ADC channel number.
758c2ecf20Sopenharmony_ci          See include/dt-bindings/iio/qcom,spmi-vadc.h
768c2ecf20Sopenharmony_ci          For PMIC7 ADC, the channel numbers are specified separately per PMIC
778c2ecf20Sopenharmony_ci          in the PMIC-specific files in include/dt-bindings/iio/.
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci      label:
808c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/string
818c2ecf20Sopenharmony_ci        description: |
828c2ecf20Sopenharmony_ci            ADC input of the platform as seen in the schematics.
838c2ecf20Sopenharmony_ci            For thermistor inputs connected to generic AMUX or GPIO inputs
848c2ecf20Sopenharmony_ci            these can vary across platform for the same pins. Hence select
858c2ecf20Sopenharmony_ci            the platform schematics name for this channel.
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci      qcom,decimation:
888c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32
898c2ecf20Sopenharmony_ci        description: |
908c2ecf20Sopenharmony_ci            This parameter is used to decrease ADC sampling rate.
918c2ecf20Sopenharmony_ci            Quicker measurements can be made by reducing decimation ratio.
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci      qcom,pre-scaling:
948c2ecf20Sopenharmony_ci        description: |
958c2ecf20Sopenharmony_ci            Used for scaling the channel input signal before the signal is
968c2ecf20Sopenharmony_ci            fed to VADC. The configuration for this node is to know the
978c2ecf20Sopenharmony_ci            pre-determined ratio and use it for post scaling. It is a pair of
988c2ecf20Sopenharmony_ci            integers, denoting the numerator and denominator of the fraction by which
998c2ecf20Sopenharmony_ci            input signal is multiplied. For example, <1 3> indicates the signal is scaled
1008c2ecf20Sopenharmony_ci            down to 1/3 of its value before ADC measurement.
1018c2ecf20Sopenharmony_ci            If property is not found default value depending on chip will be used.
1028c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32-array
1038c2ecf20Sopenharmony_ci        oneOf:
1048c2ecf20Sopenharmony_ci          - items:
1058c2ecf20Sopenharmony_ci              - const: 1
1068c2ecf20Sopenharmony_ci              - enum: [ 1, 3, 4, 6, 20, 8, 10 ]
1078c2ecf20Sopenharmony_ci          - items:
1088c2ecf20Sopenharmony_ci              - const: 10
1098c2ecf20Sopenharmony_ci              - const: 81
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci      qcom,ratiometric:
1128c2ecf20Sopenharmony_ci        description: |
1138c2ecf20Sopenharmony_ci            Channel calibration type.
1148c2ecf20Sopenharmony_ci            - For compatible property "qcom,spmi-vadc", if this property is
1158c2ecf20Sopenharmony_ci              specified VADC will use the VDD reference (1.8V) and GND for
1168c2ecf20Sopenharmony_ci              channel calibration. If property is not found, channel will be
1178c2ecf20Sopenharmony_ci              calibrated with 0.625V and 1.25V reference channels, also
1188c2ecf20Sopenharmony_ci              known as absolute calibration.
1198c2ecf20Sopenharmony_ci            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" and
1208c2ecf20Sopenharmony_ci              "qcom,spmi-adc-rev2", if this property is specified VADC will use
1218c2ecf20Sopenharmony_ci              the VDD reference (1.875V) and GND for channel calibration. If
1228c2ecf20Sopenharmony_ci              property is not found, channel will be calibrated with 0V and 1.25V
1238c2ecf20Sopenharmony_ci              reference channels, also known as absolute calibration.
1248c2ecf20Sopenharmony_ci        type: boolean
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci      qcom,hw-settle-time:
1278c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32
1288c2ecf20Sopenharmony_ci        description: |
1298c2ecf20Sopenharmony_ci            Time between AMUX getting configured and the ADC starting
1308c2ecf20Sopenharmony_ci            conversion. The 'hw_settle_time' is an index used from valid values
1318c2ecf20Sopenharmony_ci            and programmed in hardware to achieve the hardware settling delay.
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci      qcom,avg-samples:
1348c2ecf20Sopenharmony_ci        $ref: /schemas/types.yaml#/definitions/uint32
1358c2ecf20Sopenharmony_ci        description: |
1368c2ecf20Sopenharmony_ci            Number of samples to be used for measurement.
1378c2ecf20Sopenharmony_ci            Averaging provides the option to obtain a single measurement
1388c2ecf20Sopenharmony_ci            from the ADC that is an average of multiple samples. The value
1398c2ecf20Sopenharmony_ci            selected is 2^(value).
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci    required:
1428c2ecf20Sopenharmony_ci      - reg
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ciallOf:
1458c2ecf20Sopenharmony_ci  - if:
1468c2ecf20Sopenharmony_ci      properties:
1478c2ecf20Sopenharmony_ci        compatible:
1488c2ecf20Sopenharmony_ci          contains:
1498c2ecf20Sopenharmony_ci            const: qcom,spmi-vadc
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci    then:
1528c2ecf20Sopenharmony_ci      patternProperties:
1538c2ecf20Sopenharmony_ci        "^.*@[0-9a-f]+$":
1548c2ecf20Sopenharmony_ci          properties:
1558c2ecf20Sopenharmony_ci            qcom,decimation:
1568c2ecf20Sopenharmony_ci              enum: [ 512, 1024, 2048, 4096 ]
1578c2ecf20Sopenharmony_ci              default: 512
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci            qcom,hw-settle-time:
1608c2ecf20Sopenharmony_ci              enum: [ 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
1618c2ecf20Sopenharmony_ci                      4, 6, 8, 10 ]
1628c2ecf20Sopenharmony_ci              default: 0
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci            qcom,avg-samples:
1658c2ecf20Sopenharmony_ci              enum: [ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 ]
1668c2ecf20Sopenharmony_ci              default: 1
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci  - if:
1698c2ecf20Sopenharmony_ci      properties:
1708c2ecf20Sopenharmony_ci        compatible:
1718c2ecf20Sopenharmony_ci          contains:
1728c2ecf20Sopenharmony_ci            const: qcom,spmi-adc-rev2
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci    then:
1758c2ecf20Sopenharmony_ci      patternProperties:
1768c2ecf20Sopenharmony_ci        "^.*@[0-9a-f]+$":
1778c2ecf20Sopenharmony_ci          properties:
1788c2ecf20Sopenharmony_ci            qcom,decimation:
1798c2ecf20Sopenharmony_ci              enum: [ 256, 512, 1024 ]
1808c2ecf20Sopenharmony_ci              default: 1024
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci            qcom,hw-settle-time:
1838c2ecf20Sopenharmony_ci              enum: [ 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
1848c2ecf20Sopenharmony_ci                      4, 6, 8, 10 ]
1858c2ecf20Sopenharmony_ci              default: 0
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci            qcom,avg-samples:
1888c2ecf20Sopenharmony_ci              enum: [ 1, 2, 4, 8, 16 ]
1898c2ecf20Sopenharmony_ci              default: 1
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci  - if:
1928c2ecf20Sopenharmony_ci      properties:
1938c2ecf20Sopenharmony_ci        compatible:
1948c2ecf20Sopenharmony_ci          contains:
1958c2ecf20Sopenharmony_ci            const: qcom,spmi-adc5
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci    then:
1988c2ecf20Sopenharmony_ci      patternProperties:
1998c2ecf20Sopenharmony_ci        "^.*@[0-9a-f]+$":
2008c2ecf20Sopenharmony_ci          properties:
2018c2ecf20Sopenharmony_ci            qcom,decimation:
2028c2ecf20Sopenharmony_ci              enum: [ 250, 420, 840 ]
2038c2ecf20Sopenharmony_ci              default: 840
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci            qcom,hw-settle-time:
2068c2ecf20Sopenharmony_ci              enum: [ 15, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1, 2,
2078c2ecf20Sopenharmony_ci                      4, 6, 8, 10, 16, 32, 64, 128 ]
2088c2ecf20Sopenharmony_ci              default: 15
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci            qcom,avg-samples:
2118c2ecf20Sopenharmony_ci              enum: [ 1, 2, 4, 8, 16 ]
2128c2ecf20Sopenharmony_ci              default: 1
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci  - if:
2158c2ecf20Sopenharmony_ci      properties:
2168c2ecf20Sopenharmony_ci        compatible:
2178c2ecf20Sopenharmony_ci          contains:
2188c2ecf20Sopenharmony_ci            const: qcom,spmi-adc7
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci    then:
2218c2ecf20Sopenharmony_ci      patternProperties:
2228c2ecf20Sopenharmony_ci        "^.*@[0-9a-f]+$":
2238c2ecf20Sopenharmony_ci          properties:
2248c2ecf20Sopenharmony_ci            qcom,decimation:
2258c2ecf20Sopenharmony_ci              enum: [ 85, 340, 1360 ]
2268c2ecf20Sopenharmony_ci              default: 1360
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci            qcom,hw-settle-time:
2298c2ecf20Sopenharmony_ci              enum: [ 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000, 4000,
2308c2ecf20Sopenharmony_ci                      8000, 16000, 32000, 64000, 128000 ]
2318c2ecf20Sopenharmony_ci              default: 15
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci            qcom,avg-samples:
2348c2ecf20Sopenharmony_ci              enum: [ 1, 2, 4, 8, 16 ]
2358c2ecf20Sopenharmony_ci              default: 1
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ciadditionalProperties: false
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ciexamples:
2408c2ecf20Sopenharmony_ci  - |
2418c2ecf20Sopenharmony_ci    spmi_bus {
2428c2ecf20Sopenharmony_ci      #address-cells = <1>;
2438c2ecf20Sopenharmony_ci      #size-cells = <0>;
2448c2ecf20Sopenharmony_ci      /* VADC node */
2458c2ecf20Sopenharmony_ci      pmic_vadc: adc@3100 {
2468c2ecf20Sopenharmony_ci        compatible = "qcom,spmi-vadc";
2478c2ecf20Sopenharmony_ci        reg = <0x3100>;
2488c2ecf20Sopenharmony_ci        interrupts = <0x0 0x31 0x0 0x1>;
2498c2ecf20Sopenharmony_ci        #address-cells = <1>;
2508c2ecf20Sopenharmony_ci        #size-cells = <0>;
2518c2ecf20Sopenharmony_ci        #io-channel-cells = <1>;
2528c2ecf20Sopenharmony_ci        io-channel-ranges;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci        /* Channel node */
2558c2ecf20Sopenharmony_ci        adc-chan@39 {
2568c2ecf20Sopenharmony_ci          reg = <0x39>;
2578c2ecf20Sopenharmony_ci          qcom,decimation = <512>;
2588c2ecf20Sopenharmony_ci          qcom,ratiometric;
2598c2ecf20Sopenharmony_ci          qcom,hw-settle-time = <200>;
2608c2ecf20Sopenharmony_ci          qcom,avg-samples = <1>;
2618c2ecf20Sopenharmony_ci          qcom,pre-scaling = <1 3>;
2628c2ecf20Sopenharmony_ci        };
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci        adc-chan@9 {
2658c2ecf20Sopenharmony_ci          reg = <0x9>;
2668c2ecf20Sopenharmony_ci        };
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci        adc-chan@a {
2698c2ecf20Sopenharmony_ci          reg = <0xa>;
2708c2ecf20Sopenharmony_ci        };
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci        adc-chan@e {
2738c2ecf20Sopenharmony_ci          reg = <0xe>;
2748c2ecf20Sopenharmony_ci        };
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci        adc-chan@f {
2778c2ecf20Sopenharmony_ci          reg = <0xf>;
2788c2ecf20Sopenharmony_ci        };
2798c2ecf20Sopenharmony_ci      };
2808c2ecf20Sopenharmony_ci    };
281