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