summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-08-02 12:40:30 -0700
committerDave Parker <dparker@chromium.org>2013-08-09 23:35:43 -0700
commit3f5293cfd45cb1f54635c1ad0c2478d930c07ae6 (patch)
treea69af8f88e638a97654a0b0dba614044c02c1bd2
parente73ba46897a09ce7f1d60d344b15182468f40cde (diff)
downloadchrome-ec-3f5293cfd45cb1f54635c1ad0c2478d930c07ae6.tar.gz
CHERRY-PICK:x86: use charge state hook to wake up power button task
This is cleaner than having the charge state machine explicitly know about the power button task. BUG=chrome-os-partner:21610 BRANCH=none TEST=reboot EC; see that power button task does not leave init-on state until just after the charge state initializes: [0.022646 Charge state init -> idle0 after 0.005908 sec] [0.022956 PB task 8 = init-on] [0.023147 PB PCH pwrbtn=LOW] [0.023303 PB task 6 = released, wait 199996] Change-Id: I09ac67ff51a7734c5400cc595df6374cc6df6aa4 Original-Change-Id: I11d70103e3ee545512efe621f53d999680a7ad56 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64366 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/65443 Commit-Queue: Dave Parker <dparker@chromium.org> Reviewed-by: Dave Parker <dparker@chromium.org> Tested-by: Dave Parker <dparker@chromium.org>
-rw-r--r--common/charge_state.c13
-rw-r--r--common/power_button_x86.c14
2 files changed, 14 insertions, 13 deletions
diff --git a/common/charge_state.c b/common/charge_state.c
index f7a644bfe3..9e3192abde 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -695,19 +695,6 @@ void charger_task(void)
hook_notify(HOOK_CHARGE_STATE_CHANGE);
}
-#ifdef HAS_TASK_POWERBTN
- /*
- * After first init, wake the power button task so it can
- * power on the AP if necessary.
- *
- * TODO(rspangler): API, instead of assuming power button task
- * exists
- */
- if (ctx->prev.state == PWR_STATE_INIT &&
- new_state != PWR_STATE_INIT)
- task_wake(TASK_ID_POWERBTN);
-#endif
-
switch (new_state) {
case PWR_STATE_IDLE0:
/*
diff --git a/common/power_button_x86.c b/common/power_button_x86.c
index 2d353b74ed..e37fb6f81f 100644
--- a/common/power_button_x86.c
+++ b/common/power_button_x86.c
@@ -397,3 +397,17 @@ static void powerbtn_x86_changed(void)
task_wake(TASK_ID_POWERBTN);
}
DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, powerbtn_x86_changed, HOOK_PRIO_DEFAULT);
+
+/**
+ * Handle charge state changes
+ */
+static void powerbtn_x86_charge(void)
+{
+ /*
+ * If we were waiting for the charge state machine to init before we
+ * powered on the chipset, we can stop waiting.
+ */
+ if (pwrbtn_state == PWRBTN_STATE_INIT_ON)
+ task_wake(TASK_ID_POWERBTN);
+}
+DECLARE_HOOK(HOOK_CHARGE_STATE_CHANGE, powerbtn_x86_charge, HOOK_PRIO_DEFAULT);