xref: /freebsd/sys/contrib/device-tree/Bindings/iio/adc/qcom,spmi-vadc.txt (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1Qualcomm's SPMI PMIC ADC
2
3- SPMI PMIC voltage ADC (VADC) provides interface to clients to read
4  voltage. The VADC is a 15-bit sigma-delta ADC.
5- SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
6  voltage. The VADC is a 16-bit sigma-delta ADC.
7
8VADC node:
9
10- compatible:
11    Usage: required
12    Value type: <string>
13    Definition: Should contain "qcom,spmi-vadc".
14                Should contain "qcom,spmi-adc5" for PMIC5 ADC driver.
15                Should contain "qcom,spmi-adc-rev2" for PMIC rev2 ADC driver.
16                Should contain "qcom,pms405-adc" for PMS405 PMIC
17
18- reg:
19    Usage: required
20    Value type: <prop-encoded-array>
21    Definition: VADC base address in the SPMI PMIC register map.
22
23- #address-cells:
24    Usage: required
25    Value type: <u32>
26    Definition: Must be one. Child node 'reg' property should define ADC
27            channel number.
28
29- #size-cells:
30    Usage: required
31    Value type: <u32>
32    Definition: Must be zero.
33
34- #io-channel-cells:
35    Usage: required
36    Value type: <u32>
37    Definition: Must be one. For details about IIO bindings see:
38            Documentation/devicetree/bindings/iio/iio-bindings.txt
39
40- interrupts:
41    Usage: optional
42    Value type: <prop-encoded-array>
43    Definition: End of conversion interrupt.
44
45Channel node properties:
46
47- reg:
48    Usage: required
49    Value type: <u32>
50    Definition: ADC channel number.
51            See include/dt-bindings/iio/qcom,spmi-vadc.h
52
53- label:
54    Usage: required for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2"
55    Value type: <empty>
56    Definition: ADC input of the platform as seen in the schematics.
57            For thermistor inputs connected to generic AMUX or GPIO inputs
58            these can vary across platform for the same pins. Hence select
59            the platform schematics name for this channel.
60
61- qcom,decimation:
62    Usage: optional
63    Value type: <u32>
64    Definition: This parameter is used to decrease ADC sampling rate.
65            Quicker measurements can be made by reducing decimation ratio.
66            - For compatible property "qcom,spmi-vadc", valid values are
67              512, 1024, 2048, 4096. If property is not found, default value
68              of 512 will be used.
69            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
70              and 840. If property is not found, default value of 840 is used.
71            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
72              512 and 1024. If property is not present, default value is 1024.
73
74- qcom,pre-scaling:
75    Usage: optional
76    Value type: <u32 array>
77    Definition: Used for scaling the channel input signal before the signal is
78            fed to VADC. The configuration for this node is to know the
79            pre-determined ratio and use it for post scaling. Select one from
80            the following options.
81            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>
82            If property is not found default value depending on chip will be used.
83
84- qcom,ratiometric:
85    Usage: optional
86    Value type: <empty>
87    Definition: Channel calibration type.
88            - For compatible property "qcom,spmi-vadc", if this property is
89              specified VADC will use the VDD reference (1.8V) and GND for
90              channel calibration. If property is not found, channel will be
91              calibrated with 0.625V and 1.25V reference channels, also
92              known as absolute calibration.
93            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
94              if this property is specified VADC will use the VDD reference
95              (1.875V) and GND for channel calibration. If property is not found,
96              channel will be calibrated with 0V and 1.25V reference channels,
97              also known as absolute calibration.
98
99- qcom,hw-settle-time:
100    Usage: optional
101    Value type: <u32>
102    Definition: Time between AMUX getting configured and the ADC starting
103            conversion. The 'hw_settle_time' is an index used from valid values
104            and programmed in hardware to achieve the hardware settling delay.
105            - For compatible property "qcom,spmi-vadc" and "qcom,spmi-adc-rev2",
106              Delay = 100us * (hw_settle_time) for hw_settle_time < 11,
107              and 2ms * (hw_settle_time - 10) otherwise.
108              Valid values are: 0, 100, 200, 300, 400, 500, 600, 700, 800,
109              900 us and 1, 2, 4, 6, 8, 10 ms.
110              If property is not found, channel will use 0us.
111            - For compatible property "qcom,spmi-adc5", delay = 15us for
112              value 0, 100us * (value) for values < 11,
113              and 2ms * (value - 10) otherwise.
114              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 800,
115              900 us and 1, 2, 4, 6, 8, 10 ms
116              Certain controller digital versions have valid values of
117              15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
118              If property is not found, channel will use 15us.
119
120- qcom,avg-samples:
121    Usage: optional
122    Value type: <u32>
123    Definition: Number of samples to be used for measurement.
124            Averaging provides the option to obtain a single measurement
125            from the ADC that is an average of multiple samples. The value
126            selected is 2^(value).
127            - For compatible property "qcom,spmi-vadc", valid values
128              are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
129              If property is not found, 1 sample will be used.
130            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
131              valid values are: 1, 2, 4, 8, 16
132              If property is not found, 1 sample will be used.
133
134NOTE:
135
136For compatible property "qcom,spmi-vadc" following channels, also known as
137reference point channels, are used for result calibration and their channel
138configuration nodes should be defined:
139VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
140VADC_GND_REF and VADC_VDD_VADC.
141
142Example:
143
144#include <dt-bindings/iio/qcom,spmi-vadc.h>
145#include <linux/irq.h>
146/* ... */
147
148	/* VADC node */
149	pmic_vadc: vadc@3100 {
150		compatible = "qcom,spmi-vadc";
151		reg = <0x3100>;
152		interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
153		#address-cells = <1>;
154		#size-cells = <0>;
155		#io-channel-cells = <1>;
156		io-channel-ranges;
157
158		/* Channel node */
159		adc-chan@VADC_LR_MUX10_USB_ID {
160			reg = <VADC_LR_MUX10_USB_ID>;
161			qcom,decimation = <512>;
162			qcom,ratiometric;
163			qcom,hw-settle-time = <200>;
164			qcom,avg-samples = <1>;
165			qcom,pre-scaling = <1 3>;
166		};
167	};
168
169	/* IIO client node */
170	usb {
171		io-channels = <&pmic_vadc VADC_LR_MUX10_USB_ID>;
172		io-channel-names = "vadc";
173	};
174