mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 11:37:06 +02:00
iio: adc: Correct smb1398 scaling function
Correct scaling function for SMB1398 to ensure temperature is calculated accurately. Change-Id: I7ec497ef9d1171da7a08a97730912727c583830a Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org> [quic_collinsd@quicinc.com: changed prescale "num" and "den" to "numerator" and "denominator" respectively] Signed-off-by: David Collins <quic_collinsd@quicinc.com>
This commit is contained in:
parent
2b64262524
commit
81fe95c85f
|
|
@ -929,9 +929,26 @@ static int qcom_vadc_scale_hw_smb1398_temp(
|
|||
const struct adc5_data *data,
|
||||
u16 adc_code, int *result_mdec)
|
||||
{
|
||||
*result_mdec = qcom_vadc_scale_code_voltage_factor(adc_code * 100,
|
||||
prescale, data, PMIC5_SMB1398_TEMP_SCALE_FACTOR);
|
||||
*result_mdec = PMIC5_SMB1398_TEMP_CONSTANT - *result_mdec;
|
||||
s64 voltage = 0, adc_vdd_ref_mv = 1875;
|
||||
u64 temp;
|
||||
|
||||
if (adc_code > VADC5_MAX_CODE)
|
||||
adc_code = 0;
|
||||
|
||||
/* (ADC code * vref_vadc (1.875V)) / full_scale_code */
|
||||
voltage = (s64) adc_code * adc_vdd_ref_mv * 1000;
|
||||
voltage = div64_s64(voltage, data->full_scale_code_volt);
|
||||
if (voltage > 0) {
|
||||
temp = voltage * prescale->denominator;
|
||||
temp *= 100;
|
||||
do_div(temp, prescale->numerator * PMIC5_SMB1398_TEMP_SCALE_FACTOR);
|
||||
voltage = temp;
|
||||
} else {
|
||||
voltage = 0;
|
||||
}
|
||||
|
||||
voltage = voltage - PMIC5_SMB1398_TEMP_CONSTANT;
|
||||
*result_mdec = voltage;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user