Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37d9c8a2 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

hwmon: adc: Add ADC driver snapshot



Voltage ADC (VADC) and Current ADC (IADC) drivers
are used by clients to measure ADC such as voltage
phone power, thermistors and battery current.

This snapshot is taken as of msm-4.4
'commit <4f1f60e00d6a> ("Merge "ARM: dts:
msm: add nt35597 sharp panel node for sdm660"")'.

Change-Id: Ied07c12476916c181211d101786adffc2f762840
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 830592ef
Loading
Loading
Loading
Loading
+104 −0
Original line number Diff line number Diff line
Qualcomm Technologies, Inc. QPNP PMIC current ADC driver

QPNP PMIC current ADC (IADC) provides interface to clients to read
current. A 16 bit ADC is used for current measurements. There are multiple
peripherals to the IADC and the scope of the driver is to provide interface
for the USR peripheral of the IADC.

IADC node

Required properties:
- compatible : should be "qcom,qpnp-iadc" for Current ADC driver.
- reg : offset and length of the PMIC Arbiter register map.
- reg-names : resource names used for the physical base address of the PMIC IADC
	      peripheral, the SMBB_BAT_IF_TRIM_CNST_RDS register.
	      Should be "iadc-base" for the PMIC IADC peripheral base register.
	      Should be "batt-id-trim-cnst-rds" for reading the
	      SMBB_BAT_IF_TRIM_CNST_RDS register.
- address-cells : Must be one.
- size-cells : Must be zero.
- interrupts : The USR bank peripheral IADC interrupt.
- interrupt-names : Should contain "eoc-int-en-set".
- qcom,adc-bit-resolution : Bit resolution of the ADC.
- qcom,adc-vdd-reference : Voltage reference used by the ADC.

Optional properties:
- qcom,rsense : Use this property when external rsense should be used
		for current calculation and specify the units in nano-ohms.
- qcom,iadc-poll-eoc: Use polling instead of interrupts for End of Conversion completion.
- qcom,pmic-revid : Phandle pointing to the revision peripheral node. Use it to query the
		    PMIC type and revision for applying the appropriate temperature
		    compensation parameters.
- qcom,use-default-rds-trim : Add this property to check if certain conditions are to be checked
			      reading the SMBB_BAT_IF_CNST_RDS, IADC_RDS trim register and
			      manufacturer type. Check the driver for conditions that each of the type.
			      0 : Select the TypeA to read the IADC and SMBB trim register and
				  apply the default RSENSE if conditions are met.
			      1 : Select the TypeB to read the IADC, SMBB trim register and
				  manufacturer type and apply the default RSENSE if conditions are met.
			      2 : Select the TypeC to read the IADC, SMBB trim register and
				  apply the default RSENSE if conditions are met.

Channel node
NOTE: Atleast one Channel node is required.

Client required property:
- qcom,<consumer name>-iadc : The phandle to the corresponding iadc device.
			The consumer name passed to the driver when calling
			qpnp_get_iadc() is used to associate the client
			with the corresponding device.

Required properties:
- label : Channel name used for sysfs entry.
- reg : AMUX channel number.
- qcom,channel-num : Channel number associated to the AMUX input.
- qcom,decimation : Sampling rate to use for the individual channel measurement.
		    Select from the following unsigned int.
		    0 : 512
		    1 : 1K
		    2 : 2K
		    3 : 4K
- qcom,fast-avg-setup : Average number of samples to be used for measurement. Fast 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)
			Select from the following unsigned int.
			0 : 1
			1 : 2
			2 : 4
			3 : 8
			4 : 16
			5 : 32
			6 : 64
			7 : 128
			8 : 256
- qcom,iadc-vadc : Corresponding phandle of the VADC device to read the die_temperature and set
		simultaneous voltage and current conversion requests.

Example:
	/* Main Node */
	qcom,iadc@3200 {
                        compatible = "qcom,qpnp-iadc";
                        reg = <0x3200 0x100>;
			#address-cells = <1>;
			#size-cells = <0>;
                        interrupts = <0 0x36 0>;
			interrupt-names = "eoc-int-en-set";
                        qcom,adc-bit-resolution = <16>;
                        qcom,adc-vdd-reference = <1800>;
			qcom,rsense = <1500>;
			qcom,iadc-vadc = <&pm8941_vadc>;

			/* Channel Node */
                        chan@0 = {
                                label = "rsense";
                                reg = <0>;
                                qcom,decimation = <0>;
                                qcom,fast-avg-setup = <0>;
                        };
	};

Client device example:
/* Add to the clients node that needs the IADC */
client_node {
	qcom,client-iadc = <&pm8941_iadc>;
};
+197 −0
Original line number Diff line number Diff line
Qualcomm Technologies, Inc. QPNP PMIC Voltage ADC Arbiter

QPNP PMIC Voltage ADC (VADC) provides interface to clients to read
Voltage. A 15 bit ADC is used for Voltage measurements. There are multiple
peripherals to the VADC and the scope of the driver is to provide interface
for the USR peripheral of the VADC.

VADC node

Required properties:
- compatible : should be "qcom,qpnp-vadc" for Voltage ADC device driver and
		"qcom,qpnp-vadc-hc" for VADC_HC voltage ADC device driver.
- reg : offset and length of the PMIC Aribter register map.
- address-cells : Must be one.
- size-cells : Must be zero.
- interrupts : The USR bank peripheral VADC interrupt.
- interrupt-names : Should contain "eoc-int-en-set" for EOC,
		"high-thr-en-set" for high threshold interrupts and
		"low-thr-en-set" for low threshold interrupts. High and low threshold
		interrupts are to be enabled if VADC_USR needs to support recurring measurement.
- qcom,adc-bit-resolution : Bit resolution of the ADC.
- qcom,adc-vdd-reference : Voltage reference used by the ADC.

Channel nodes
NOTE: Atleast one Channel node is required.

Optional properties:
- qcom,vadc-poll-eoc: Use polling instead of interrupts for End of Conversion completion.
- qcom,pmic-revid : Phandle pointing to the revision peripheral node. Use it to query the
		    PMIC type and revision for applying the appropriate temperature
		    compensation parameters.
-qcom,vadc-meas-int-mode : Enable VADC_USR to handle requests to perform recurring measurements
			   for any one supported channel along with supporting single conversion
			   requests.
- qcom,vadc-recalib-check: Add this property to check if recalibration required due to inaccuracy.
- qcom,vadc-thermal-node : If present a thermal node is created and the channel is registered as
			   part of the thermal sysfs which allows clients to use the thermal framework
			   to set temperature thresholds and receive notification when the temperature
			   crosses a set threshold, read temperature and enable/set trip types supported
			   by the thermal framework.
- hkadc_ldo-supply : Add this property if VADC needs to perform a Software Vote for the HKADC.
- hkadc_ok-supply : Add this property if the VADC needs to perform a Software vote for the HKADC VREG_OK.
- qcom,cal-val : Add this property for VADC_HC voltage ADC device to select from the following
		unsigned int. If the property is not present the default calibration value of
		using the timer value is chosen.
		    0 : The calibration values used for measurement are from a timer.
		    1 : Forces a fresh measurement for calibration values at the same time
			measurement is taken.

Client required property:
- qcom,<consumer name>-vadc : The phandle to the corresponding vadc device.
			The consumer name passed to the driver when calling
			qpnp_get_vadc() is used to associate the client
			with the corresponding device.

Required properties:
- label : Channel name used for sysfs entry.
- reg : AMUX channel number.
- qcom,decimation : Sampling rate to use for the individual channel measurement.
		    Select from following unsigned int for Voltage ADC device.
		    0 : 512
		    1 : 1K
		    2 : 2K
		    3 : 4K
		    Select from following unsigned int for VADC_HC voltage ADC device.
		    0 : 256
		    1 : 512
		    2 : 1024
- qcom,pre-div-channel-scaling : Pre-div used for the channel before the signal
				 is being measured. Some of the AMUX channels
				 support dividing the signal from a predetermined
				 ratio. The configuration for this node is to know
				 the pre-determined ratio and use it for post scaling.
				 Select from the following unsigned int.
				 0 : {1, 1}
				 1 : {1, 3}
				 2 : {1, 4}
				 3 : {1, 6}
				 4 : {1, 20}
				 5 : {1, 8}
				 6 : {10, 81}
				 7 : {1, 10}
- qcom,calibration-type : Reference voltage to use for channel calibration.
			  Channel calibration is dependendent on the channel.
			  Certain channels like XO_THERM, BATT_THERM use ratiometric
			  calibration. Most other channels fall under absolute calibration.
			  Select from the following strings.
			  "absolute" : Uses the 625mv and 1.25V reference channels.
			  "ratiometric" : Uses the reference Voltage/GND for calibration.
- qcom,scale-function : Scaling function used to convert raw ADC code to units specific to
			a given channel.
			Select from the following unsigned int.
			0 : Default scaling to convert raw adc code to voltage.
			1 : Conversion to temperature based on btm parameters.
			2 : Returns result in degC for 100k pull-up.
			3 : Returns current across 0.1 ohm resistor.
			4 : Returns XO thermistor voltage in degree's Centigrade.
			5 : Returns result in degC for 150k pull-up.
			9 : Conversion to temperature based on -15~55 allowable
			    battery charging tempeature setting for btm parameters.
- qcom,hw-settle-time : Settling period for the channel before ADC read.
			Select from the following unsigned int.
			0 : 0us
			1 : 100us
			2 : 200us
			3 : 300us
			4 : 400us
			5 : 500us
			6 : 600us
			7 : 700us
			8 : 800us
			9 : 900us
			0xa : 1ms
			0xb : 2ms
			0xc : 4ms
			0xd : 6ms
			0xe : 8ms
			0xf : 10ms
- qcom,fast-avg-setup : Average number of samples to be used for measurement. Fast 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)
			Select from the following unsigned int for Voltage ADC device.
			0 : 1
			1 : 2
			2 : 4
			3 : 8
			4 : 16
			5 : 32
			6 : 64
			7 : 128
			8 : 256
			Select from the following unsigned int for VADC_HC ADC device.
			0 : 1
			1 : 2
			2 : 4
			3 : 8
			4 : 16

Example:
	/* Main Node */
	qcom,vadc@3100 {
                        compatible = "qcom,qpnp-vadc";
                        reg = <0x3100 0x100>;
			#address-cells = <1>;
			#size-cells = <0>;
                        interrupts = <0x0 0x31 0x0>;
			interrupt-names = "eoc-int-en-set";
                        qcom,adc-bit-resolution = <15>;
                        qcom,adc-vdd-reference = <1800>;

			/* Channel Node */
                        chan@0 {
                                label = "usb_in";
                                reg = <0>;
                                qcom,decimation = <0>;
                                qcom,pre-div-channel-scaling = <4>;
                                qcom,calibration-type = "absolute";
                                qcom,scale-function = <0>;
                                qcom,hw-settle-time = <0>;
                                qcom,fast-avg-setup = <0>;
                        };
	};

Client device example:
/* Add to the clients node that needs the VADC channel A/D */
client_node {
	qcom,client-vadc = <&pm8941_vadc>;
};

/* Clients have an option of measuring an analog signal through an MPP.
   MPP block is not part of the VADC block but is an individual PMIC
   block that has an option to support clients to configure an MPP as
   an analog input which can be routed through one of the VADC pre-mux
   inputs. Here is an example of how to configure an MPP as an analog
   input */

/* Configure MPP4 as an Analog input to AMUX8 and read from channel 0x23 */
/* MPP DT configuration in the platform DT file*/
	mpp@a300 { /* MPP 4 */
		qcom,mode = <4>; /* AIN input */
		qcom,invert = <1>; /* Enable MPP */
		qcom,ain-route = <3>; /* AMUX 8 */
		qcom,master-en = <1>;
		qcom,src-sel = <0>; /* Function constant */
	};

/* VADC Channel configuration */
	chan@23 {
		label = "mpp4_div3";
		reg = <0x23>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <1>;
		qcom,calibration-type = "absolute";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0>;
		qcom,fast-avg-setup = <0>;
	};
+20 −0
Original line number Diff line number Diff line
@@ -1243,6 +1243,26 @@ config SENSORS_PCF8591
	  These devices are hard to detect and rarely found on mainstream
	  hardware.  If unsure, say N.

config SENSORS_QPNP_ADC_VOLTAGE
	tristate "Support for Qualcomm Technologies Inc. QPNP Voltage ADC"
	depends on SPMI
	help
	  This is the VADC arbiter driver for Qualcomm Technologies Inc. QPNP ADC Chip.

	  The driver supports reading the HKADC, XOADC through the ADC AMUX arbiter.
	  The VADC includes support for the conversion sequencer. The driver supports
	  reading the ADC through the AMUX channels for external pull-ups simultaneously.

config SENSORS_QPNP_ADC_CURRENT
	tristate "Support for Qualcomm Technologies Inc. QPNP current ADC"
	depends on SPMI
	help
	  This is the IADC driver for Qualcomm Technologies Inc. QPNP ADC Chip.

	  The driver supports single mode operation to read from upto seven channel
	  configuration that include reading the external/internal Rsense, CSP_EX,
	  CSN_EX pair along with the gain and offset calibration.

source drivers/hwmon/pmbus/Kconfig

config SENSORS_PWM_FAN
+2 −0
Original line number Diff line number Diff line
@@ -166,6 +166,8 @@ obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o
obj-$(CONFIG_SENSORS_WM831X)	+= wm831x-hwmon.o
obj-$(CONFIG_SENSORS_WM8350)	+= wm8350-hwmon.o
obj-$(CONFIG_SENSORS_XGENE)	+= xgene-hwmon.o
obj-$(CONFIG_SENSORS_QPNP_ADC_VOLTAGE)	+= qpnp-adc-voltage.o qpnp-adc-common.o
obj-$(CONFIG_SENSORS_QPNP_ADC_CURRENT)	+= qpnp-adc-current.o qpnp-adc-common.o

obj-$(CONFIG_PMBUS)		+= pmbus/

+2101 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading