summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-11-03 09:25:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-11-28 17:56:29 -0800
commitc147530f1046743d15647faae404073855d77f18 (patch)
treebfa2aadc6344b7160f4954bb9bf830a5572a6261
parent4815373754754c7a4452a5081851d51042d50201 (diff)
downloadchrome-ec-c147530f1046743d15647faae404073855d77f18.tar.gz
intel_x86: Auto power-on after battery SOC is above minimum required
If power-up is inhibited by charger because of battery SOC, then check for the conditions again on BATTERY_SOC_CHANGE. This allows the EC to boot the AP up on connecting AC power and SOC going above the minimum required. BUG=b:65864825 BRANCH=None TEST=Verified following on coral and soraka: 1. Discharge battery to ~0% 2. Connect AC power ==> Power-up is inhibited 3. When battery SOC reaches 1%. AP is not taken out of reset: "[12.974428 Battery 1% / 8h:4 to full] [12.980439 power-up still inhibited]" 4. When battery SOC reaches 2%, AP is taken out of reset: "[9.230148 Battery 2% / 4h:5 to full] [9.236122 Battery SOC ok to boot AP!]" Change-Id: Ifa89f8929987d86c9e02530b663d563dbe25ed85 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/753294 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--power/intel_x86.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/power/intel_x86.c b/power/intel_x86.c
index c1962965b3..59b2d529aa 100644
--- a/power/intel_x86.c
+++ b/power/intel_x86.c
@@ -58,6 +58,42 @@ static const int sleep_sig[] = {
static int power_s5_up; /* Chipset is sequencing up or down */
+#ifdef CONFIG_CHARGER
+/* Flag to indicate if power up was inhibited due to low battery SOC level. */
+static int power_up_inhibited;
+
+/*
+ * Check if AP power up should be inhibited.
+ * 0 = Ok to boot up AP
+ * 1 = AP power up is inhibited.
+ */
+static int is_power_up_inhibited(void)
+{
+ /* Defaulting to power button not pressed. */
+ const int power_button_pressed = 0;
+
+ return charge_prevent_power_on(power_button_pressed) ||
+ charge_want_shutdown();
+}
+
+static void power_up_inhibited_cb(void)
+{
+ if (!power_up_inhibited)
+ return;
+
+ if (is_power_up_inhibited()) {
+ CPRINTS("power-up still inhibited");
+ return;
+ }
+
+ CPRINTS("Battery SOC ok to boot AP!");
+ power_up_inhibited = 0;
+
+ chipset_exit_hard_off();
+}
+DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, power_up_inhibited_cb, HOOK_PRIO_DEFAULT);
+#endif
+
/* Get system sleep state through GPIOs or VWs */
static inline int chipset_get_sleep_signal(enum sys_sleep_state state)
{
@@ -275,22 +311,30 @@ enum power_state common_intel_x86_power_handle_state(enum power_state state)
#ifdef CONFIG_CHARGER
{
int tries = 0;
+
/*
* Allow charger to be initialized for upto defined tries,
* in case we're trying to boot the AP with no battery.
*/
- while (charge_prevent_power_on(0) &&
- tries++ < CHARGER_INITIALIZED_TRIES) {
+ while ((tries < CHARGER_INITIALIZED_TRIES) &&
+ is_power_up_inhibited()) {
msleep(CHARGER_INITIALIZED_DELAY_MS);
+ tries++;
}
- /* Return to G3 if battery level is too low */
- if (charge_want_shutdown() ||
- tries > CHARGER_INITIALIZED_TRIES) {
+ /*
+ * Return to G3 if battery level is too low. Set
+ * power_up_inhibited in order to check the eligibility to boot
+ * AP up after battery SOC changes.
+ */
+ if (tries == CHARGER_INITIALIZED_TRIES) {
CPRINTS("power-up inhibited");
+ power_up_inhibited = 1;
chipset_force_shutdown();
return POWER_G3;
}
+
+ power_up_inhibited = 0;
}
#endif