power: pm8921-charger: increase hearbeat if battery is low
When the battery percent charge goes low we want to increase the
frequency of state of charge updates. This helps the correction
algorithm ample opportunities to correct the state of charge and
prevent a low voltage shutdown.
Change-Id: Ie846350ee4c1fd70198d28646779b20349134ef7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c
index bb996b7..4e15e77 100644
--- a/drivers/power/pm8921-charger.c
+++ b/drivers/power/pm8921-charger.c
@@ -271,6 +271,7 @@
enum pm8921_chg_led_src_config led_src_config;
bool host_mode;
u8 active_path;
+ int recent_reported_soc;
};
/* user space parameter to limit usb current */
@@ -1404,6 +1405,7 @@
if (percent_soc <= 10)
pr_warn("low battery charge = %d%%\n", percent_soc);
+ chip->recent_reported_soc = percent_soc;
return percent_soc;
}
@@ -2781,6 +2783,7 @@
* per update_time minutes
*
*/
+#define LOW_SOC_HEARTBEAT_MS 20000
static void update_heartbeat(struct work_struct *work)
{
struct delayed_work *dwork = to_delayed_work(work);
@@ -2789,7 +2792,12 @@
pm_chg_failed_clear(chip, 1);
power_supply_changed(&chip->batt_psy);
- schedule_delayed_work(&chip->update_heartbeat_work,
+ if (chip->recent_reported_soc <= 20)
+ schedule_delayed_work(&chip->update_heartbeat_work,
+ round_jiffies_relative(msecs_to_jiffies
+ (LOW_SOC_HEARTBEAT_MS)));
+ else
+ schedule_delayed_work(&chip->update_heartbeat_work,
round_jiffies_relative(msecs_to_jiffies
(chip->update_time)));
}