summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-02-25 12:56:40 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-06 06:51:30 -0800
commitdcd378e1cde499fe3c33efd98bd7e737b034ff77 (patch)
tree8f8f022e28de1986e604faae0440d49ca5e7f5c9 /common
parentf2ea9714253427c81f9d154d0502d0d10124a8d2 (diff)
downloadchrome-ec-dcd378e1cde499fe3c33efd98bd7e737b034ff77.tar.gz
chgstv2: Make board_critical_shutdown_check specify action on critical soc
Currently, board_critical_shutdown_check is used only in the context of CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF. It returns true to cutoff the battery or false to take no action. This patch extends board_critical_shutdown_check to allow it to control what actions to take on critical battery condition. With this change, each board can also customize critical battery actions with more granularity (per OEM, BOARD_VERSION, etc.). Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/123727148 BRANCH=nami TEST=Verify a battery is cutoff at critical low charge on Scarlet and DUT wakes up by AC plugin on cros/firmware-scarlet-10388.B. Change-Id: Id49e860b05e21c3bfa4d75f27c48b55c2a3ad95f Reviewed-on: https://chromium-review.googlesource.com/1487113 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/charge_state_v2.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index bd4bb81558..b07e82022e 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1284,6 +1284,19 @@ static inline int battery_too_low(void)
curr.batt.voltage <= batt_info->voltage_min));
}
+__attribute__((weak))
+enum critical_shutdown board_critical_shutdown_check(
+ struct charge_state_data *curr)
+{
+#ifdef CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
+ return CRITICAL_SHUTDOWN_CUTOFF;
+#elif defined(CONFIG_HIBERNATE)
+ return CRITICAL_SHUTDOWN_HIBERNATE;
+#else
+ return CRITICAL_SHUTDOWN_IGNORE;
+#endif
+}
+
/*
* 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
@@ -1329,19 +1342,19 @@ static int shutdown_on_critical_battery(void)
CRITICAL_BATTERY_SHUTDOWN_TIMEOUT_US) {
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();
-#elif defined(CONFIG_HIBERNATE)
- CPRINTS(
- "charge force EC hibernate due to critical battery");
- system_hibernate(0, 0);
-#endif
+ switch (board_critical_shutdown_check(&curr)) {
+ case CRITICAL_SHUTDOWN_HIBERNATE:
+ CPRINTS("Hibernate due to critical battery");
+ system_hibernate(0, 0);
+ break;
+ case CRITICAL_SHUTDOWN_CUTOFF:
+ CPRINTS("Cutoff due to critical battery");
+ board_cut_off_battery();
+ break;
+ case CRITICAL_SHUTDOWN_IGNORE:
+ default:
+ break;
+ }
} else {
/* Timeout waiting for AP to shut down, so kill it */
CPRINTS(