summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-07-22 12:01:39 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-01 02:52:18 +0000
commit0085573ff4b035fc45c7d902c622f9e39cd997e3 (patch)
treea66ac1479fb156fa4788f5e5ec7a1150be407c8f /power
parente58a913bccb07b329605046b5e23f18865cb003f (diff)
downloadchrome-ec-0085573ff4b035fc45c7d902c622f9e39cd997e3.tar.gz
skylake: Inhibit AP power-on until charge current limit is set
Inhibit AP power-on through the BATLOW pin, even if the system is unprotected, until our charger and current limit are initialized. Note that this feature is only functional on glados v2 since other skylake boards do not have BATLOW connected. BUG=chrome-os-partner:41258 TEST=Manual on glados v1 with rework. Remove battery and attach Zinger. Verify EC powers on and AP doesn't boot. Run `powerbtn`, verify that AP boots. Remove all power and attach battery, verify that EC powers on and AP boots. Also verify compilation on glados v2. BRANCH=None Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I55de857f7006777640f7853b7bde98ba97e8bd13 Reviewed-on: https://chromium-review.googlesource.com/287378
Diffstat (limited to 'power')
-rw-r--r--power/skylake.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/power/skylake.c b/power/skylake.c
index 88c7b5ddae..b30961e689 100644
--- a/power/skylake.c
+++ b/power/skylake.c
@@ -5,6 +5,7 @@
/* Skylake IMVP8 / ROP PMIC chipset power control module for Chrome EC */
+#include "charge_state.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -38,6 +39,9 @@
#define IN_ALL_S0 (IN_PGOOD_ALL_CORE | IN_ALL_PM_SLP_DEASSERTED)
+#define CHARGER_INITIALIZED_DELAY_MS 100
+#define CHARGER_INITIALIZED_TRIES 10
+
static int throttle_cpu; /* Throttle CPU? */
static int forcing_shutdown; /* Forced shutdown in progress? */
@@ -128,6 +132,9 @@ enum power_state power_handle_state(enum power_state state)
*/
int rsmrst_in = gpio_get_level(GPIO_RSMRST_L_PGOOD);
int rsmrst_out = gpio_get_level(GPIO_PCH_RSMRST_L);
+#ifdef GLADOS_BOARD_V2
+ int tries = 0;
+#endif
if (rsmrst_in != rsmrst_out) {
/*
@@ -187,6 +194,23 @@ enum power_state power_handle_state(enum power_state state)
}
#ifdef GLADOS_BOARD_V2
+ /*
+ * Allow up to 1s for charger to be initialized, in case
+ * we're trying to boot the AP with no battery.
+ */
+ while (charge_prevent_power_on() &&
+ tries++ < CHARGER_INITIALIZED_TRIES) {
+ msleep(CHARGER_INITIALIZED_DELAY_MS);
+ }
+
+ /* Return to G3 if battery level is too low */
+ if (charge_want_shutdown() ||
+ tries == CHARGER_INITIALIZED_TRIES) {
+ CPRINTS("power-up inhibited");
+ chipset_force_shutdown();
+ return POWER_G3;
+ }
+
/* Allow AP to power on */
gpio_set_level(GPIO_PMIC_SLP_SUS_L, 1);
gpio_set_level(GPIO_PCH_BATLOW_L, 1);