From 01152db0c3263a7c5d7a7a068de77791dd5d9ec8 Mon Sep 17 00:00:00 2001 From: Jishnu Prakash Date: Tue, 4 Feb 2020 23:25:28 +0530 Subject: [PATCH] iio: adc: qcom-vadc-common: Change ADC7 die_temp output unit to mC Change ADC7 die_temp output unit from C to mC, as thermal framework expects temperatures to be reported in mC. Change-Id: Ie14b745f7db625f399ac5f79b3467a1654ea4a21 Signed-off-by: Jishnu Prakash --- drivers/iio/adc/qcom-vadc-common.c | 3 ++- drivers/iio/adc/qcom-vadc-common.h | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index 8ace02030a58..b960995daa96 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -581,7 +581,8 @@ static int qcom_vadc7_scale_hw_calib_die_temp( } else { vtemp0 = adcmap7_die_temp[i-1].x; voltage = voltage - vtemp0; - temp = voltage/(adcmap7_die_temp[i-1].y); + temp = div64_s64(voltage * DIE_TEMP_ADC7_SCALE_FACTOR, + adcmap7_die_temp[i-1].y); temp += DIE_TEMP_ADC7_SCALE_1 + (DIE_TEMP_ADC7_SCALE_2 * (i-1)); *result_mdec = temp; } diff --git a/drivers/iio/adc/qcom-vadc-common.h b/drivers/iio/adc/qcom-vadc-common.h index b50ae8748db2..a4d0fc739948 100644 --- a/drivers/iio/adc/qcom-vadc-common.h +++ b/drivers/iio/adc/qcom-vadc-common.h @@ -53,9 +53,10 @@ #define R_PU_100K 100000 #define RATIO_MAX_ADC7 0x4000 -#define DIE_TEMP_ADC7_SCALE_1 -60 -#define DIE_TEMP_ADC7_SCALE_2 20 -#define DIE_TEMP_ADC7_MAX 160 +#define DIE_TEMP_ADC7_SCALE_1 -60000 +#define DIE_TEMP_ADC7_SCALE_2 20000 +#define DIE_TEMP_ADC7_SCALE_FACTOR 1000 +#define DIE_TEMP_ADC7_MAX 160000 /** * struct vadc_map_pt - Map the graph representation for ADC channel