summaryrefslogtreecommitdiff
path: root/include/charge_state.h
diff options
context:
space:
mode:
authorIvan Chen <yulunchen@google.com>2022-09-01 17:55:15 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-19 09:43:58 +0000
commit2fbeb3eec6ebbb4eecc1cf92982998b811c758e6 (patch)
treed8c61b428be0acc613b0ff3c9ac31a173c669257 /include/charge_state.h
parentd8c655abeb90fecc68b24a542dca6313ac3df777 (diff)
downloadchrome-ec-2fbeb3eec6ebbb4eecc1cf92982998b811c758e6.tar.gz
Battery: align OS low battery shutdown behavior
Deprecate BATTERY_LEVEL_CRITICAL in battery logic and use CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE instead to align OS low battery shutdown behavior, and centralize the low battery threshold decision. LOW_COVERAGE_REASON=CONFIG_OCPC is per-board definition. BRANCH=none BUG=b:244253629 TEST=Verify dedede shutdown from resume on low battery. Signed-off-by: Ivan Chen <yulunchen@google.com> Change-Id: Ibab3f87f213cc23c54fb5d7dc95aa6366c98e94e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3868875 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Shou-Chieh Hsu <shouchieh@chromium.org>
Diffstat (limited to 'include/charge_state.h')
-rw-r--r--include/charge_state.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/charge_state.h b/include/charge_state.h
index c2d2bce948..221947b9d1 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -7,6 +7,7 @@
#include "common.h"
#include "timer.h"
+#include "stdbool.h"
/* Stuff that's common to all charger implementations can go here. */
@@ -136,6 +137,27 @@ static inline int charge_want_shutdown(void)
#endif
/**
+ * Return true if battery level is below threshold, false otherwise,
+ * or if SoC can't be determined.
+ *
+ * @param transitioned True to check if SoC is previously above threshold
+ */
+enum batt_threshold_type {
+ BATT_THRESHOLD_TYPE_LOW = 0,
+ BATT_THRESHOLD_TYPE_SHUTDOWN
+};
+#if defined(CONFIG_CHARGER) && defined(CONFIG_BATTERY)
+int battery_is_below_threshold(enum batt_threshold_type type,
+ bool transitioned);
+#else
+static inline int battery_is_below_threshold(enum batt_threshold_type type,
+ bool transitioned)
+{
+ return 0;
+}
+#endif
+
+/**
* Return non-zero if the battery level is too low to allow power on, even if
* a charger is attached.
*