From fdac3804153be20399a7b0e026a378f3d5eb24f3 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Tue, 8 Aug 2017 10:55:37 -0700 Subject: [PATCH] poppy: Fix charger_profile_override When battery is cutoff, it might at times require some current to be applied to it so that it can wake up. Thus, in case where all battery flags indicate error in charger_profile_override, set requested_current and requested_voltage to precharge_current and voltage max. This allows the battery to be woken up. BUG=b:64370648,b:64460667 BRANCH=None TEST=Verified that on connecting AC power after battery-cutoff, there are no "try to wake battery" messages anymore. Change-Id: Ib88369238b492994d8310655126e19bc7e347a0c Signed-off-by: Furquan Shaikh Reviewed-on: https://chromium-review.googlesource.com/607034 Reviewed-by: Aaron Durbin Reviewed-by: Nicolas Boichat --- board/poppy/battery.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/board/poppy/battery.c b/board/poppy/battery.c index 6b6f1f5603..af172f52b9 100644 --- a/board/poppy/battery.c +++ b/board/poppy/battery.c @@ -126,10 +126,19 @@ enum battery_disconnect_state battery_get_disconnect_state(void) int charger_profile_override(struct charge_state_data *curr) { const struct battery_info *batt_info; - /* battery temp in 0.1 deg C */ - int bat_temp_c = curr->batt.temperature - 2731; + int bat_temp_c; batt_info = battery_get_info(); + + if ((curr->batt.flags & BATT_FLAG_BAD_ANY) == BATT_FLAG_BAD_ANY) { + curr->requested_current = batt_info->precharge_current; + curr->requested_voltage = batt_info->voltage_max; + return 1000; + } + + /* battery temp in 0.1 deg C */ + bat_temp_c = curr->batt.temperature - 2731; + /* Don't charge if outside of allowable temperature range */ if (bat_temp_c >= batt_info->charging_max_c * 10 || bat_temp_c < batt_info->charging_min_c * 10) {