summaryrefslogtreecommitdiff
path: root/power/rk3399.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2016-07-15 19:17:44 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-18 11:36:36 -0700
commit06ca7d4d9137b407a3cf5dd86bdb1cdb4e6334e7 (patch)
tree3d7fdeec76d92817e3cafc598f83f6cceac0eaa6 /power/rk3399.c
parentc9f150c3686d6148ec6b73b65c4689b6eb78b6b8 (diff)
downloadchrome-ec-06ca7d4d9137b407a3cf5dd86bdb1cdb4e6334e7.tar.gz
rk3399: kevin: Inhibit booting w/ insufficient pwr
Before, as soon as the EC started booting, it would unconditionally boot the AP (unless explicitly told not to. ie: "reboot ap-off"). However, we weren't waiting for our power to settle which was causing some brownouts. This would happen when trying to boot without the battery. This commit causes the EC to inhibit powering on the AP until we have sufficient power. BUG=chrome-os-partner:55289 BRANCH=None TEST=Flash EVT2; verify can boot normally. TEST=Remove battery and insert charger. Verify that DUT can boot up. TEST=Insert drained battery. Verify power on is inhbited. Plug in charger and verify that DUT can power on. Change-Id: Ifb40766fcc1d330674ec39de6d81174f92b6d658 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/361005 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'power/rk3399.c')
-rw-r--r--power/rk3399.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/power/rk3399.c b/power/rk3399.c
index 554e5aee3d..8efebaf69a 100644
--- a/power/rk3399.c
+++ b/power/rk3399.c
@@ -5,6 +5,7 @@
/* rk3399 chipset power control module for Chrome EC */
+#include "charge_state.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -43,6 +44,9 @@
/* Long power key press to force shutdown in S0 */
#define FORCED_SHUTDOWN_DELAY (8 * SECOND)
+#define CHARGER_INITIALIZED_DELAY_MS 100
+#define CHARGER_INITIALIZED_TRIES 40
+
static int forcing_shutdown;
void chipset_force_shutdown(void)
@@ -94,6 +98,8 @@ DECLARE_DEFERRED(force_shutdown);
enum power_state power_handle_state(enum power_state state)
{
+ int tries = 0;
+
switch (state) {
case POWER_G3:
break;
@@ -118,6 +124,23 @@ enum power_state power_handle_state(enum power_state state)
case POWER_G3S5:
forcing_shutdown = 0;
+ /*
+ * Allow time for charger to be initialized, in case we're
+ * trying to boot the AP with no battery.
+ */
+ while (charge_prevent_power_on(0) &&
+ 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;
+ }
+
/* Power up to next state */
return POWER_S5;