diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2021-07-23 07:37:06 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-09 22:01:36 +0000 |
commit | 8bbea20178969365302f364527e7949a0cb04197 (patch) | |
tree | d31bf4b2196e27a711fd593179a458c51048544a /common | |
parent | 677220270d3c9973817e5507bdacadc35a24dcae (diff) | |
download | chrome-ec-8bbea20178969365302f364527e7949a0cb04197.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>
Diffstat (limited to 'common')
-rw-r--r-- | common/charge_state_v2.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index f293c61175..77c5e18125 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1729,22 +1729,28 @@ static void sustain_battery_soc(void) soc = charge_get_display_charge() / 10; + /* + * 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. + */ switch (mode) { 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; |