]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00215718: battery: fix issure that coulomb data increases in discharger
authorRong Dian <b38775@freescale.com>
Wed, 4 Jul 2012 04:51:17 +0000 (12:51 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:34:57 +0000 (08:34 +0200)
Hardware cannot support battery internal resistance and coulomb calculation,
estimate data only by battery voltage.The true battery voltage will change to
a bit lower about 50mV~500mV than normal voltage with playing game or video or
other consumption actions, then change back to normal voltage with finishing
playing game or video or other consumption actions in the discharger stage.

Signed-off-by: Rong Dian <b38775@freescale.com>
drivers/power/sabresd_battery.c

index df9f62cdeb5dbfcae99b7eba1e3c5b5161159fe6..460da4a43b721a658fd574c22cdcc115c78254c1 100755 (executable)
@@ -249,8 +249,26 @@ u32 calibration_voltage(struct max8903_data *data)
 static void max8903_battery_update_status(struct max8903_data *data)
 {
        static int counter;
+       int temp;
+       static int temp_last;
        mutex_lock(&data->work_lock);
-       data->voltage_uV = calibration_voltage(data);
+       temp = calibration_voltage(data);
+       if (temp_last == 0) {
+               data->voltage_uV = temp;
+               temp_last = temp;
+       }
+       if (data->charger_online == 0 && temp_last != 0) {
+               if (temp < temp_last) {
+               temp_last = temp;
+               data->voltage_uV = temp;
+               } else {
+               data->voltage_uV = temp_last;
+               }
+       }
+       if (data->charger_online == 1) {
+               data->voltage_uV = temp;
+               temp_last = temp;
+       }
        data->percent = calibrate_battery_capability_percent(data);
        if (data->percent != data->old_percent) {
                data->old_percent = data->percent;