summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben.chen2@quanta.corp-partner.google.com <ben.chen2@quanta.corp-partner.google.com>2019-10-08 19:44:32 +0800
committerCommit Bot <commit-bot@chromium.org>2019-10-15 11:10:45 +0000
commit4038bac6f39207dca025f8c333813ad77052b349 (patch)
tree37518acd761c539589b9f8f70e33c3378e77e9c2
parentc469aa1bcbef30ee57f12e4f99799ca8b95d576c (diff)
downloadchrome-ec-4038bac6f39207dca025f8c333813ad77052b349.tar.gz
power_button_x86: Make sure PWRBTN_STATE_INIT_ON base 100 milliseconds
Fix sub function state_machine PWRBTN_STATE_INIT_ON case, should be first check charge_prevent_power_on until POWER Button Time out. BUG=b:141260790 BRANCH=Master TEST=check PB task timing with power on timing be sure the same time. Change-Id: I15a599773afe94e0730755dd60674cb4c4ea27d6 Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1847571 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
-rw-r--r--common/power_button_x86.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/common/power_button_x86.c b/common/power_button_x86.c
index e5772d2f68..270d1ee2a4 100644
--- a/common/power_button_x86.c
+++ b/common/power_button_x86.c
@@ -321,33 +321,32 @@ static void state_machine(uint64_t tnow)
pwrbtn_state = PWRBTN_STATE_IDLE;
break;
case 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
- * CONFIG_POWER_BUTTON_INIT_TIMEOUT seconds after the PB task
- * was started. Here, it is important to check the current time
- * against PB task start time to prevent unnecessary timeouts
- * happening in recovery case where the tasks could start as
- * late as 30 seconds after EC reset.
- */
- if (tnow >
- (tpb_task_start +
- CONFIG_POWER_BUTTON_INIT_TIMEOUT * 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.
+ * Before attempting to power the system on, we need to allow
+ * time for charger, battery and USB-C PD initialization to be
+ * ready to supply sufficient power. Check every 100
+ * milliseconds, and give up CONFIG_POWER_BUTTON_INIT_TIMEOUT
+ * seconds after the PB task was started. Here, it is
+ * important to check the current time against PB task start
+ * time to prevent unnecessary timeouts happening in recovery
+ * case where the tasks could start as late as 30 seconds
+ * after EC reset.
*/
- if (charge_prevent_power_on(0)) {
- tnext_state = tnow + 100 * MSEC;
- break;
+
+ if (!IS_ENABLED(CONFIG_CHARGER) || charge_prevent_power_on(0)) {
+ if (tnow >
+ (tpb_task_start +
+ CONFIG_POWER_BUTTON_INIT_TIMEOUT * SECOND)) {
+ pwrbtn_state = PWRBTN_STATE_IDLE;
+ break;
+ }
+
+ if (IS_ENABLED(CONFIG_CHARGER)) {
+ tnext_state = tnow + 100 * MSEC;
+ break;
+ }
}
-#endif
/*
* Power the system on if possible. Gating due to insufficient