From ca24524c8ee97172387cbc091150e1db7dce85cf Mon Sep 17 00:00:00 2001 From: Ramakrishna Pallala Date: Tue, 22 May 2012 19:46:12 +0530 Subject: [PATCH] MFLD/Battery: fix battery full logic for transition b/w temperature zones BZ: 37894 This patch fixes the battery full detection logic in case of temperature transition b/w battery charge profle. Change-Id: Iff9651b3fa5f35b45a8cec53b0661e69ef3e102f Signed-off-by: Ramakrishna Pallala Reviewed-on: http://android.intel.com:8080/49753 Reviewed-by: Tc, Jenny Tested-by: Kallappa Manjanna, MadhukumarX Reviewed-by: Koskinen, Ilkka Reviewed-by: buildbot Tested-by: buildbot --- drivers/power/intel_mdf_battery.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/power/intel_mdf_battery.c b/drivers/power/intel_mdf_battery.c index 180b28c..d457de0 100644 --- a/drivers/power/intel_mdf_battery.c +++ b/drivers/power/intel_mdf_battery.c @@ -1437,7 +1437,16 @@ static int check_charge_full(struct msic_power_module_info *mbi, /* convert to milli amps */ cur_avg /= 1000; - if ((volt_now > (vref - VBATT_FULL_DET_MARGIN)) && + /* + * charge full is detected (1)when Vbatt > Vfull and could + * be discharging, this can happen when temperature zone + * transition happens. (2) when Vbatt is close to Vfull and + * the charge current is with in the termination range. + */ + if ((volt_now > vref) && (volt_prev > vref) && + (cur_avg <= FULL_CURRENT_AVG_HIGH)) { + is_full = true; + } else if ((volt_now > (vref - VBATT_FULL_DET_MARGIN)) && (volt_prev > (vref - VBATT_FULL_DET_MARGIN))) { if (cur_avg >= FULL_CURRENT_AVG_LOW && cur_avg <= FULL_CURRENT_AVG_HIGH) -- 2.7.4