From f972d1a873887ee3005b77e50b541d8418c9a3a5 Mon Sep 17 00:00:00 2001 From: Jishnu Prakash Date: Mon, 22 Mar 2021 13:28:47 +0530 Subject: [PATCH 1/2] dt-bindings: iio: qcom,spmi-vadc: Add PMIC5 GEN3 ADC bindings PMIC5 GEN3 ADC has support for clients to read voltage and current on supported channels connected to the PMIC. Clients include reading voltage phone power and on board system thermistors for thermal management. ADCs on certain PMICs have support to read battery current. Change-Id: Ief7cbdf77d227ba2cb4ef7919aa66d9962d98e37 --- bindings/iio/adc/qcom,spmi-vadc.txt | 99 +++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 13 deletions(-) diff --git a/bindings/iio/adc/qcom,spmi-vadc.txt b/bindings/iio/adc/qcom,spmi-vadc.txt index 0c01def7..97590725 100644 --- a/bindings/iio/adc/qcom,spmi-vadc.txt +++ b/bindings/iio/adc/qcom,spmi-vadc.txt @@ -11,6 +11,7 @@ VADC node: Usage: required Value type: Definition: Should contain "qcom,spmi-vadc". + Should contain "qcom,spmi-adc5-gen3" for PMIC5 Gen3 ADC driver. Should contain "qcom,spmi-adc7" for PMIC7 ADC driver. Should contain "qcom,spmi-adc5" for PMIC5 ADC driver. Should contain "qcom,spmi-adc-rev2" for PMIC rev2 ADC driver. @@ -20,6 +21,8 @@ VADC node: Usage: required Value type: Definition: VADC base address in the SPMI PMIC register map. + Debug ADC peripheral base address in the SPMI PMIC + register map. Debug peripheral address is optional. - #address-cells: Usage: required @@ -52,7 +55,8 @@ Channel node properties: See include/dt-bindings/iio/qcom,spmi-vadc.h - label: - Usage: required for "qcom,spmi-adc5", "qcom,spmi-adc7" and "qcom,spmi-adc-rev2" + Usage: required for "qcom,spmi-adc5", "qcom,spmi-adc7", "qcom,spmi-adc5-gen3" + and "qcom,spmi-adc-rev2" Value type: Definition: ADC input of the platform as seen in the schematics. For thermistor inputs connected to generic AMUX or GPIO inputs @@ -70,9 +74,9 @@ Channel node properties: - For compatible property "qcom,spmi-adc5", valid values are 250, 420 and 840. If property is not found, default value of 840 is used. - - For compatible property "qcom,spmi-adc7", valid values are - 85, 340 and 1360. If property is not found, default value of - 1360 is used. + - For compatible property "qcom,spmi-adc7" and "qcom,spmi-adc5-gen3", + valid values are 85, 340 and 1360. If property is not found, default + value of 1360 is used. - For compatible property "qcom,spmi-adc-rev2", valid values are 256, 512 and 1024. If property is not present, default value is 1024. @@ -97,9 +101,10 @@ Channel node properties: 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. + - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7", + "qcom,spmi-adc5-gen3" 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. @@ -123,8 +128,8 @@ Channel node properties: Certain controller digital versions have valid values of 15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms If property is not found, channel will use 15us. - - For compatible property "qcom,spmi-adc7", delay = 15us for - value 0, 100us * (value) for values < 8, 1ms for value 8 + - For compatible property "qcom,spmi-adc7" or "qcom,spmi-adc5-gen3", + delay = 15us for value 0, 100us * (value) for values < 8, 1ms for value 8 and 2ms * (value - 8) otherwise. Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000 us. @@ -140,8 +145,9 @@ Channel node properties: - For compatible property "qcom,spmi-vadc", valid values are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 If property is not found, 1 sample will be used. - - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" - and "qcom,spmi-adc-rev2", valid values are: 1, 2, 4, 8, 16. + - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7", + "qcom,spmi-adc5-gen3" and "qcom,spmi-adc-rev2", + valid values are: 1, 2, 4, 8, 16. If property is not found, 1 sample will be used. - qcom,scale-fn-type: @@ -149,9 +155,30 @@ Channel node properties: Value type: Definition: The index of the VADC scale function used to convert raw ADC code to physical scaled units for the channel. Defined for compatible - properties "qcom,spmi-adc5" and "qcom,spmi-adc7". + properties "qcom,spmi-adc5", "qcom,spmi-adc5-gen3" and "qcom,spmi-adc7". See include/dt-bindings/iio/qcom,spmi-vadc.h. +- qcom,adc-tm-type: + Usage: optional + Value type: + Definition: Type of ADC_TM usage defined for a given channel. Valid values + are 0-3. Defined for compatible property "qcom,spmi-adc5-gen3". + - Value 0 indicates it will not be used for ADC_TM. + - Value 1 indicates it will be used for thermistors, for detecting + temperature threshold violations and temperature reads. + - Value 2 indicates it will be used for thermistors, for temperature + reads alone. + - Value 3 indicates it will be used for non-thermal clients, for + detecting threshold violations for that channel. + +- qcom,rscale-type: + Usage: optional + Value type: + Definition: Type of reverse scaling function used for ADC_TM channels. Valid only + for the case of non-thermal ADC_TM client. Valid value at present is only + 0 for reverse scaling of default voltage scaling function. Defined for + compatible property "qcom,spmi-adc5-gen3". + NOTE: For compatible property "qcom,spmi-vadc" following channels, also known as @@ -160,7 +187,7 @@ 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. -Example: +Example1: #include #include @@ -192,3 +219,49 @@ Example: io-channels = <&pmic_vadc VADC_LR_MUX10_USB_ID>; io-channel-names = "vadc"; }; + +Example2: + +#include +#include +/* ... */ + + /* VADC node */ + pm5100_adc: adc@8000 { + compatible = "qcom,spmi-adc-gen3"; + reg = <0x8000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <0x0 0x80 0x0 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "adc"; + #io-channel-cells = <1>; + io-channel-ranges; + #thermal-sensor-cells = <1>; + + pm5100_die_temp { + reg = ; + label = "pm5100_die_temp"; + qcom,pre-scaling = <1 1>; + }; + + pm5100_xo_therm { + reg = ; + label = "pm5100_xo_therm"; + qcom,ratiometric; + qcom,hw-settle-time = <200>; + qcom,pre-scaling = <1 1>; + qcom,adc-tm-type = <1>; + }; + + pm5100_vph_pwr { + reg = ; + label = "pm5100_vph_pwr"; + qcom,pre-scaling = <1 3>; + }; + }; + + /* IIO client node */ + batt { + io-channels = <&pm5100_adc PM5100_ADC5_GEN3_VPH_PWR>; + io-channel-names = "vph_pwr"; + }; From f81f67f0bb80ef45ab40a9c1364edfcbcadf278c Mon Sep 17 00:00:00 2001 From: Jishnu Prakash Date: Tue, 29 Jun 2021 16:41:46 +0530 Subject: [PATCH 2/2] dt-bindings: iio: qcom,spmi-vadc: Add SW-calibrated ADC bindings Add bindings for SW-calibrated ADC used on PMR735A/PMR735B on targets which don't have PMK8350 running in master mode. Change-Id: I753b3caf1e52ac9920a9df32cbef465277409700 --- bindings/iio/adc/qcom,spmi-vadc.txt | 60 ++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/bindings/iio/adc/qcom,spmi-vadc.txt b/bindings/iio/adc/qcom,spmi-vadc.txt index 97590725..b242cb77 100644 --- a/bindings/iio/adc/qcom,spmi-vadc.txt +++ b/bindings/iio/adc/qcom,spmi-vadc.txt @@ -11,12 +11,13 @@ VADC node: Usage: required Value type: Definition: Should contain "qcom,spmi-vadc". - Should contain "qcom,spmi-adc5-gen3" for PMIC5 Gen3 ADC driver. - Should contain "qcom,spmi-adc7" for PMIC7 ADC driver. - Should contain "qcom,spmi-adc5" for PMIC5 ADC driver. - Should contain "qcom,spmi-adc-rev2" for PMIC rev2 ADC driver. + Should contain "qcom,spmi-adc5-gen3" for PMIC5 Gen3 ADC. + Should contain "qcom,spmi-adc7" for PMIC7 ADC. + Should contain "qcom,spmi-adc5" for PMIC5 ADC. + Should contain "qcom,spmi-adc-rev2" for PMIC rev2 ADC. Should contain "qcom,pms405-adc" for PMS405 PMIC - Should contain "qcom,spmi-adc5-lite" for PMIC5 ADC-lite driver. + Should contain "qcom,spmi-adc5-lite" for PMIC5 ADC-lite. + Should contain "qcom,spmi-adc7-sw-calib" for PMIC7 SW-calibrated ADC. - reg: Usage: required Value type: @@ -108,6 +109,19 @@ Channel node properties: If property is not found, channel will be calibrated with 0V and 1.25V reference channels, also known as absolute calibration. +- qcom,no-cal: + Usage: optional + Value type: + Definition: Channel calibration type. + - For compatible property "qcom,spmi-adc7-sw-calib", if this property + is specified for a channel, VADC will not use any reference channels + for that channel's calibration. It is needed for the three calibration + channels alone (ADC7_REF_GND, ADC7_1P25VREF and ADC7_VREF_VADC), + mutually exclusive with ratiometric calibration and not meant for any + other compatible property. If property is not found, channel will be + calibrated with 0.625V and 1.25V reference channels, also known as + absolute calibration. + - qcom,hw-settle-time: Usage: optional Value type: @@ -187,6 +201,11 @@ 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. +For compatible property "qcom,spmi-adc7-sw-calib" following channels, also +known as reference point channels, are used for result calibration and their +channel configuration nodes should be defined: +ADC7_REF_GND, ADC7_1P25VREF and ADC7_VREF_VADC. + Example1: #include @@ -265,3 +284,34 @@ Example2: io-channels = <&pm5100_adc PM5100_ADC5_GEN3_VPH_PWR>; io-channel-names = "vph_pwr"; }; + +Example3: + +#include +#include +/* ... */ + + /* VADC node */ + pmr735a_vadc: vadc@3600 { + compatible = "qcom,spmi-adc7-sw-calib"; + reg = <0x3600>, <0x3900>; + reg-names = "adc5-sw-calib-pbs-base", "adc5-sw-calib-cmn-base"; + interrupts = <0x4 0x36 0x0 IRQ_TYPE_EDGE_RISING>; + #address-cells = <1>; + #size-cells = <0>; + #io-channel-cells = <1>; + io-channel-ranges; + + /* Channel node */ + pmr735a_die_temp { + reg = ; + label = "pmr735a_die_temp"; + qcom,pre-scaling = <1 1>; + }; + }; + + /* IIO client node */ + pmr735a_tz { + io-channels = <&pmr735a_vadc ADC7_DIE_TEMP>; + io-channel-names = "thermal"; + };