diff options
author | YH Huang <yh.huang@mediatek.com> | 2015-06-22 20:22:00 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-25 10:51:19 +0000 |
commit | 8099b7b3849c43f6b0eba4dd3bd5564d254dc12e (patch) | |
tree | d8a001714ad7806c520969c97139f795846934d6 | |
parent | d5c43a880c7dadf76df152422f8b0f5e68455f61 (diff) | |
download | chrome-ec-8099b7b3849c43f6b0eba4dd3bd5564d254dc12e.tar.gz |
oak: power: add the console command "power on/off"
Add the console command "power on/off" for AP power on/off.
BRANCH=none
BUG=none
TEST=manual
enter "power on/off" in the ec console to turn AP power on/off.
Change-Id: I16d2af72bc1bf045e7672acd9471dff0a672aff5
Signed-off-by: YH Huang <yh.huang@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/280957
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | power/mediatek.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/power/mediatek.c b/power/mediatek.c index c8b08b2faa..130a691195 100644 --- a/power/mediatek.c +++ b/power/mediatek.c @@ -38,6 +38,7 @@ #include "system.h" #include "task.h" #include "test_util.h" +#include "util.h" #define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args) @@ -679,5 +680,63 @@ static void powerbtn_mtk_changed(void) { task_wake(TASK_ID_CHIPSET); } - DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, powerbtn_mtk_changed, HOOK_PRIO_DEFAULT); + +/*****************************************************************************/ +/* Console debug command */ + +static const char *power_req_name[POWER_REQ_COUNT] = { + "none", + "off", + "on", +}; + +/* Power states that we can report */ +enum power_state_t { + PSTATE_UNKNOWN, + PSTATE_OFF, + PSTATE_SUSPEND, + PSTATE_ON, + + PSTATE_COUNT, +}; + +static const char * const state_name[] = { + "unknown", + "off", + "suspend", + "on", +}; + +static int command_power(int argc, char **argv) +{ + int v; + + if (argc < 2) { + enum power_state_t state; + + state = PSTATE_UNKNOWN; + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + state = PSTATE_OFF; + if (chipset_in_state(CHIPSET_STATE_SUSPEND)) + state = PSTATE_SUSPEND; + if (chipset_in_state(CHIPSET_STATE_ON)) + state = PSTATE_ON; + ccprintf("%s\n", state_name[state]); + + return EC_SUCCESS; + } + + if (!parse_bool(argv[1], &v)) + return EC_ERROR_PARAM1; + + power_request = v ? POWER_REQ_ON : POWER_REQ_OFF; + ccprintf("Requesting power %s\n", power_req_name[power_request]); + task_wake(TASK_ID_CHIPSET); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(power, command_power, + "on/off", + "Turn AP power on/off", + NULL); |