From 7ad29b56aeaa26ff2461257bdc070e9277a41782 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Thu, 29 Jan 2015 11:29:37 -0800 Subject: charge_state_v2: ignore false battery SOC readings Ignore battery readings over 100%. This fixes a samus bug where a false battery SOC reading causes charging to stop. BUG=chrome-os-partner:36115, chrome-os-partner:36081 BRANCH=samus TEST=add following code to common/smart.c: static int reset_soc; in battery_get_params(): if (reset_soc) { batt_new.state_of_charge = 65535; reset_soc = 0; } after battery_get_params(): static int command_battsoc(int argc, char **argv) { reset_soc = 1; return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(battsoc, command_battsoc, "", "", NULL); This changes the battery state of charge to 65535% for one loop through charge state machine. w/o this CL, on samus the battery stops charging when you call this, but with this CL it is fixed. Change-Id: I44f054a4e84260bd7cd7b77e44b1698645ab6c35 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/244346 Reviewed-by: Shawn N --- common/charge_state_v2.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 0f48d2482f..5e3df653c6 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -611,6 +611,13 @@ void charger_task(void) curr.batt.flags |= BATT_FLAG_BAD_TEMPERATURE; } + /* If the battery thinks it's above 100%, don't believe it */ + if (curr.batt.state_of_charge > 100) { + CPRINTS("ignoring ridiculous batt.soc of %d%%", + curr.batt.state_of_charge); + curr.batt.flags |= BATT_FLAG_BAD_STATE_OF_CHARGE; + } + /* * Now decide what we want to do about it. We'll normally just * pass along whatever the battery wants to the charger. Note @@ -739,15 +746,6 @@ void charger_task(void) curr.state = ST_CHARGE; } - /* - * If battery seems to be disconnected, we need to get it - * 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) - /* Full up. Stop charging */ - curr.state = ST_IDLE; - /* * TODO(crosbug.com/p/27643): Quit trying if charging too long * without getting full (CONFIG_CHARGER_TIMEOUT_HOURS). -- cgit v1.2.1