diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-03-28 15:27:27 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-28 23:23:48 -0700 |
commit | 14e70e301969b961f3f77ce1ded0971ce4fb9afb (patch) | |
tree | fffee936b71635a760854acc91567b4c57a4295d /common/charge_state_v2.c | |
parent | c00837e9a380fc4c3a0d05fc30fdb332686f28e2 (diff) | |
download | chrome-ec-14e70e301969b961f3f77ce1ded0971ce4fb9afb.tar.gz |
charge_state_v2: Use lid and base batteries to determine if near full
When reporting state, current code was only using the lid battery
level to determine if we are "near full" (different LED color).
Fix this to include both lid and base batteries in the logic.
BRANCH=none
BUG=b:75982704
TEST=Lid at 100%, base at 50%, LED is amber when charging.
Disconnect base => LED turns white (lid is near full)
Change-Id: I6fd44a16832cbd6d440f1bbb8c696e41c3f4699b
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/983202
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r-- | common/charge_state_v2.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index c62627ca5a..3c8a0d80a6 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1877,6 +1877,19 @@ int charge_prevent_power_on(int power_button_pressed) return prevent_power_on; } +static int battery_near_full(void) +{ + if (curr.batt.state_of_charge < BATTERY_LEVEL_NEAR_FULL) + return 0; + +#ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER + if (charge_base > -1 && charge_base < BATTERY_LEVEL_NEAR_FULL) + return 0; +#endif + + return 1; +} + enum charge_state charge_get_state(void) { switch (curr.state) { @@ -1886,14 +1899,14 @@ enum charge_state charge_get_state(void) return PWR_STATE_IDLE; case ST_DISCHARGE: #ifdef CONFIG_PWR_STATE_DISCHARGE_FULL - if (curr.batt.state_of_charge >= BATTERY_LEVEL_NEAR_FULL) + if (battery_near_full()) return PWR_STATE_DISCHARGE_FULL; else #endif return PWR_STATE_DISCHARGE; case ST_CHARGE: /* The only difference here is what the LEDs display. */ - if (curr.batt.state_of_charge >= BATTERY_LEVEL_NEAR_FULL) + if (battery_near_full()) return PWR_STATE_CHARGE_NEAR_FULL; else return PWR_STATE_CHARGE; |