From 0a2807572ef406610cb90c3de422dea8b9a6955c Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Tue, 16 Dec 2014 10:17:06 -0800 Subject: samus: Don't power-on AP if battery level < 1% This will also inhibit power-on if no battery is attached. BUG=chrome-os-partner:31127 TEST=Manual on Samus. 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. Also, verify that Samus can boot successfully to the OS with 1% battery and a 5V @ 500mA charger attached. BRANCH=Samus Change-Id: I47cd3903c8cc13282fd5038f9d5fd1e310283ea7 Signed-off-by: Shawn Nematbakhsh Reviewed-on: https://chromium-review.googlesource.com/236022 Reviewed-by: Alec Berg --- board/samus/board.h | 1 + board/samus/power_sequence.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/board/samus/board.h b/board/samus/board.h index fad50ec80d..fbc1327a23 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -48,6 +48,7 @@ #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 #define CONFIG_CHARGER_INPUT_CURRENT 448 #define CONFIG_CHARGER_DISCHARGE_ON_AC +#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 #define CONFIG_FANS 2 #define CONFIG_GESTURE_DETECTION #define CONFIG_GESTURE_SAMPLING_INTERVAL_MS 5 diff --git a/board/samus/power_sequence.c b/board/samus/power_sequence.c index e034c69f71..c999c98180 100644 --- a/board/samus/power_sequence.c +++ b/board/samus/power_sequence.c @@ -6,6 +6,7 @@ /* X86 chipset power control module for Chrome EC */ #include "battery.h" +#include "charge_state.h" #include "chipset.h" #include "common.h" #include "console.h" @@ -196,6 +197,13 @@ enum power_state power_handle_state(enum power_state state) case POWER_S5: while ((power_get_signals() & IN_PCH_SLP_S5_DEASSERTED) == 0) { + /* Return to G3 if battery level is too low */ + if (charge_want_shutdown() || + charge_prevent_power_on()) { + CPRINTS("power-up inhibited"); + return POWER_S5G3; + } + if (task_wait_event(SECOND*4) == TASK_EVENT_TIMER) { CPRINTS("timeout waiting for S5 exit"); /* Put system in G3 and assert RTCRST# */ -- cgit v1.2.1