summaryrefslogtreecommitdiff
path: root/common/charge_state_v1.c
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2014-12-16 09:54:54 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-17 18:07:10 +0000
commita7bae3588cb976405b90677a324de06c71fa3f48 (patch)
treef758c61f021485acee7ee82e4ebfa51f3b0300a9 /common/charge_state_v1.c
parent6c980a4dbf2e37b83e868c0eb12774190ea8c94d (diff)
downloadchrome-ec-a7bae3588cb976405b90677a324de06c71fa3f48.tar.gz
power_button_x86: Inhibit AP power-on if battery level is too low
Allow CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON to be defined at the board level to be the minimum battery percentage required for power-on. If the battery level is below the threshold, or if the battery is missing, power button presses will be ignored. BUG=chrome-os-partner:31127 TEST=Manual on Samus with subsequent commit. Verify that AP continues to boot normally when charge level exceeds CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON. Verify that power button presses are ignored when the charge level is below the threshold, and we return to G3. BRANCH=Samus Change-Id: I0ff3f7ddabf38080332470e172c8b2e307bf1655 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/236021 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/charge_state_v1.c')
-rw-r--r--common/charge_state_v1.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/common/charge_state_v1.c b/common/charge_state_v1.c
index b4ecb74c5b..9be0d47c15 100644
--- a/common/charge_state_v1.c
+++ b/common/charge_state_v1.c
@@ -681,6 +681,19 @@ int charge_want_shutdown(void)
charge_get_percent() < BATTERY_LEVEL_SHUTDOWN;
}
+int charge_prevent_power_on(void)
+{
+ int prevent_power_on = 0;
+#ifdef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
+ /* Require a minimum battery level to power on */
+ if (battery_is_present() == BP_NO ||
+ charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
+ prevent_power_on = 1;
+#endif
+ /* Factory override: Always allow power on if WP is disabled */
+ return prevent_power_on && system_is_locked();
+}
+
static int charge_force_idle(int enable)
{
if (enable) {