diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-07-14 10:31:42 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-07-15 02:06:48 +0000 |
commit | 3b55292cdb76f1acd540b89ce16a24fda863bc62 (patch) | |
tree | cfd15ef9e8949c8a7bb835b173a754b1e1e55c3a /common/port80.c | |
parent | 19ad2a91ccc80c97107566b573791ff12a9bc7d4 (diff) | |
download | chrome-ec-3b55292cdb76f1acd540b89ce16a24fda863bc62.tar.gz |
port80: Disable port80 task when leaving S0
port80 task polling prevents the EC from entering low power states and
isn't useful when the AP isn't running. Therefore, when
CONFIG_PORT80_TASK_EN is enabled, only enable the port80 task when
entering S0, and disable it when leaving S0.
BUG=chrome-os-partner:42104
TEST=Manual on Glados. Boot AP, verify that 'port80' log starts with "10
20...". Shutdown AP, verify with 'taskinfo' that PORT80 task stops
consuming cycles. Boot AP again, verify that 'port80' log starts with
new "10 20...".
BRANCH=None
Change-Id: Id41dbdaa4597456d042b7a3921c1ec439af759f4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/285550
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/port80.c')
-rw-r--r-- | common/port80.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/common/port80.c b/common/port80.c index f857540727..312024a3ad 100644 --- a/common/port80.c +++ b/common/port80.c @@ -7,6 +7,7 @@ #include "common.h" #include "console.h" +#include "hooks.h" #include "host_command.h" #include "port80.h" #include "task.h" @@ -58,11 +59,6 @@ void port_80_write(int data) */ void port80_task(void) { -#ifdef CONFIG_PORT80_TASK_EN - task_en = 1; - task_timeout = PORT80_POLL_PERIOD; -#endif - while (1) { int data = port_80_read(); @@ -72,7 +68,28 @@ void port80_task(void) task_wait_event(task_timeout); } } -#endif + +static void port_80_task_enable(void) +{ + task_en = 1; + task_timeout = PORT80_POLL_PERIOD; + task_wake(TASK_ID_PORT80); +} + +static void port_80_task_disable(void) +{ + task_en = 0; + task_timeout = -1; +} + +#ifdef CONFIG_PORT80_TASK_EN + +/* Only enable the port80 task when the AP is started, to save power */ +DECLARE_HOOK(HOOK_CHIPSET_RESUME, port_80_task_enable, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, port_80_task_disable, HOOK_PRIO_DEFAULT); + +#endif /* PORT80_TASK_EN */ +#endif /* HAS_TASK_PORT80 */ /*****************************************************************************/ /* Console commands */ @@ -104,11 +121,9 @@ static int command_port80(int argc, char **argv) } else if (!strcasecmp(argv[1], "task")) { task_en = !task_en; ccprintf("task %sabled\n", task_en ? "en" : "dis"); - if (task_en) { - task_timeout = PORT80_POLL_PERIOD; - task_wake(TASK_ID_PORT80); - } else - task_timeout = -1; + task_en ? port_80_task_enable() : + port_80_task_disable(); + return EC_SUCCESS; } else if (!strcasecmp(argv[1], "poll")) { i = port_80_read(); |