diff options
author | Simon Glass <sjg@chromium.org> | 2012-07-17 04:50:36 +0100 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-17 23:14:10 -0700 |
commit | 698ae9f5ad77325de6c694391eb35202a10b8e69 (patch) | |
tree | c5ea6ff2f3cd0dcb680d41f58f92043367c86772 | |
parent | 228259479aac39563eb4906d61dc5faa76fb35f1 (diff) | |
download | chrome-ec-698ae9f5ad77325de6c694391eb35202a10b8e69.tar.gz |
gaia_power: Add power command to check power state.
It is useful to be able to see the current AP power state, and x86
has a command for this. Add one for gaia.
BUG=chrome-os-partner:11427
TEST=manual
(start with power off)
> powerinfo
off
(press power button)
> [batt] state idle -> pre-charging
AP running ...
Power button released
Setting pwron timer 10038870
powerinfo
on
> Releasing pwron
(after kernel boots, make device go into suspend by typing this at
kernel command line:
type echo mem > /sys/power/state)
> powerinfo
suspend
Change-Id: I3244b3a7fd0b6dd689f3470fb97ffe5a72c8d8f9
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27653
Reviewed-by: David Hendricks <dhendrix@chromium.org>
-rw-r--r-- | common/gaia_power.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/common/gaia_power.c b/common/gaia_power.c index bf060f9327..c8d439946b 100644 --- a/common/gaia_power.c +++ b/common/gaia_power.c @@ -479,3 +479,45 @@ DECLARE_CONSOLE_COMMAND(forcepower, command_force_power, NULL, "Force power on", NULL); + +/* 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) +{ + 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; + } + + ccputs("Invalid args\n"); + return EC_ERROR_INVAL; +} +DECLARE_CONSOLE_COMMAND(power, command_power, + NULL, + "Check AP power state", + NULL); |