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

Commit f28b592e authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

hwmon: qpnp-adc: Enable VADC_HC peripheral



Add support to allow clients to perform single
measurement requests on VADC_HC peripheral.
Channels include reading vph_pwr input, PMIC
die temperature, coin cell input voltage,
battery input and system thermistors.

The peripheral configures individual channel
properties such as the calibration type, hardware
settling delay, fast averaging and decimation ratio
associated with the channel when the individual
channel measurement request is issued. The client
receives the raw ADC code and the physical scaled
result associated with the channel.

Change-Id: I73bfdb05b7561efa4b3d7c8d2fa7f8d0df5ea48e
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 13fe987c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -8,7 +8,8 @@ for the USR peripheral of the VADC.
VADC node

Required properties:
- compatible : should be "qcom,qpnp-vadc" for Voltage ADC driver.
- compatible : should be "qcom,qpnp-vadc" for Voltage ADC driver and
		"qcom,qpnp-vadc-hc" for VADC_HC voltage ADC driver.
- reg : offset and length of the PMIC Aribter register map.
- address-cells : Must be one.
- size-cells : Must be zero.
+166 −149
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#define QPNP_VADC_OK_VOLTAGE_MAX	1000000
#define PMI_CHG_SCALE_1		-138890
#define PMI_CHG_SCALE_2		391750000000
#define QPNP_VADC_HC_VREF_CODE		0x4000

/* Units for temperature below (on x axis) is in 0.1DegC as
   required by the battery driver. Note the resolution used
@@ -584,6 +585,47 @@ static const struct qpnp_vadc_map_pt adcmap_ncp03wf683[] = {
	{30,	125}
};

/*
 * Voltage to temperature table for 100k pull up for NTCG104EF104 with
 * 1.875V reference.
 */
static const struct qpnp_vadc_map_pt adcmap_100k_104ef_104fb_1875_vref[] = {
	{ 1831,	-40 },
	{ 1814,	-35 },
	{ 1791,	-30 },
	{ 1761,	-25 },
	{ 1723,	-20 },
	{ 1675,	-15 },
	{ 1616,	-10 },
	{ 1545,	-5 },
	{ 1463,	0 },
	{ 1370,	5 },
	{ 1268,	10 },
	{ 1160,	15 },
	{ 1049,	20 },
	{ 937,	25 },
	{ 828,	30 },
	{ 726,	35 },
	{ 630,	40 },
	{ 544,	45 },
	{ 467,	50 },
	{ 399,	55 },
	{ 340,	60 },
	{ 290,	65 },
	{ 247,	70 },
	{ 209,	75 },
	{ 179,	80 },
	{ 153,	85 },
	{ 130,	90 },
	{ 112,	95 },
	{ 96,	100 },
	{ 82,	105 },
	{ 71,	110 },
	{ 62,	115 },
	{ 53,	120 },
	{ 46,	125 },
};

static int32_t qpnp_adc_map_voltage_temp(const struct qpnp_vadc_map_pt *pts,
		uint32_t tablesize, int32_t input, int64_t *output)
{
@@ -675,59 +717,23 @@ static int32_t qpnp_adc_map_temp_voltage(const struct qpnp_vadc_map_pt *pts,
	return 0;
}

static int64_t qpnp_adc_scale_absolute_calib(int32_t adc_code,
static void qpnp_adc_scale_with_calib_param(int32_t adc_code,
		const struct qpnp_adc_properties *adc_properties,
		const struct qpnp_vadc_chan_properties *chan_properties)
		const struct qpnp_vadc_chan_properties *chan_properties,
		int64_t *scale_voltage)
{
	int64_t adc_voltage = 0;
	bool negative_offset = 0;

	if (!chan_properties || !chan_properties->offset_gain_numerator ||
		!chan_properties->offset_gain_denominator || !adc_properties)
		return -EINVAL;

	adc_voltage = (adc_code -
		chan_properties->adc_graph[CALIB_ABSOLUTE].adc_gnd)
	*scale_voltage = (adc_code -
		chan_properties->adc_graph[chan_properties->calib_type].adc_gnd)
		* chan_properties->adc_graph[chan_properties->calib_type].dx;
	if (adc_voltage < 0) {
		negative_offset = 1;
		adc_voltage = -adc_voltage;
	}
	do_div(adc_voltage,
		chan_properties->adc_graph[CALIB_ABSOLUTE].dy);

	if (negative_offset)
		adc_voltage = -adc_voltage;
	adc_voltage +=
		chan_properties->adc_graph[CALIB_ABSOLUTE].dx;

	return adc_voltage;
}

static int64_t qpnp_adc_scale_ratiometric_calib(int32_t adc_code,
		const struct qpnp_adc_properties *adc_properties,
		const struct qpnp_vadc_chan_properties *chan_properties)
{
	int64_t adc_voltage = 0;
	bool negative_offset = 0;

	if (!chan_properties || !chan_properties->offset_gain_numerator ||
		!chan_properties->offset_gain_denominator || !adc_properties)
		return -EINVAL;
	*scale_voltage = div64_s64(*scale_voltage,
		chan_properties->adc_graph[chan_properties->calib_type].dy);

	adc_voltage = (adc_code -
		chan_properties->adc_graph[CALIB_RATIOMETRIC].adc_gnd)
		* adc_properties->adc_vdd_reference;
	if (adc_voltage < 0) {
		negative_offset = 1;
		adc_voltage = -adc_voltage;
	}
	do_div(adc_voltage,
		chan_properties->adc_graph[CALIB_RATIOMETRIC].dy);
	if (negative_offset)
		adc_voltage = -adc_voltage;
	if (chan_properties->calib_type == CALIB_ABSOLUTE)
		*scale_voltage +=
		chan_properties->adc_graph[chan_properties->calib_type].dx;

	return adc_voltage;
	if (*scale_voltage < 0)
		*scale_voltage = 0;
}

int32_t qpnp_adc_scale_pmic_therm(struct qpnp_vadc_chip *vadc,
@@ -737,7 +743,6 @@ int32_t qpnp_adc_scale_pmic_therm(struct qpnp_vadc_chip *vadc,
		struct qpnp_vadc_result *adc_chan_result)
{
	int64_t pmic_voltage = 0;
	bool negative_offset = 0;

	if (!chan_properties || !chan_properties->offset_gain_numerator ||
		!chan_properties->offset_gain_denominator || !adc_properties
@@ -745,19 +750,15 @@ int32_t qpnp_adc_scale_pmic_therm(struct qpnp_vadc_chip *vadc,
		|| !chan_properties->adc_graph[CALIB_ABSOLUTE].dy)
		return -EINVAL;

	pmic_voltage = (adc_code -
		chan_properties->adc_graph[CALIB_ABSOLUTE].adc_gnd)
		* chan_properties->adc_graph[CALIB_ABSOLUTE].dx;
	if (pmic_voltage < 0) {
		negative_offset = 1;
		pmic_voltage = -pmic_voltage;
	}
	do_div(pmic_voltage,
		chan_properties->adc_graph[CALIB_ABSOLUTE].dy);
	if (negative_offset)
		pmic_voltage = -pmic_voltage;
	pmic_voltage += chan_properties->adc_graph[CALIB_ABSOLUTE].dx;

	if (adc_properties->adc_hc) {
		/* (ADC code * vref_vadc (1.875V)) / 0x4000 */
		pmic_voltage = (adc_code * adc_properties->adc_vdd_reference
								* 1000);
		pmic_voltage = div64_s64(pmic_voltage,
					(QPNP_VADC_HC_VREF_CODE * 1000));
	} else
		qpnp_adc_scale_with_calib_param(adc_code, adc_properties,
					chan_properties, &pmic_voltage);
	if (pmic_voltage > 0) {
		/* 2mV/K */
		adc_chan_result->measurement = pmic_voltage*
@@ -765,9 +766,9 @@ int32_t qpnp_adc_scale_pmic_therm(struct qpnp_vadc_chip *vadc,

		do_div(adc_chan_result->measurement,
			chan_properties->offset_gain_numerator * 2);
	} else {
	} else
		adc_chan_result->measurement = 0;
	}

	/* Change to .001 deg C */
	adc_chan_result->measurement -= KELVINMIL_DEGMIL;
	adc_chan_result->physical = (int32_t)adc_chan_result->measurement;
@@ -837,24 +838,34 @@ int32_t qpnp_adc_tdkntcg_therm(struct qpnp_vadc_chip *chip,
		const struct qpnp_vadc_chan_properties *chan_properties,
		struct qpnp_vadc_result *adc_chan_result)
{
	int64_t xo_thm = 0;
	int64_t xo_thm_voltage = 0;

	if (!chan_properties || !chan_properties->offset_gain_numerator ||
		!chan_properties->offset_gain_denominator || !adc_properties
		|| !adc_chan_result)
		return -EINVAL;

	if (chan_properties->calib_type == CALIB_ABSOLUTE) {
		xo_thm = qpnp_adc_scale_absolute_calib(adc_code,
			adc_properties, chan_properties);
		do_div(xo_thm , 1000);
	if (adc_properties->adc_hc) {
		/* (ADC code * vref_vadc (1.875V) * 1000) / (0x4000 * 1000) */
		xo_thm_voltage = (adc_code * adc_properties->adc_vdd_reference
							* 1000);
		xo_thm_voltage = div64_s64(xo_thm_voltage,
					(QPNP_VADC_HC_VREF_CODE * 1000));

		qpnp_adc_map_voltage_temp(adcmap_100k_104ef_104fb_1875_vref,
			ARRAY_SIZE(adcmap_100k_104ef_104fb_1875_vref),
			xo_thm_voltage, &adc_chan_result->physical);
	} else {
		xo_thm = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	}
		qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &xo_thm_voltage);

		if (chan_properties->calib_type == CALIB_ABSOLUTE)
			do_div(xo_thm_voltage, 1000);

		qpnp_adc_map_voltage_temp(adcmap_100k_104ef_104fb,
			ARRAY_SIZE(adcmap_100k_104ef_104fb),
		xo_thm, &adc_chan_result->physical);
			xo_thm_voltage, &adc_chan_result->physical);
	}

	return 0;
}
@@ -868,8 +879,8 @@ int32_t qpnp_adc_scale_batt_therm(struct qpnp_vadc_chip *chip,
{
	int64_t bat_voltage = 0;

	bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &bat_voltage);

	adc_chan_result->measurement = bat_voltage;

@@ -889,8 +900,8 @@ int32_t qpnp_adc_scale_qrd_batt_therm(struct qpnp_vadc_chip *chip,
{
	int64_t bat_voltage = 0;

	bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &bat_voltage);

	adc_chan_result->measurement = bat_voltage;

@@ -910,8 +921,8 @@ int32_t qpnp_adc_scale_qrd_skuaa_batt_therm(struct qpnp_vadc_chip *chip,
{
	int64_t bat_voltage = 0;

	bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &bat_voltage);

	adc_chan_result->measurement = bat_voltage;

@@ -931,9 +942,8 @@ int32_t qpnp_adc_scale_qrd_skug_batt_therm(struct qpnp_vadc_chip *chip,
{
	int64_t bat_voltage = 0;

	bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);

	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &bat_voltage);
	adc_chan_result->measurement = bat_voltage;

	return qpnp_adc_map_temp_voltage(
@@ -952,8 +962,8 @@ int32_t qpnp_adc_scale_qrd_skuh_batt_therm(struct qpnp_vadc_chip *chip,
{
	int64_t bat_voltage = 0;

	bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &bat_voltage);

	return qpnp_adc_map_temp_voltage(
			adcmap_qrd_skuh_btm_threshold,
@@ -971,8 +981,8 @@ int32_t qpnp_adc_scale_qrd_skut1_batt_therm(struct qpnp_vadc_chip *chip,
{
	int64_t bat_voltage = 0;

	bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &bat_voltage);

	return qpnp_adc_map_temp_voltage(
			adcmap_qrd_skut1_btm_threshold,
@@ -990,8 +1000,8 @@ int32_t qpnp_adc_scale_smb_batt_therm(struct qpnp_vadc_chip *chip,
{
	int64_t bat_voltage = 0;

	bat_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &bat_voltage);

	return qpnp_adc_map_temp_voltage(
			adcmap_smb_batt_therm,
@@ -1009,8 +1019,8 @@ int32_t qpnp_adc_scale_therm_pu1(struct qpnp_vadc_chip *chip,
{
	int64_t therm_voltage = 0;

	therm_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &therm_voltage);

	qpnp_adc_map_voltage_temp(adcmap_150k_104ef_104fb,
		ARRAY_SIZE(adcmap_150k_104ef_104fb),
@@ -1028,17 +1038,31 @@ int32_t qpnp_adc_scale_therm_pu2(struct qpnp_vadc_chip *chip,
{
	int64_t therm_voltage = 0;

	if (chan_properties->calib_type == CALIB_ABSOLUTE) {
		therm_voltage = qpnp_adc_scale_absolute_calib(adc_code,
			adc_properties, chan_properties);
		do_div(therm_voltage , 1000);
	if (!chan_properties || !chan_properties->offset_gain_numerator ||
		!chan_properties->offset_gain_denominator || !adc_properties)
		return -EINVAL;

	if (adc_properties->adc_hc) {
		/* (ADC code * vref_vadc (1.875V) * 1000) / (0x4000 * 1000) */
		therm_voltage = (adc_code * adc_properties->adc_vdd_reference
							* 1000);
		therm_voltage = div64_s64(therm_voltage,
					(QPNP_VADC_HC_VREF_CODE * 1000));

		qpnp_adc_map_voltage_temp(adcmap_100k_104ef_104fb_1875_vref,
			ARRAY_SIZE(adcmap_100k_104ef_104fb_1875_vref),
			therm_voltage, &adc_chan_result->physical);
	} else {
		therm_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	}
		qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &therm_voltage);

		if (chan_properties->calib_type == CALIB_ABSOLUTE)
			do_div(therm_voltage, 1000);

		qpnp_adc_map_voltage_temp(adcmap_100k_104ef_104fb,
			ARRAY_SIZE(adcmap_100k_104ef_104fb),
			therm_voltage, &adc_chan_result->physical);
	}

	return 0;
}
@@ -1111,8 +1135,8 @@ int32_t qpnp_adc_scale_therm_ncp03(struct qpnp_vadc_chip *chip,
{
	int64_t therm_voltage = 0;

	therm_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &therm_voltage);

	qpnp_adc_map_voltage_temp(adcmap_ncp03wf683,
		ARRAY_SIZE(adcmap_ncp03wf683),
@@ -1130,8 +1154,9 @@ int32_t qpnp_adc_scale_batt_id(struct qpnp_vadc_chip *chip,
{
	int64_t batt_id_voltage = 0;

	batt_id_voltage = qpnp_adc_scale_ratiometric_calib(adc_code,
			adc_properties, chan_properties);
	qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &batt_id_voltage);

	adc_chan_result->physical = batt_id_voltage;
	adc_chan_result->physical = adc_chan_result->measurement;

@@ -1145,7 +1170,6 @@ int32_t qpnp_adc_scale_default(struct qpnp_vadc_chip *vadc,
		const struct qpnp_vadc_chan_properties *chan_properties,
		struct qpnp_vadc_result *adc_chan_result)
{
	bool negative_rawfromoffset = 0, negative_offset = 0;
	int64_t scale_voltage = 0;

	if (!chan_properties || !chan_properties->offset_gain_numerator ||
@@ -1153,43 +1177,22 @@ int32_t qpnp_adc_scale_default(struct qpnp_vadc_chip *vadc,
		|| !adc_chan_result)
		return -EINVAL;

	scale_voltage = (adc_code -
		chan_properties->adc_graph[chan_properties->calib_type].adc_gnd)
		* chan_properties->adc_graph[chan_properties->calib_type].dx;
	if (scale_voltage < 0) {
		negative_offset = 1;
		scale_voltage = -scale_voltage;
	}
	do_div(scale_voltage,
		chan_properties->adc_graph[chan_properties->calib_type].dy);
	if (negative_offset)
		scale_voltage = -scale_voltage;

	if (chan_properties->calib_type == CALIB_ABSOLUTE)
		scale_voltage +=
		chan_properties->adc_graph[chan_properties->calib_type].dx;
	else
		scale_voltage *= 1000;

	if (scale_voltage < 0) {
		if (adc_properties->bipolar) {
			scale_voltage = -scale_voltage;
			negative_rawfromoffset = 1;
	if (adc_properties->adc_hc) {
		/* (ADC code * vref_vadc (1.875V)) / 0x4000 */
		scale_voltage = (adc_code * adc_properties->adc_vdd_reference
								* 1000);
		scale_voltage = div64_s64(scale_voltage,
						QPNP_VADC_HC_VREF_CODE);
	} else {
			scale_voltage = 0;
		}
		qpnp_adc_scale_with_calib_param(adc_code, adc_properties,
					chan_properties, &scale_voltage);
		scale_voltage *= 1000;
	}

	adc_chan_result->measurement = scale_voltage *
				chan_properties->offset_gain_denominator;

	/* do_div only perform positive integer division! */
	do_div(adc_chan_result->measurement,
	scale_voltage *= chan_properties->offset_gain_denominator;
	scale_voltage = div64_s64(scale_voltage,
				chan_properties->offset_gain_numerator);

	if (negative_rawfromoffset)
		adc_chan_result->measurement = -adc_chan_result->measurement;

	adc_chan_result->measurement = scale_voltage;
	/*
	 * Note: adc_chan_result->measurement is in the unit of
	 * adc_properties.adc_reference. For generic channel processing,
@@ -1774,6 +1777,7 @@ int32_t qpnp_adc_get_devicetree_data(struct spmi_device *spmi,
	struct qpnp_adc_properties *adc_prop;
	struct qpnp_adc_amux_properties *amux_prop;
	int count_adc_channel_list = 0, decimation, rc = 0, i = 0;
	bool adc_hc;

	if (!node)
		return -EINVAL;
@@ -1790,17 +1794,14 @@ int32_t qpnp_adc_get_devicetree_data(struct spmi_device *spmi,

	adc_prop = devm_kzalloc(&spmi->dev, sizeof(struct qpnp_adc_properties),
					GFP_KERNEL);
	if (!adc_prop) {
		dev_err(&spmi->dev, "Unable to allocate memory\n");
	if (!adc_prop)
		return -ENOMEM;
	}

	adc_channel_list = devm_kzalloc(&spmi->dev,
		((sizeof(struct qpnp_adc_amux)) * count_adc_channel_list),
				GFP_KERNEL);
	if (!adc_channel_list) {
		dev_err(&spmi->dev, "Unable to allocate memory\n");
	if (!adc_channel_list)
		return -ENOMEM;
	}

	amux_prop = devm_kzalloc(&spmi->dev,
		sizeof(struct qpnp_adc_amux_properties) +
@@ -1812,6 +1813,8 @@ int32_t qpnp_adc_get_devicetree_data(struct spmi_device *spmi,

	adc_qpnp->adc_channels = adc_channel_list;
	adc_qpnp->amux_prop = amux_prop;
	adc_hc = adc_qpnp->adc_hc;
	adc_prop->adc_hc = adc_hc;

	for_each_child_of_node(node, child) {
		int channel_num, scaling, post_scaling, hw_settle_time;
@@ -1861,15 +1864,29 @@ int32_t qpnp_adc_get_devicetree_data(struct spmi_device *spmi,
				pr_err("Invalid calibration type\n");
				return -EINVAL;
			}
			if (!strcmp(calibration_param, "absolute"))
			if (!strcmp(calibration_param, "absolute")) {
				if (adc_hc)
					calib_type = ADC_HC_ABS_CAL;
				else
					calib_type = CALIB_ABSOLUTE;
			else if (!strcmp(calibration_param, "ratiometric"))
			} else if (!strcmp(calibration_param, "ratiometric")) {
				if (adc_hc)
					calib_type = ADC_HC_RATIO_CAL;
				else
					calib_type = CALIB_RATIOMETRIC;
			} else if (!strcmp(calibration_param, "no_cal")) {
				if (adc_hc)
					calib_type = ADC_HC_NO_CAL;
				else {
					pr_err("%s: Invalid calibration property\n",
						__func__);
					return -EINVAL;
				}
			} else {
				pr_err("%s: Invalid calibration property\n",
						__func__);
				return -EINVAL;
			}
		}
		rc = of_property_read_u32(child,
				"qcom,fast-avg-setup", &fast_avg_setup);
+397 −122

File changed.

Preview size limit exceeded, changes collapsed.

+189 −6
Original line number Diff line number Diff line
@@ -121,7 +121,107 @@ enum qpnp_vadc_channels {
	LR_MUX10_PU1_PU2_AMUX_USB_ID_LV = 249,
	LR_MUX3_BUF_PU1_PU2_XO_THERM_BUF = 252,
	ALL_OFF = 255,
	ADC_MAX_NUM,
	ADC_MAX_NUM = 0xffff,

	/* Channel listing for refreshed VADC in hex format */
	VADC_VREF_GND = 0,
	VADC_CALIB_VREF_1P25 = 1,
	VADC_CALIB_VREF = 2,
	VADC_CALIB_VREF_1_DIV_3 = 0x82,
	VADC_VPH_PWR = 0x83,
	VADC_VBAT_SNS = 0x84,
	VADC_VCOIN = 0x85,
	VADC_DIE_TEMP = 6,
	VADC_CHG_TEMP = 7,
	VADC_USB_IN = 8,
	VADC_IREG_FB = 9,
	/* External input connection */
	VADC_BAT_THERM = 0xa,
	VADC_BAT_ID = 0xb,
	VADC_XO_THERM = 0xc,
	VADC_AMUX_THM1 = 0xd,
	VADC_AMUX_THM2 = 0xe,
	VADC_AMUX_THM3 = 0xf,
	VADC_AMUX_THM4 = 0x10,
	VADC_AMUX_THM5 = 0x11,
	VADC_AMUX1_GPIO = 0x12,
	VADC_AMUX2_GPIO = 0x13,
	VADC_AMUX3_GPIO = 0x14,
	VADC_AMUX4_GPIO = 0x15,
	VADC_AMUX5_GPIO = 0x16,
	VADC_AMUX6_GPIO = 0x17,
	VADC_AMUX7_GPIO = 0x18,
	VADC_AMUX8_GPIO = 0x19,
	VADC_ATEST1 = 0x1a,
	VADC_ATEST2 = 0x1b,
	VADC_ATEST3 = 0x1c,
	VADC_ATEST4 = 0x1d,
	VADC_OFF = 0xff,
	/* PU1 is 30K pull up */
	VADC_BAT_THERM_PU1 = 0x2a,
	VADC_BAT_ID_PU1 = 0x2b,
	VADC_XO_THERM_PU1 = 0x2c,
	VADC_AMUX_THM1_PU1 = 0x2d,
	VADC_AMUX_THM2_PU1 = 0x2e,
	VADC_AMUX_THM3_PU1 = 0x2f,
	VADC_AMUX_THM4_PU1 = 0x30,
	VADC_AMUX_THM5_PU1 = 0x31,
	VADC_AMUX1_GPIO_PU1 = 0x32,
	VADC_AMUX2_GPIO_PU1 = 0x33,
	VADC_AMUX3_GPIO_PU1 = 0x34,
	VADC_AMUX4_GPIO_PU1 = 0x35,
	VADC_AMUX5_GPIO_PU1 = 0x36,
	VADC_AMUX6_GPIO_PU1 = 0x37,
	VADC_AMUX7_GPIO_PU1 = 0x38,
	VADC_AMUX8_GPIO_PU1 = 0x39,
	/* PU2 is 100K pull up */
	VADC_BAT_THERM_PU2 = 0x4a,
	VADC_BAT_ID_PU2 = 0x4b,
	VADC_XO_THERM_PU2 = 0x4c,
	VADC_AMUX_THM1_PU2 = 0x4d,
	VADC_AMUX_THM2_PU2 = 0x4e,
	VADC_AMUX_THM3_PU2 = 0x4f,
	VADC_AMUX_THM4_PU2 = 0x50,
	VADC_AMUX_THM5_PU2 = 0x51,
	VADC_AMUX1_GPIO_PU2 = 0x52,
	VADC_AMUX2_GPIO_PU2 = 0x53,
	VADC_AMUX3_GPIO_PU2 = 0x54,
	VADC_AMUX4_GPIO_PU2 = 0x55,
	VADC_AMUX5_GPIO_PU2 = 0x56,
	VADC_AMUX6_GPIO_PU2 = 0x57,
	VADC_AMUX7_GPIO_PU2 = 0x58,
	VADC_AMUX8_GPIO_PU2 = 0x59,
	/* PU3 is 400K pull up */
	VADC_BAT_THERM_PU3 = 0x6a,
	VADC_BAT_ID_PU3 = 0x6b,
	VADC_XO_THERM_PU3 = 0x6c,
	VADC_AMUX_THM1_PU3 = 0x6d,
	VADC_AMUX_THM2_PU3 = 0x6e,
	VADC_AMUX_THM3_PU3 = 0x6f,
	VADC_AMUX_THM4_PU3 = 0x70,
	VADC_AMUX_THM5_PU3 = 0x71,
	VADC_AMUX1_GPIO_PU3 = 0x72,
	VADC_AMUX2_GPIO_PU3 = 0x73,
	VADC_AMUX3_GPIO_PU3 = 0x74,
	VADC_AMUX4_GPIO_PU3 = 0x75,
	VADC_AMUX5_GPIO_PU3 = 0x76,
	VADC_AMUX6_GPIO_PU3 = 0x77,
	VADC_AMUX7_GPIO_PU3 = 0x78,
	VADC_AMUX8_GPIO_PU3 = 0x79,
	/* External input connection with 1/3 div */
	VADC_AMUX1_GPIO_DIV_3 = 0x92,
	VADC_AMUX2_GPIO_DIV_3 = 0x93,
	VADC_AMUX3_GPIO_DIV_3 = 0x94,
	VADC_AMUX4_GPIO_DIV_3 = 0x95,
	VADC_AMUX5_GPIO_DIV_3 = 0x96,
	VADC_AMUX6_GPIO_DIV_3 = 0x97,
	VADC_AMUX7_GPIO_DIV_3 = 0x98,
	VADC_AMUX8_GPIO_DIV_3 = 0x99,
	VADC_ATEST1_DIV_3 = 0x9a,
	VADC_ATEST2_DIV_3 = 0x9b,
	VADC_ATEST3_DIV_3 = 0x9c,
	VADC_ATEST4_DIV_3 = 0x9d,
	VADC_REFRESH_MAX_NUM = 0xffff,
};

/**
@@ -185,7 +285,12 @@ enum qpnp_adc_decimation_type {
	DECIMATION_TYPE2,
	DECIMATION_TYPE3,
	DECIMATION_TYPE4,
	DECIMATION_NONE,
	DECIMATION_NONE = 0xff,

	ADC_HC_DEC_RATIO_256 = 0,
	ADC_HC_DEC_RATIO_512 = 1,
	ADC_HC_DEC_RATIO_1024 = 2,
	ADC_HC_DEC_RATIO_NONE = 0xff,
};

/**
@@ -194,6 +299,19 @@ enum qpnp_adc_decimation_type {
 * %ADC_CALIB_RATIOMETRIC: Use reference Voltage/GND.
 * %ADC_CALIB_CONFIG_NONE: Do not use this calibration type.
 *
 * enum qpnp_adc_cal_sel - Selects the calibration type that is applied
 *			   on the corresponding channel measurement after
 *			   the ADC data is read.
 * %ADC_HC_NO_CAL :	To obtain raw, uncalibrated data on qpnp-vadc-hc type.
 * %ADC_HC_RATIO_CAL :	Applies ratiometric calibration. Note the calibration
 *			values stored in the CAL peripheral for VADC_VREF and
 *			VREF_1P25 already have GND_REF value removed. Used
 *			only with qpnp-vadc-hc type of VADC.
 * %ADC_HC_ABS_CAL :	Applies absolute calibration. Note the calibration
 *			values stored in the CAL peripheral for VADC_VREF and
 *			VREF_1P25 already have GND_REF value removed. Used
 *			only with qpnp-vadc-hc type of VADC.
 *
 * Use the input reference voltage depending on the calibration type
 * to calcluate the offset and gain parameters. The calibration is
 * specific to each channel of the QPNP ADC.
@@ -202,6 +320,11 @@ enum qpnp_adc_calib_type {
	CALIB_ABSOLUTE = 0,
	CALIB_RATIOMETRIC,
	CALIB_NONE,

	ADC_HC_NO_CAL = 0,
	ADC_HC_RATIO_CAL = 1,
	ADC_HC_ABS_CAL = 2,
	ADC_HC_CAL_SEL_NONE,
};

/**
@@ -384,6 +507,46 @@ enum qpnp_adc_hw_settle_time {
	ADC_CHANNEL_HW_SETTLE_NONE,
};

/**
 * enum qpnp_adc_dec_ratio_sel - Selects the decimation ratio of the ADC.
 *				 Support values are 256, 512 and 1024.
 */
enum qpnp_vadc_dec_ratio_sel {
	ADC_DEC_RATIO_256 = 0,
	ADC_DEC_RATIO_512,
	ADC_DEC_RATIO_1024,
	ADC_DEC_RATIO_NONE,
};

/**
 * enum qpnp_adc_cal_sel - Selects the calibration type that is applied
 *			   on the corresponding channel measurement after
 *			   the ADC data is read.
 * %ADC_NO_CAL :	To obtain raw, uncalibrated data.
 * %ADC_RATIO_CAL :	Applies ratiometric calibration. Note the calibration
 *			values stored in the CAL peripheral for VADC_VREF and
 *			VREF_1P25 already have GND_REF value removed.
 * %ADC_ABS_CAL :	Applies absolute calibration. Note the calibration
 *			values stored in the CAL peripheral for VADC_VREF and
 *			VREF_1P25 already have GND_REF value removed.
 */

/**
 * enum qpnp_adc_cal_val - Selects if the calibration values applied
 *			    are the ones when collected on a timer interval
 *			    or if an immediate calibration needs to be forced.
 * %ADC_TIMER_CAL : Uses calibration value collected on the timer interval.
 * %ADC_NEW_CAL : Forces an immediate calibration. Use only when necessary
 *		  since it forces 3 calibration measurements in addition to
 *		  the channel measurement. For most measurement, using
 *		  calibration based on the timer interval is sufficient.
 */
enum qpnp_adc_cal_val {
	ADC_TIMER_CAL = 0,
	ADC_NEW_CAL,
	ADC_CAL_VAL_NONE,
};

/**
 * enum qpnp_vadc_mode_sel - Selects the basic mode of operation.
 *		- The normal mode is used for single measurement.
@@ -862,11 +1025,13 @@ struct qpnp_vadc_scaling_ratio {
 * @adc_reference: Reference voltage for QPNP ADC.
 * @bitresolution: ADC bit resolution for QPNP ADC.
 * @biploar: Polarity for QPNP ADC.
 * @adc_hc: Represents using HC variant of the ADC controller.
 */
struct qpnp_adc_properties {
	uint32_t	adc_vdd_reference;
	uint32_t	bitresolution;
	bool		bipolar;
	bool		adc_hc;
};

/**
@@ -941,6 +1106,7 @@ struct qpnp_adc_amux {
	enum qpnp_adc_fast_avg_ctl		fast_avg_setup;
	enum qpnp_adc_hw_settle_time		hw_settle_time;
	enum qpnp_adc_calib_type		calib_type;
	enum qpnp_adc_cal_val			cal_val;
};

/**
@@ -1063,6 +1229,7 @@ struct qpnp_adc_drv {
	struct qpnp_iadc_calib		calib;
	struct regulator		*hkadc_ldo;
	struct regulator		*hkadc_ldo_ok;
	bool				adc_hc;
};

/**
@@ -1118,6 +1285,18 @@ int32_t qpnp_vadc_read(struct qpnp_vadc_chip *dev,
				enum qpnp_vadc_channels channel,
				struct qpnp_vadc_result *result);

/**
 * qpnp_vadc_hc_read() - Performs ADC read on the channel.
 *		It uses the refreshed VADC design from qpnp-vadc-hc.
 * @dev:	Structure device for qpnp vadc
 * @channel:	Input channel to perform the ADC read.
 * @result:	Structure pointer of type adc_chan_result
 *		in which the ADC read results are stored.
 */
int32_t qpnp_vadc_hc_read(struct qpnp_vadc_chip *dev,
				enum qpnp_vadc_channels channel,
				struct qpnp_vadc_result *result);

/**
 * qpnp_vadc_conv_seq_request() - Performs ADC read on the conversion
 *				sequencer channel.
@@ -1695,6 +1874,10 @@ static inline int32_t qpnp_vadc_read(struct qpnp_vadc_chip *dev,
				uint32_t channel,
				struct qpnp_vadc_result *result)
{ return -ENXIO; }
static inline int32_t qpnp_vadc_hc_read(struct qpnp_vadc_chip *dev,
				uint32_t channel,
				struct qpnp_vadc_result *result)
{ return -ENXIO; }
static inline int32_t qpnp_vadc_conv_seq_request(struct qpnp_vadc_chip *dev,
			enum qpnp_vadc_trigger trigger_channel,
			enum qpnp_vadc_channels channel,