From 9f09fbe42c073b5e1fec97feb5baaa74781c4f00 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Thu, 12 Apr 2012 14:18:30 -0700 Subject: [PATCH] Fix power button turning system back on after 4 sec Signed-off-by: Randall Spangler BUG=chrome-os-partner:8981 TEST=manual Turn system on Hold power button for 5 sec Let go System should stay off Change-Id: I4660108972795d631b7c33926df58513ee09e1c7 --- chip/lm4/power_button.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c index 350189c4a4..00bf2b8487 100644 --- a/chip/lm4/power_button.c +++ b/chip/lm4/power_button.c @@ -122,8 +122,15 @@ static void state_machine(uint64_t tnow) switch (pwrbtn_state) { case PWRBTN_STATE_START: - tnext_state = tnow + PWRBTN_DELAY_T0; - pwrbtn_state = PWRBTN_STATE_T0; + if (chipset_in_state(CHIPSET_STATE_SOFT_OFF)) { + /* Chipset is off, so just pass the true power button + * state to the chipset. */ + pwrbtn_state = PWRBTN_STATE_HELD_DOWN; + } else { + /* Chipset is on, so send the chipset a pulse */ + tnext_state = tnow + PWRBTN_DELAY_T0; + pwrbtn_state = PWRBTN_STATE_T0; + } set_pwrbtn_to_pch(0); break; case PWRBTN_STATE_T0: @@ -132,8 +139,14 @@ static void state_machine(uint64_t tnow) set_pwrbtn_to_pch(1); break; case PWRBTN_STATE_T1: + /* If the chipset is already off, don't tell it the power + * button is down; it'll just cause the chipset to turn on + * again. */ + if (!chipset_in_state(CHIPSET_STATE_SOFT_OFF)) + set_pwrbtn_to_pch(0); + else + uart_printf("[%T PB chipset already off]\n"); pwrbtn_state = PWRBTN_STATE_HELD_DOWN; - set_pwrbtn_to_pch(0); break; case PWRBTN_STATE_STOPPING: set_pwrbtn_to_pch(1);