summaryrefslogtreecommitdiff
path: root/common/x86_power.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-01-26 13:45:32 -0800
committerRandall Spangler <rspangler@chromium.org>2012-01-26 16:01:39 -0800
commitd12a96a5ec7af993eb8f163b21509be1c2ca3060 (patch)
tree5e0b888f220ab31314a40cd3c986a85b6adf030d /common/x86_power.c
parentc5da68d224e7b9ee49dfbe1227f228c9030311d9 (diff)
downloadchrome-ec-d12a96a5ec7af993eb8f163b21509be1c2ca3060.tar.gz
Add x86power command to get/set x86 power state
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:7528 TEST=x86power s0; should turn on all power rails (check via gpioget) Change-Id: I284ac2104e02748ed69408873fbcebb9d54cdcff
Diffstat (limited to 'common/x86_power.c')
-rw-r--r--common/x86_power.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/common/x86_power.c b/common/x86_power.c
index 7618b69a44..523735f65d 100644
--- a/common/x86_power.c
+++ b/common/x86_power.c
@@ -117,6 +117,7 @@ static int wait_in_signals(uint32_t want)
while ((in_signals & in_want) != in_want) {
if (task_wait_msg(DEFAULT_TIMEOUT) == (1 << TASK_ID_TIMER)) {
+ update_in_signals();
uart_printf("[x86 power timeout on input; "
"wanted 0x%04x, got 0x%04x]\n",
in_want, in_signals & in_want);
@@ -202,8 +203,8 @@ void x86_power_task(void)
x86_power_init();
while (1) {
- uart_printf("[x86 power state %d = %s]\n", state,
- state_names[state]);
+ uart_printf("[x86 power state %d = %s, in 0x%04x]\n",
+ state, state_names[state], in_signals);
switch (state) {
@@ -212,13 +213,6 @@ void x86_power_task(void)
state = X86_G3S5;
break;
- case X86_S5:
- /* For bringup, power on one second after boot */
- /* TODO: remove post-bringup */
- usleep(1000000);
- state = X86_S5S0;
- break;
-
case X86_G3S5:
/* Wait for the always-on rails to be good */
wait_in_signals(IN_PGOOD_ALWAYS_ON);
@@ -274,6 +268,14 @@ void x86_power_task(void)
state = X86_S0;
break;
+ case X86_S5:
+#ifdef AUTO_POWER_UP
+ /* For bringup, power on one second after boot */
+ /* TODO: remove post-bringup */
+ usleep(1000000);
+ state = X86_S5S0;
+ break;
+#endif
case X86_S0:
/* Steady state; wait for a message */
task_wait_msg(-1);
@@ -281,5 +283,34 @@ void x86_power_task(void)
}
}
+/*****************************************************************************/
+/* Console commnands */
+static int command_x86power(int argc, char **argv)
+{
+ enum x86_state current = state;
+ /* If no args provided, print current state */
+ if (argc < 2) {
+ uart_printf("Current X86 state: %d (%s)\n",
+ state, state_names[state]);
+ return EC_SUCCESS;
+ }
+ /* Get state to move to */
+ if (!strcasecmp(argv[1], "S0")) {
+ if (state == X86_S5)
+ state = X86_S5S0;
+ }
+
+ if (current == state)
+ uart_puts("State not changed.\n");
+ else {
+ uart_printf("New X86 state: %d (%s)\n",
+ state, state_names[state]);
+ /* Wake up the task if it's asleep */
+ task_send_msg(TASK_ID_X86POWER, TASK_ID_X86POWER, 0);
+ }
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(x86power, command_x86power);