summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/power/supply/sc27xx_fuel_gauge.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c
index db7d07d5dae9..6a29f00aec48 100644
--- a/drivers/power/supply/sc27xx_fuel_gauge.c
+++ b/drivers/power/supply/sc27xx_fuel_gauge.c
@@ -326,8 +326,6 @@ static int sc27xx_fgu_set_clbcnt(struct sc27xx_fgu_data *data, int clbcnt)
326{ 326{
327 int ret; 327 int ret;
328 328
329 clbcnt *= SC27XX_FGU_SAMPLE_HZ;
330
331 ret = regmap_update_bits(data->regmap, 329 ret = regmap_update_bits(data->regmap,
332 data->base + SC27XX_FGU_CLBCNT_SETL, 330 data->base + SC27XX_FGU_CLBCNT_SETL,
333 SC27XX_FGU_CLBCNT_MASK, clbcnt); 331 SC27XX_FGU_CLBCNT_MASK, clbcnt);
@@ -362,7 +360,6 @@ static int sc27xx_fgu_get_clbcnt(struct sc27xx_fgu_data *data, int *clb_cnt)
362 360
363 *clb_cnt = ccl & SC27XX_FGU_CLBCNT_MASK; 361 *clb_cnt = ccl & SC27XX_FGU_CLBCNT_MASK;
364 *clb_cnt |= (cch & SC27XX_FGU_CLBCNT_MASK) << SC27XX_FGU_CLBCNT_SHIFT; 362 *clb_cnt |= (cch & SC27XX_FGU_CLBCNT_MASK) << SC27XX_FGU_CLBCNT_SHIFT;
365 *clb_cnt /= SC27XX_FGU_SAMPLE_HZ;
366 363
367 return 0; 364 return 0;
368} 365}
@@ -380,10 +377,10 @@ static int sc27xx_fgu_get_capacity(struct sc27xx_fgu_data *data, int *cap)
380 377
381 /* 378 /*
382 * Convert coulomb counter to delta capacity (mAh), and set multiplier 379 * Convert coulomb counter to delta capacity (mAh), and set multiplier
383 * as 100 to improve the precision. 380 * as 10 to improve the precision.
384 */ 381 */
385 temp = DIV_ROUND_CLOSEST(delta_clbcnt, 360); 382 temp = DIV_ROUND_CLOSEST(delta_clbcnt * 10, 36 * SC27XX_FGU_SAMPLE_HZ);
386 temp = sc27xx_fgu_adc_to_current(data, temp); 383 temp = sc27xx_fgu_adc_to_current(data, temp / 1000);
387 384
388 /* 385 /*
389 * Convert to capacity percent of the battery total capacity, 386 * Convert to capacity percent of the battery total capacity,
@@ -790,7 +787,7 @@ static int sc27xx_fgu_cap_to_clbcnt(struct sc27xx_fgu_data *data, int capacity)
790 * Convert current capacity (mAh) to coulomb counter according to the 787 * Convert current capacity (mAh) to coulomb counter according to the
791 * formula: 1 mAh =3.6 coulomb. 788 * formula: 1 mAh =3.6 coulomb.
792 */ 789 */
793 return DIV_ROUND_CLOSEST(cur_cap * 36 * data->cur_1000ma_adc, 10); 790 return DIV_ROUND_CLOSEST(cur_cap * 36 * data->cur_1000ma_adc * SC27XX_FGU_SAMPLE_HZ, 10);
794} 791}
795 792
796static int sc27xx_fgu_calibration(struct sc27xx_fgu_data *data) 793static int sc27xx_fgu_calibration(struct sc27xx_fgu_data *data)