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 17:31:16 +0000
commite3148d18d9b36237d820e8f12f45bf751dc0b351 (patch)
treecbb6f8ee5a4efa5d5ce2290d5db9561d2c04df73
parent592ef3fc7b49a0bca9e9d59c5372571b3fe25c47 (diff)
downloadchrome-ec-e3148d18d9b36237d820e8f12f45bf751dc0b351.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> (cherry picked from commit 58d8fc6c170c69beb3d081d9e1f5bafb3dffe83d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4472392 Tested-by: Chao Gui <chaogui@google.com> Reviewed-by: Chao Gui <chaogui@google.com> Commit-Queue: Chao Gui <chaogui@google.com>
-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);