From f214e47717b153ffb154795ca7d482db35ef4d3e Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Tue, 7 Feb 2012 10:33:42 -0800 Subject: [PATCH] Turn on when power button pressed Signed-off-by: Randall Spangler BUG=chrome-os-partner:7850 TEST=reboot, press power button; system should turn on reboot, type 'x86power s0'; system should also turn on Change-Id: Iac114c2655240d8aba81283d12f667f8e64d3ad3 --- common/x86_power.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/common/x86_power.c b/common/x86_power.c index 8f791e3236..68f30cdaf4 100644 --- a/common/x86_power.c +++ b/common/x86_power.c @@ -236,20 +236,6 @@ void x86_power_task(void) break; case X86_S5S0: - /* TODO: this should be in response to a power button - * event, not causing one. For initial bringup, - * simulate the event. */ - - /* Assert power button */ - gpio_set_level(GPIO_PCH_PWRBTNn, 0); - - /* Wait at least 16ms after asserting PWRBTN#. More - * is better for now, apparently. */ - usleep(100000); - - /* Release power button */ - gpio_set_level(GPIO_PCH_PWRBTNn, 1); - /* Wait for PM_SLP_S3n to be asserted */ wait_in_signals(IN_ALL_PM_SLP_DEASSERTED); @@ -278,13 +264,17 @@ void x86_power_task(void) 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; + /* If PM_SLP_S3# is deasserted, system is trying to + * power on. */ + if (gpio_get_level(GPIO_PCH_SLP_S3n) == 1) { + state = X86_S5S0; + break; + } + + /* Otherwise, steady state; wait for a message */ + task_wait_msg(-1); break; -#endif + case X86_S0: /* Steady state; wait for a message */ task_wait_msg(-1); @@ -307,8 +297,13 @@ static int command_x86power(int argc, char **argv) /* Get state to move to */ if (!strcasecmp(argv[1], "S0")) { - if (state == X86_S5) - state = X86_S5S0; + if (state == X86_S5) { + /* Simulate a 100ms power button press */ + uart_puts("Simulating power button press.\n"); + gpio_set_level(GPIO_PCH_PWRBTNn, 0); + usleep(100000); + gpio_set_level(GPIO_PCH_PWRBTNn, 1); + } } if (current == state)