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

Commit 01d25e15 authored by Dipen Parmar's avatar Dipen Parmar
Browse files

hwmon: qpnp-adc-voltage: Avoid adc code check with recalibration



In VADC driver with recalibration parameter enabled and
MPP2 or MPP4 current sink configuration some ratiometric
channels report the adc code higher than maximum permitted
value.

VADC driver checks the adc code against the permitted
maximum value and overwrites adc code to permitted maximum
value if it is higher and this results into incorrect adc
readings.

Fix this problem by avoiding the adc code check when
recalibration parameter enabled.

Change-Id: Ic1bcc8b4e52cddc013cf1654c229c22fd348159e
Signed-off-by: default avatarDipen Parmar <dipenp@codeaurora.org>
parent e9f04b9a
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -1529,8 +1529,11 @@ int32_t qpnp_adc_smb_btm_rscaler(struct qpnp_vadc_chip *chip,
}
}
EXPORT_SYMBOL(qpnp_adc_smb_btm_rscaler);
EXPORT_SYMBOL(qpnp_adc_smb_btm_rscaler);


int32_t qpnp_vadc_check_result(int32_t *data)
int32_t qpnp_vadc_check_result(int32_t *data, bool recalib_check)
{
{
	if (recalib_check)
		return 0;

	if (*data < QPNP_VADC_MIN_ADC_CODE)
	if (*data < QPNP_VADC_MIN_ADC_CODE)
		*data = QPNP_VADC_MIN_ADC_CODE;
		*data = QPNP_VADC_MIN_ADC_CODE;
	else if (*data > QPNP_VADC_MAX_ADC_CODE)
	else if (*data > QPNP_VADC_MAX_ADC_CODE)
+2 −1
Original line number Original line Diff line number Diff line
@@ -459,7 +459,8 @@ static int32_t qpnp_vadc_read_conversion_result(struct qpnp_vadc_chip *vadc,


	*data = (rslt_msb << 8) | rslt_lsb;
	*data = (rslt_msb << 8) | rslt_lsb;


	status = qpnp_vadc_check_result(data);
	status = qpnp_vadc_check_result(data,
			(vadc->vadc_recalib_check ? true : false));
	if (status < 0) {
	if (status < 0) {
		pr_err("VADC data check failed\n");
		pr_err("VADC data check failed\n");
		goto fail;
		goto fail;
+2 −1
Original line number Original line Diff line number Diff line
@@ -1123,8 +1123,9 @@ int32_t qpnp_vadc_conv_seq_request(struct qpnp_vadc_chip *dev,
/**
/**
 * qpnp_vadc_check_result() - Performs check on the ADC raw code.
 * qpnp_vadc_check_result() - Performs check on the ADC raw code.
 * @data:	Data used for verifying the range of the ADC code.
 * @data:	Data used for verifying the range of the ADC code.
 * @recalib_check:	Recalibration check to ignore result check.
 */
 */
int32_t qpnp_vadc_check_result(int32_t *data);
int32_t qpnp_vadc_check_result(int32_t *data, bool recalib_check);


/**
/**
 * qpnp_adc_get_devicetree_data() - Abstracts the ADC devicetree data.
 * qpnp_adc_get_devicetree_data() - Abstracts the ADC devicetree data.