From 6fb8ab3369f454e51fa2ef6bcbf14dc0a9919912 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Sat, 24 Jan 2015 14:38:11 -0800 Subject: samus: modify fast charging profile to avoid charge problems Several modifications to samus fast charging to fix bug where charging circuit stops charging the battery. - Fix bug: if we have a bad temperature reading, fast charging should ignore it. - Change the fast charging high temperature profile to set a charging voltage equal to the maximum of 8.3V and the current battery voltage. - Divide the normal temperature profile into two phases, low voltage charging and high voltage charging. Once we transition to second phase, don't allow it to go back to phase 1 unless AC is removed. On samus, we have to make sure we never command the BQ to a charging voltage that is below the present battery voltage or else the INA will lose power and we will not be able to charge the battery until AC is disconnected. This also changes charge_state_v2 so that the fast charging profile override is called even when AC is disconnected to avoid jumps in temperature as seen by the fast charging code. Also changes the voltage threshold for transitioning from phase 1 to phase 2 of normal temp charging so that the transition is taken a little earlier to match the desired profile slightly better. BUG=chrome-os-partner:35491 BRANCH=samus TEST=Added custom console command to be able to directly control the battery temperature that charger_profile_override() uses: static int command_chgtemp(int argc, char **argv) { char *e; if (argc < 2) return EC_ERROR_PARAM_COUNT; chg_temp = strtoi(argv[1], &e, 10); if (*e) return EC_ERROR_PARAM1; return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(chgtemp, command_chgtemp, "", "", NULL); Using this command, I jumped back and forth between all three temperature fast charging regions and made sure that (1) we never set a charging voltage below the present battery voltage and (2) we never stop charging the battery. I ran this test at low battery and high battery percentage and with low load (G3) and high load (S0 with webgl aquarium). Change-Id: I035603a4ab48a156ab43f8c93f21200c4b664aab Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/243143 Reviewed-by: Duncan Laurie --- common/charge_state_v2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'common/charge_state_v2.c') diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 894faed8b6..0f48d2482f 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -744,24 +744,22 @@ void charger_task(void) * out of that state, even if the charge level is full. */ if (curr.batt.state_of_charge >= BATTERY_LEVEL_FULL && - !battery_seems_to_be_disconnected) { + !battery_seems_to_be_disconnected) /* Full up. Stop charging */ curr.state = ST_IDLE; - goto wait_for_it; - } /* * TODO(crosbug.com/p/27643): Quit trying if charging too long * without getting full (CONFIG_CHARGER_TIMEOUT_HOURS). */ +wait_for_it: #ifdef CONFIG_CHARGER_PROFILE_OVERRIDE sleep_usec = charger_profile_override(&curr); if (sleep_usec < 0) problem(PR_CUSTOM, sleep_usec); #endif -wait_for_it: /* Keep the AP informed */ if (need_static) need_static = update_static_battery_info(); -- cgit v1.2.1