summaryrefslogtreecommitdiff
path: root/common/charge_state_v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/charge_state_v2.c')
-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(