common/charge_state: Cut off battery if board selects CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF

If board selects both CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF and
CONFIG_HIBERNATE, then CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF should
be given higher preference when deciding what action to take in case
of critical battery.

This is necessary on boards where components like H1 chip could be
consuming more power than is healthy when the battery is already
critically low, depleting it to dangeriously low voltage levels faster
than it should.

(Reference: https://chromium-review.googlesource.com/582543)

BUG=b:64460667
BRANCH=None
TEST=Manual testing to ensure that EC cuts off battery when it is
critically low instead of hibernating on soraka.

Change-Id: I6efacd7206199ca19f1073296b113b6cf18ec655
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/605014
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
This commit is contained in:
Furquan Shaikh
2017-08-07 13:18:35 -07:00
committed by chrome-bot
parent 25918cd9ba
commit 04ef7b0a84

View File

@@ -539,15 +539,15 @@ static void shutdown_on_critical_battery(void)
} else if (get_time().val > shutdown_warning_time.val +
CRITICAL_BATTERY_SHUTDOWN_TIMEOUT_US) {
if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
#ifdef CONFIG_HIBERNATE
/* Timeout waiting for charger to provide more power */
CPRINTS(
"charge force EC hibernate due to critical battery");
system_hibernate(0, 0);
#elif defined(CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF)
#if defined(CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF)
CPRINTS(
"charge force battery cut-off due to critical level");
board_cut_off_battery();
#elif defined(CONFIG_HIBERNATE)
CPRINTS(
"charge force EC hibernate due to critical battery");
system_hibernate(0, 0);
#endif
} else {
/* Timeout waiting for AP to shut down, so kill it */