summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-07-23 07:37:06 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-09 02:22:41 +0000
commit250f9daa4dc1a8e8ae3cb0e9896decf35eee551b (patch)
treee64dec170281011467fc5d0dcf31c8ea0676d0f9
parentd729a3153b19a4b34e5b7d9afb53a8e421f5a8df (diff)
downloadchrome-ec-250f9daa4dc1a8e8ae3cb0e9896decf35eee551b.tar.gz
chgstv2/sustainer: Stop AC current when discharging
Currently, the battery sustainer discharges the battery using CHARGE_CONTROL_IDLE, which uses the AC current and stops the current from the battery. With this change, when lower < upper, the sustainer discharges using DISCHARGE. When lower == upper, the sustainer discharges using IDLE. BUG=b:188457962 BRANCH=None TEST=run-sbs_charging_v2 Change-Id: I4af31eff488bc9cfa627f84994b685488c3c9061 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3049290 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Derek Basehore <dbasehore@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3631844 Tested-by: wen zhang <zhangwen6@huaqin.corp-partner.google.com> Reviewed-by: Mike Lee <mike5@huaqin.corp-partner.google.com> Commit-Queue: wen zhang <zhangwen6@huaqin.corp-partner.google.com>
-rw-r--r--common/charge_state_v2.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 4b7c5411d2..832e599678 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1568,21 +1568,27 @@ static void sustain_battery_soc(void)
soc = charge_get_percent();
switch (chg_ctl_mode) {
+ /*
+ * When lower < upper, the sustainer discharges using DISCHARGE. When
+ * lower == upper, the sustainer discharges using IDLE. The following
+ * switch statement handle both cases but in reality either DISCHARGE
+ * or IDLE is used but not both.
+ */
case CHARGE_CONTROL_NORMAL:
/* Going up */
if (sustain_soc.upper < soc)
- mode = CHARGE_CONTROL_DISCHARGE;
+ mode = sustain_soc.upper == sustain_soc.lower ?
+ CHARGE_CONTROL_IDLE : CHARGE_CONTROL_DISCHARGE;
break;
case CHARGE_CONTROL_IDLE:
- /* discharging naturally */
+ /* Discharging naturally */
if (soc < sustain_soc.lower)
- /* TODO: Charge slowly */
mode = CHARGE_CONTROL_NORMAL;
break;
case CHARGE_CONTROL_DISCHARGE:
- /* discharging rapidly (discharge_on_ac) */
- if (soc < sustain_soc.upper)
- mode = CHARGE_CONTROL_IDLE;
+ /* Discharging actively. */
+ if (soc < sustain_soc.lower)
+ mode = CHARGE_CONTROL_NORMAL;
break;
default:
return;