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

Commit 137abbe9 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 VADC and ADC_TM nodes for QM215"

parents 788307b1 afaa4092
Loading
Loading
Loading
Loading
+229 −0
Original line number Original line Diff line number Diff line
@@ -196,3 +196,232 @@
	vdd_hf_dig-supply = <&pm8916_s1_level_ao>;
	vdd_hf_dig-supply = <&pm8916_s1_level_ao>;
	vdd_hf_pll-supply = <&pm8916_l7_ao>;
	vdd_hf_pll-supply = <&pm8916_l7_ao>;
};
};

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

	chan@2 {
		label = "ireg_fb";
		reg = <2>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <6>;
		qcom,calibration-type = "absolute";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0>;
		qcom,fast-avg-setup = <0>;
	};

	chan@5 {
		label = "vcoin";
		reg = <5>;
		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>;
	};

	chan@6 {
		label = "vbat_sns";
		reg = <6>;
		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>;
	};

	chan@7 {
		label = "vph_pwr";
		reg = <7>;
		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>;
	};

	chan@b {
		label = "chg_temp";
		reg = <0xb>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "absolute";
		qcom,scale-function = <3>;
		qcom,hw-settle-time = <0>;
		qcom,fast-avg-setup = <0>;
	};

	chan@11 {
		label = "skin_therm";
		reg = <0x11>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
		qcom,vadc-thermal-node;
	};

	chan@30 {
		label = "batt_therm";
		reg = <0x30>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <22>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};

	chan@36 {
		label = "pa_therm0";
		reg = <0x36>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <2>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
		qcom,vadc-thermal-node;
	};

	chan@32 {
		label = "xo_therm";
		reg = <0x32>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <4>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
		qcom,vadc-thermal-node;
	};

	chan@3c {
		label = "xo_therm_buf";
		reg = <0x3c>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <4>;
		qcom,hw-settle-time = <2>;
		qcom,fast-avg-setup = <0>;
		qcom,vadc-thermal-node;
	};
};

&pm8916_adc_tm {
	/* Channel Node */
	chan@30 {
		label = "batt_therm";
		reg = <0x30>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <8>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0x2>;
		qcom,btm-channel-number = <0x48>;
	};

	chan@6 {
		label = "vbat_sns";
		reg = <0x6>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <1>;
		qcom,calibration-type = "absolute";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0x2>;
		qcom,btm-channel-number = <0x68>;
	};
};

&soc {
	thermal-zones {
		xo-therm-buf-adc {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8916_vadc 0x3c>;
			thermal-governor = "user_space";

			trips {
				active-config0 {
					temperature = <65000>;
					hysteresis = <1000>;
					type = "passive";
				};
			};
		};

		xo-therm-adc {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8916_vadc 0x32>;
			thermal-governor = "user_space";

			trips {
				active-config0 {
					temperature = <65000>;
					hysteresis = <1000>;
					type = "passive";
				};
			};
		};

		pa-therm0-adc {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8916_vadc 0x36>;
			thermal-governor = "user_space";

			trips {
				active-config0 {
					temperature = <65000>;
					hysteresis = <1000>;
					type = "passive";
				};
			};
		};

		skin-therm-adc {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8916_vadc 0x11>;
			thermal-governor = "user_space";

			trips {
				active-config0 {
					temperature = <65000>;
					hysteresis = <1000>;
					type = "passive";
				};
			};
		};
	};
};
+71 −0
Original line number Original line Diff line number Diff line
@@ -1263,6 +1263,19 @@ int32_t qpnp_adc_batt_therm_qrd(struct qpnp_vadc_chip *chip,
		qpnp_adc_map_voltage_temp(adcmap_batt_therm_qrd,
		qpnp_adc_map_voltage_temp(adcmap_batt_therm_qrd,
			ARRAY_SIZE(adcmap_batt_therm_qrd),
			ARRAY_SIZE(adcmap_batt_therm_qrd),
			batt_thm_voltage, &adc_chan_result->physical);
			batt_thm_voltage, &adc_chan_result->physical);
	} else {

		qpnp_adc_scale_with_calib_param(adc_code,
			adc_properties, chan_properties, &batt_thm_voltage);

		adc_chan_result->measurement = batt_thm_voltage;

		return qpnp_adc_map_voltage_temp(
				adcmap_batt_therm_qrd,
				ARRAY_SIZE(adcmap_batt_therm_qrd),
				batt_thm_voltage,
				&adc_chan_result->physical);

	}
	}
	return 0;
	return 0;
}
}
@@ -2152,6 +2165,64 @@ int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *chip,
}
}
EXPORT_SYMBOL(qpnp_adc_qrd_skut1_btm_scaler);
EXPORT_SYMBOL(qpnp_adc_qrd_skut1_btm_scaler);


int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *chip,
		struct qpnp_adc_tm_btm_param *param,
		uint32_t *low_threshold, uint32_t *high_threshold)
{
	struct qpnp_vadc_linear_graph btm_param;
	int64_t low_output = 0, high_output = 0;
	int rc = 0;

	if (param->adc_tm_hc) {
		pr_debug("Update scaling for VADC_TM_HC\n");
		return -EINVAL;
	}

	qpnp_get_vadc_gain_and_offset(chip, &btm_param, CALIB_RATIOMETRIC);

	pr_debug("warm_temp:%d and cool_temp:%d\n", param->high_temp,
				param->low_temp);
	rc = qpnp_adc_map_voltage_temp(
		adcmap_batt_therm_qrd,
		ARRAY_SIZE(adcmap_batt_therm_qrd),
		(param->low_temp),
		&low_output);
	if (rc) {
		pr_debug("low_temp mapping failed with %d\n", rc);
		return rc;
	}

	pr_debug("low_output:%lld\n", low_output);
	low_output *= btm_param.dy;
	low_output = div64_s64(low_output, btm_param.adc_vref);
	low_output += btm_param.adc_gnd;

	rc = qpnp_adc_map_voltage_temp(
		adcmap_batt_therm_qrd,
		ARRAY_SIZE(adcmap_batt_therm_qrd),
		(param->high_temp),
		&high_output);
	if (rc) {
		pr_debug("high temp mapping failed with %d\n", rc);
		return rc;
	}

	pr_debug("high_output:%lld\n", high_output);
	high_output *= btm_param.dy;
	high_output = div64_s64(high_output, btm_param.adc_vref);
	high_output += btm_param.adc_gnd;

	/* btm low temperature correspondes to high voltage threshold */
	*low_threshold = high_output;
	/* btm high temperature correspondes to low voltage threshold */
	*high_threshold = low_output;

	pr_debug("high_volt:%d, low_volt:%d\n", *high_threshold,
				*low_threshold);
	return 0;
}
EXPORT_SYMBOL(qpnp_adc_qrd_215_btm_scaler);

int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip,
int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip,
		struct qpnp_adc_tm_btm_param *param,
		struct qpnp_adc_tm_btm_param *param,
		uint32_t *low_threshold, uint32_t *high_threshold)
		uint32_t *low_threshold, uint32_t *high_threshold)
+1 −0
Original line number Original line Diff line number Diff line
@@ -361,6 +361,7 @@ static struct qpnp_adc_tm_reverse_scale_fn adc_tm_rscale_fn[] = {
	[SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr},
	[SCALE_R_ABSOLUTE] = {qpnp_adc_absolute_rthr},
	[SCALE_QRD_SKUH_RBATT_THERM] = {qpnp_adc_qrd_skuh_btm_scaler},
	[SCALE_QRD_SKUH_RBATT_THERM] = {qpnp_adc_qrd_skuh_btm_scaler},
	[SCALE_QRD_SKUT1_RBATT_THERM] = {qpnp_adc_qrd_skut1_btm_scaler},
	[SCALE_QRD_SKUT1_RBATT_THERM] = {qpnp_adc_qrd_skut1_btm_scaler},
	[SCALE_QRD_215_RBATT_THERM] = {qpnp_adc_qrd_215_btm_scaler},
};
};


static int32_t qpnp_adc_tm_read_reg(struct qpnp_adc_tm_chip *chip,
static int32_t qpnp_adc_tm_read_reg(struct qpnp_adc_tm_chip *chip,
+21 −0
Original line number Original line Diff line number Diff line
@@ -455,6 +455,7 @@ enum qpnp_adc_tm_rscale_fn_type {
	SCALE_R_ABSOLUTE,
	SCALE_R_ABSOLUTE,
	SCALE_QRD_SKUH_RBATT_THERM,
	SCALE_QRD_SKUH_RBATT_THERM,
	SCALE_QRD_SKUT1_RBATT_THERM,
	SCALE_QRD_SKUT1_RBATT_THERM,
	SCALE_QRD_215_RBATT_THERM,
	SCALE_RSCALE_NONE,
	SCALE_RSCALE_NONE,
};
};


@@ -1887,6 +1888,22 @@ int32_t qpnp_adc_qrd_skuh_btm_scaler(struct qpnp_vadc_chip *dev,
int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev,
int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev,
		struct qpnp_adc_tm_btm_param *param,
		struct qpnp_adc_tm_btm_param *param,
		uint32_t *low_threshold, uint32_t *high_threshold);
		uint32_t *low_threshold, uint32_t *high_threshold);
/**
 * qpnp_adc_qrd_215_btm_scaler() - Performs reverse calibration on the
 *		low/high temperature threshold values passed by the client.
 *		The function maps the temperature to voltage and applies
 *		ratiometric calibration on the voltage values for SKUT1 board.
 * @dev:	Structure device for qpnp vadc
 * @param:	The input parameters that contain the low/high temperature
 *		values.
 * @low_threshold: The low threshold value that needs to be updated with
 *		the above calibrated voltage value.
 * @high_threshold: The low threshold value that needs to be updated with
 *		the above calibrated voltage value.
 */
int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *dev,
		struct qpnp_adc_tm_btm_param *param,
		uint32_t *low_threshold, uint32_t *high_threshold);
/**
/**
 * qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration
 * qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration
 *		and convert given temperature to voltage on supported
 *		and convert given temperature to voltage on supported
@@ -2279,6 +2296,10 @@ static inline int32_t qpnp_adc_qrd_skut1_btm_scaler(struct qpnp_vadc_chip *dev,
		struct qpnp_adc_tm_btm_param *param,
		struct qpnp_adc_tm_btm_param *param,
		uint32_t *low_threshold, uint32_t *high_threshold)
		uint32_t *low_threshold, uint32_t *high_threshold)
{ return -ENXIO; }
{ return -ENXIO; }
static inline int32_t qpnp_adc_qrd_215_btm_scaler(struct qpnp_vadc_chip *dev,
		struct qpnp_adc_tm_btm_param *param,
		uint32_t *low_threshold, uint32_t *high_threshold)
{ return -ENXIO; }
static inline int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr(
static inline int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr(
		struct qpnp_vadc_chip *dev,
		struct qpnp_vadc_chip *dev,
		struct qpnp_adc_tm_btm_param *param,
		struct qpnp_adc_tm_btm_param *param,