From d12a96a5ec7af993eb8f163b21509be1c2ca3060 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Thu, 26 Jan 2012 13:45:32 -0800 Subject: Add x86power command to get/set x86 power state Signed-off-by: Randall Spangler BUG=chrome-os-partner:7528 TEST=x86power s0; should turn on all power rails (check via gpioget) Change-Id: I284ac2104e02748ed69408873fbcebb9d54cdcff --- common/x86_power.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'common/x86_power.c') 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); -- cgit v1.2.1