iio: rradc: Update RRADC USBIN scaling

To improve accuracy update RRADC USBIN current
scaling factor for V/A from 0.5 to 0.53.

Change-Id: Ia13bd8702f337f71dae5d612f6efe55ee8c2a317
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
This commit is contained in:
Siddartha Mohanadoss 2016-11-11 14:25:56 -08:00
parent 4a91ea36cb
commit f0bcb723f9

View file

@ -165,7 +165,8 @@
#define FG_ADC_RR_CHG_THRESHOLD_SCALE 4
#define FG_ADC_RR_VOLT_INPUT_FACTOR 8
#define FG_ADC_RR_CURR_INPUT_FACTOR 2
#define FG_ADC_RR_CURR_INPUT_FACTOR 2000
#define FG_ADC_RR_CURR_USBIN_INPUT_FACTOR_MIL 1886
#define FG_ADC_SCALE_MILLI_FACTOR 1000
#define FG_ADC_KELVINMIL_CELSIUSMIL 273150
@ -323,12 +324,20 @@ static int rradc_post_process_curr(struct rradc_chip *chip,
struct rradc_chan_prop *prop, u16 adc_code,
int *result_ua)
{
int64_t ua = 0;
int64_t ua = 0, scale = 0;
/* 0.5 V/A; 2.5V ADC full scale */
ua = ((int64_t)adc_code * FG_ADC_RR_CURR_INPUT_FACTOR);
if (!prop)
return -EINVAL;
if (prop->channel == RR_ADC_USBIN_I)
scale = FG_ADC_RR_CURR_USBIN_INPUT_FACTOR_MIL;
else
scale = FG_ADC_RR_CURR_INPUT_FACTOR;
/* scale * V/A; 2.5V ADC full scale */
ua = ((int64_t)adc_code * scale);
ua *= (FG_ADC_RR_FS_VOLTAGE_MV * FG_ADC_SCALE_MILLI_FACTOR);
ua = div64_s64(ua, FG_MAX_ADC_READINGS);
ua = div64_s64(ua, (FG_MAX_ADC_READINGS * 1000));
*result_ua = ua;
return 0;