diff options
author | Philip Chen <philipchen@google.com> | 2018-06-29 18:23:37 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-02 21:50:23 -0700 |
commit | 535c4d4a6a0e1c669ddee3c81b45faa22ac27196 (patch) | |
tree | 07ff04aed8a27784032b5706121cc0ec3c661127 /common/charge_state_v2.c | |
parent | cbcf963069165059b1b61a2268a3dbd9cdffd872 (diff) | |
download | chrome-ec-535c4d4a6a0e1c669ddee3c81b45faa22ac27196.tar.gz |
scarlet: Cut off battery in a custom battery condition
We want to shut down AP when the battery charge drops below
BATTERY_LEVEL_SHUTDOWN. Then we want to cut off the battery
to protect the battery from over-discharging.
But we don't want to cut off the battery right after the battery charge
drops below BATTERY_LEVEL_SHUTDOWN so that we can retain the RTC timestamp
for functionality reasons.
So let's add a custom check before we move on to cut off the battery in
shutdown_on_critical_battery().
BUG=b:68723854
BRANCH=scarlet
TEST=make buildall -j
TEST=keep the battery discharging, see AP shut down when
battery charge hits 2% and later EC cut off battery when
battery voltage hits 3.2V
Change-Id: I9950cf32558c11a2f55ee6ca64c157146d449110
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1121593
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Trybot-Ready: Philip Chen <philipchen@chromium.org>
(cherry picked from commit 91171747b4ca01ac929186c96d4d6aa3489c60ab)
Reviewed-on: https://chromium-review.googlesource.com/1140795
Commit-Ready: Philip Chen <philipchen@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r-- | common/charge_state_v2.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 8102029c21..5a088d9783 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1277,11 +1277,13 @@ static inline int battery_too_low(void) curr.batt.voltage <= batt_info->voltage_min)); } - -/* - * Send host event to the AP if the battery is temperature or charge level - * is critical. Force-shutdown if the problem isn't corrected after timeout. - */ + /* + * If the battery is at extremely low charge (and discharging) or extremely + * high temperature, the EC will notify the AP and start a timer. If the + * critical condition is not corrected before the timeout expires, the EC + * will shut down the AP (if the AP is not already off) and then optionally + * hibernate or cut off battery. + */ static int shutdown_on_critical_battery(void) { int batt_temp_c; @@ -1321,6 +1323,10 @@ static int shutdown_on_critical_battery(void) if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) { /* Timeout waiting for charger to provide more power */ #if defined(CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF) +#ifdef CONFIG_BATTERY_CRITICAL_CUT_OFF_CUSTOM_CONDITION + if (!board_critical_shutdown_check(&curr)) + return battery_critical; +#endif /* CONFIG_BATTERY_CRITICAL_CUT_OFF_CUSTOM_CONDITION */ CPRINTS( "charge force battery cut-off due to critical level"); board_cut_off_battery(); |