summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2023-04-24 13:33:37 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-25 15:23:27 +0000
commit58d8fc6c170c69beb3d081d9e1f5bafb3dffe83d (patch)
treeb5d3f61ac664ad1763525e4ffea15aa775a7c5c8
parent002af21a2bf462d5396ed0e552af08d47b9a5516 (diff)
downloadchrome-ec-58d8fc6c170c69beb3d081d9e1f5bafb3dffe83d.tar.gz
Charge_state_v2: Always evaluate battery disconnect
Always evaluate the battery disconnect state when we know the battery is physically present. Otherwise, we may miss the battery coming out of disconnect if AC is removed around the same time the battery becomes responsive. This causes us to remain in safe state with an active charge port offering 0mV/0mA. Note this change adjusts the criteria for battery disconnect, counting errors in assessing the battery disconnect state as disconnects. This should account for the fact that the check now runs before we've verified battery communication is okay. BRANCH=skyrim BUG=b:276837557 TEST=on frostflow, ensure units don't show charging when AC is removed after coming out of ship mode Change-Id: Ie52c993005cf389dc2912c6ab9492483b60239a9 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4470067 Tested-by: SamSP Liu <samsp_liu2@compal.corp-partner.google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/charge_state_v2.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 59657318f5..e103f991ba 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1809,6 +1809,17 @@ void charger_task(void *u)
}
/*
+ * Always check the disconnect state if the battery is present.
+ * This is because the battery disconnect state is one of the
+ * items used to decide whether or not to leave safe mode.
+ *
+ * Note: For our purposes, an unresponsive battery is
+ * considered to be disconnected
+ */
+ battery_seems_disconnected = battery_get_disconnect_state() !=
+ BATTERY_NOT_DISCONNECTED;
+
+ /*
* If we had trouble talking to the battery or the charger, we
* should probably do nothing for a bit, and if it doesn't get
* better then flag it as an error.
@@ -1868,14 +1879,6 @@ void charger_task(void *u)
}
/* The battery is responding. Yay. Try to use it. */
- /*
- * Always check the disconnect state. This is because
- * the battery disconnect state is one of the items used
- * to decide whether or not to leave safe mode.
- */
- battery_seems_disconnected = battery_get_disconnect_state() ==
- BATTERY_DISCONNECTED;
-
revive_battery(&need_static);
set_charge_state(ST_CHARGE);