From 77000e73bc11308bbf872fa8bbdd2a43d9e58050 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Tue, 31 Jul 2012 15:07:14 -0700 Subject: Fix setting initial debounced power button state If it's pressed, need to track that or we'll ignore the release. And then we'll leave the power button signal asserted to the PCH, and it'll shut down 4 seconds after the power button was pressed. BUG=chrome-os-partner:11971 TEST=hibernate 10, then press power button for ~0.5 sec, then release system should boot normally Change-Id: Ibb9b8a8827cca6c81bac06dc9543de1a76fa5aad Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/28863 Reviewed-by: Bill Richardson --- chip/lm4/power_button.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c index 1a7c462497..dd1712cb69 100644 --- a/chip/lm4/power_button.c +++ b/chip/lm4/power_button.c @@ -287,13 +287,16 @@ static void set_initial_pwrbtn_state(void) { uint32_t reset_flags = system_get_reset_flags(); + /* Set debounced power button state to initial button state */ + debounced_power_pressed = get_power_button_pressed(); + if (system_jumped_to_this_image() && chipset_in_state(CHIPSET_STATE_ON)) { /* * Jumped to this image while the chipset was already on, so * simply reflect the actual power button state. */ - if (get_power_button_pressed()) { + if (debounced_power_pressed) { *memmap_switches |= EC_SWITCH_POWER_BUTTON_PRESSED; CPRINTF("[%T PB init-jumped-held]\n"); set_pwrbtn_to_pch(0); @@ -316,7 +319,7 @@ static void set_initial_pwrbtn_state(void) */ CPRINTF("[%T PB init-off]\n"); set_pwrbtn_to_pch(1); - if (get_power_button_pressed()) + if (debounced_power_pressed) pwrbtn_state = PWRBTN_STATE_EAT_RELEASE; else pwrbtn_state = PWRBTN_STATE_IDLE; @@ -330,7 +333,7 @@ static void set_initial_pwrbtn_state(void) set_pwrbtn_to_pch(0); tnext_state = get_time().val + PWRBTN_INITIAL_US; - if (get_power_button_pressed()) { + if (debounced_power_pressed) { *memmap_switches |= EC_SWITCH_POWER_BUTTON_PRESSED; if (reset_flags & RESET_FLAG_RESET_PIN) -- cgit v1.2.1