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

Commit 9c671771 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: Add DT entry for bat_therm on QRD for PMI632"

parents c024636f 26a8bc4f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -24,3 +24,8 @@
	qcom,pmic-id = <0x010016 0x25 0x0 0x0>;
};

&pmi632_vadc {
	chan@4a {
		qcom,scale-function = <22>;
	};
};
+5 −0
Original line number Diff line number Diff line
@@ -24,3 +24,8 @@
	qcom,pmic-id = <0x010016 0x25 0xC 0x0>;
};

&pmi632_vadc {
	chan@4a {
		qcom,scale-function = <22>;
	};
};
+104 −0
Original line number Diff line number Diff line
@@ -677,6 +677,80 @@ static const struct qpnp_vadc_map_pt adcmap_batt_therm[] = {
	{124,	980}
};

/* Voltage to temperature */
static const struct qpnp_vadc_map_pt adcmap_batt_therm_qrd[] = {
	{1840,	-400},
	{1835,	-380},
	{1828,	-360},
	{1821,	-340},
	{1813,	-320},
	{1803,	-300},
	{1793,	-280},
	{1781,	-260},
	{1768,	-240},
	{1753,	-220},
	{1737,	-200},
	{1719,	-180},
	{1700,	-160},
	{1679,	-140},
	{1655,	-120},
	{1630,	-100},
	{1603,	-80},
	{1574,	-60},
	{1543,	-40},
	{1510,	-20},
	{1475,	00},
	{1438,	20},
	{1400,	40},
	{1360,	60},
	{1318,	80},
	{1276,	100},
	{1232,	120},
	{1187,	140},
	{1142,	160},
	{1097,	180},
	{1051,	200},
	{1005,	220},
	{960,	240},
	{915,	260},
	{871,	280},
	{828,	300},
	{786,	320},
	{745,	340},
	{705,	360},
	{666,	380},
	{629,	400},
	{594,	420},
	{560,	440},
	{527,	460},
	{497,	480},
	{467,	500},
	{439,	520},
	{413,	540},
	{388,	560},
	{365,	580},
	{343,	600},
	{322,	620},
	{302,	640},
	{284,	660},
	{267,	680},
	{251,	700},
	{235,	720},
	{221,	740},
	{208,	760},
	{195,	780},
	{184,	800},
	{173,	820},
	{163,	840},
	{153,	860},
	{144,	880},
	{136,	900},
	{128,	920},
	{120,	940},
	{114,	960},
	{107,	980}
};

/*
 * Voltage to temperature table for 100k pull up for NTCG104EF104 with
 * 1.875V reference.
@@ -1016,6 +1090,36 @@ int32_t qpnp_adc_batt_therm(struct qpnp_vadc_chip *chip,
}
EXPORT_SYMBOL(qpnp_adc_batt_therm);

int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *chip,
		int32_t adc_code,
		const struct qpnp_adc_properties *adc_properties,
		const struct qpnp_vadc_chan_properties *chan_properties,
		struct qpnp_vadc_result *adc_chan_result)
{
	int64_t batt_thm_voltage = 0;

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

	if (adc_properties->adc_hc) {
		/* (code * vref_vadc (1.875V) * 1000) / (scale_code * 1000) */
		if (adc_code > QPNP_VADC_HC_MAX_CODE)
			adc_code = 0;
		batt_thm_voltage = (int64_t) adc_code;
		batt_thm_voltage *= (adc_properties->adc_vdd_reference
							* 1000);
		batt_thm_voltage = div64_s64(batt_thm_voltage,
				adc_properties->full_scale_code * 1000);
		qpnp_adc_map_voltage_temp(adcmap_batt_therm_qrd,
			ARRAY_SIZE(adcmap_batt_therm_qrd),
			batt_thm_voltage, &adc_chan_result->physical);
	}
	return 0;
}
EXPORT_SYMBOL(qpnp_adc_batt_therm_qrd);

int32_t qpnp_adc_scale_batt_therm(struct qpnp_vadc_chip *chip,
		int32_t adc_code,
		const struct qpnp_adc_properties *adc_properties,
+1 −0
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ static struct qpnp_vadc_scale_fn vadc_scale_fn[] = {
	[SCALE_DIE_TEMP] = {qpnp_adc_scale_die_temp},
	[SCALE_I_DEFAULT] = {qpnp_iadc_scale_default},
	[SCALE_USBIN_I] = {qpnp_adc_scale_usbin_curr},
	[SCALE_BATT_THERM_TEMP_QRD] = {qpnp_adc_batt_therm_qrd},
};

static struct qpnp_vadc_rscale_fn adc_vadc_rscale_fn[] = {
+26 −0
Original line number Diff line number Diff line
@@ -388,6 +388,8 @@ enum qpnp_adc_channel_scaling_param {
 * %SCALE_DIE_TEMP: Conversion for die temp.
 * %SCALE_I_DEFAULT: Default scaling to convert raw adc code to current (uA).
 * %SCALE_USBIN_I: Conversion for USB input current.
 * %SCALE_BATT_THERM_TEMP_QRD: Conversion to temperature(decidegC) based on btm
 *			parameters for QRD.
 * %SCALE_NONE: Do not use this scaling type.
 */
enum qpnp_adc_scale_fn_type {
@@ -410,6 +412,7 @@ enum qpnp_adc_scale_fn_type {
	SCALE_DIE_TEMP,
	SCALE_I_DEFAULT,
	SCALE_USBIN_I,
	SCALE_BATT_THERM_TEMP_QRD,
	SCALE_NONE,
};

@@ -1431,6 +1434,23 @@ int32_t qpnp_adc_batt_therm(struct qpnp_vadc_chip *dev,
			const struct qpnp_adc_properties *adc_prop,
			const struct qpnp_vadc_chan_properties *chan_prop,
			struct qpnp_vadc_result *chan_rslt);
/**
 * qpnp_adc_batt_therm_qrd() - Scales the pre-calibrated digital output
 *		of an ADC to the ADC reference and compensates for the
 *		gain and offset. Returns the temperature in decidegC for QRD.
 * @dev:	Structure device for qpnp vadc
 * @adc_code:	pre-calibrated digital output of the ADC.
 * @adc_prop:	adc properties of the pm8xxx adc such as bit resolution,
 *		reference voltage.
 * @chan_prop:	individual channel properties to compensate the i/p scaling,
 *		slope and offset.
 * @chan_rslt:	physical result to be stored.
 */
int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *dev,
			int32_t adc_code,
			const struct qpnp_adc_properties *adc_prop,
			const struct qpnp_vadc_chan_properties *chan_prop,
			struct qpnp_vadc_result *chan_rslt);
/**
 * qpnp_adc_scale_batt_therm() - Scales the pre-calibrated digital output
 *		of an ADC to the ADC reference and compensates for the
@@ -2033,6 +2053,12 @@ static inline int32_t qpnp_adc_batt_therm(struct qpnp_vadc_chip *vadc,
			const struct qpnp_vadc_chan_properties *chan_prop,
			struct qpnp_vadc_result *chan_rslt)
{ return -ENXIO; }
static inline int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *vadc,
			int32_t adc_code,
			const struct qpnp_adc_properties *adc_prop,
			const struct qpnp_vadc_chan_properties *chan_prop,
			struct qpnp_vadc_result *chan_rslt)
{ return -ENXIO; }
static inline int32_t qpnp_adc_scale_batt_therm(struct qpnp_vadc_chip *vadc,
			int32_t adc_code,
			const struct qpnp_adc_properties *adc_prop,