mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-14 00:24:41 -04: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>
This commit is contained in:
parent
9eaefd9787
commit
b4ac30156e
1 changed files with 20 additions and 3 deletions
|
|
@ -909,9 +909,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->den;
|
||||
temp *= 100;
|
||||
do_div(temp, prescale->num * PMIC5_SMB1398_TEMP_SCALE_FACTOR);
|
||||
voltage = temp;
|
||||
} else {
|
||||
voltage = 0;
|
||||
}
|
||||
|
||||
voltage = voltage - PMIC5_SMB1398_TEMP_CONSTANT;
|
||||
*result_mdec = voltage;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue