diff options
author | Edward Hill <ecgh@chromium.org> | 2018-02-02 12:30:09 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-13 19:00:18 -0700 |
commit | e74d21f5bdf7f05f13a3b6d496fe37235cb4fdef (patch) | |
tree | 93083fe07ed3164f4df807bb8d7366c52ee6e6de /common/power_button_x86.c | |
parent | 70a258a192787766289a2804a012337ad0bccc17 (diff) | |
download | chrome-ec-e74d21f5bdf7f05f13a3b6d496fe37235cb4fdef.tar.gz |
power button: Wait for charger and battery initialization
For PWRBTN_STATE_INIT_ON, before attempting to power the
system on, we need to wait for charger and battery to be
ready to supply sufficient power. Check every 100
milliseconds, and give up after 1 second. This allows
time for charger, battery and USB-C PD initialization.
Previously, init-on would fail because it called
set_pwrbtn_to_pch too soon (before charge current had
been initialized, and before the USB-C 3A current was
detected).
BUG=b:72645441,b:74017044
BRANCH=none
TEST=cold reset Grunt with ac/battery connected/disconnected
Change-Id: I0413e7f2d7b19a99c994b51b22f28a2f993137de
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/900049
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
Diffstat (limited to 'common/power_button_x86.c')
-rw-r--r-- | common/power_button_x86.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/common/power_button_x86.c b/common/power_button_x86.c index 79fdeea82f..4876ee12c4 100644 --- a/common/power_button_x86.c +++ b/common/power_button_x86.c @@ -310,13 +310,24 @@ static void state_machine(uint64_t tnow) break; case PWRBTN_STATE_INIT_ON: /* - * Don't do anything until the charger knows the battery level. - * Otherwise we could power on the AP only to shut it right - * back down due to insufficient battery. + * Before attempting to power the system on, we need to wait for + * charger and battery to be ready to supply sufficient power. + * Check every 100 milliseconds, and give up after 1 second. */ -#ifdef HAS_TASK_CHARGER - if (charge_get_state() == PWR_STATE_INIT) + if (tnow > 1 * SECOND) { + pwrbtn_state = PWRBTN_STATE_IDLE; + break; + } + +#ifdef CONFIG_CHARGER + /* + * If not able to power on, try again later, to allow time for + * charger, battery and USB-C PD initialization. + */ + if (charge_prevent_power_on(0)) { + tnext_state = tnow + 100 * MSEC; break; + } #endif /* |