diff options
Diffstat (limited to 'board/cr50/wp.c')
-rw-r--r-- | board/cr50/wp.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/board/cr50/wp.c b/board/cr50/wp.c index 3c25036647..4d074d9cbd 100644 --- a/board/cr50/wp.c +++ b/board/cr50/wp.c @@ -11,6 +11,7 @@ #include "hooks.h" #include "nvmem.h" #include "nvmem_vars.h" +#include "physical_presence.h" #include "registers.h" #include "scratch_reg1.h" #include "system.h" @@ -377,7 +378,7 @@ static void unlock_sequence_is_over(void) unlock_in_progress = 0; /* Allow sleeping again */ - enable_sleep(SLEEP_MASK_FORCE_NO_DSLEEP); + enable_sleep(SLEEP_MASK_PHYSICAL_PRESENCE); } DECLARE_DEFERRED(unlock_sequence_is_over); @@ -397,12 +398,16 @@ static void power_button_poked(void) static void power_button_handler(void) { - if (unlock_in_progress) + CPRINTS("power button pressed"); + if (physical_detect_press() == EC_SUCCESS) { + /* Consumed by physical detect */ + } else if (unlock_in_progress) { power_button_poked(); #ifdef CONFIG_U2F - else + } else { power_button_record(); #endif + } GWRITE_FIELD(RBOX, INT_STATE, INTR_PWRB_IN_FED, 1); } @@ -420,7 +425,7 @@ static void start_unlock_process(int total_poking_time, int max_poke_interval) unlock_deadline.val += total_poking_time; /* Stay awake while we're doing this, just in case. */ - disable_sleep(SLEEP_MASK_FORCE_NO_DSLEEP); + disable_sleep(SLEEP_MASK_PHYSICAL_PRESENCE); /* Check progress after waiting long enough for one button press */ hook_call_deferred(&unlock_sequence_is_over_data, unlock_beat); @@ -437,6 +442,15 @@ static void power_button_init(void) } DECLARE_HOOK(HOOK_INIT, power_button_init, HOOK_PRIO_DEFAULT); +void board_physical_presence_enable(int enable) +{ + /* Stay awake while we're doing this, just in case. */ + if (enable) + disable_sleep(SLEEP_MASK_PHYSICAL_PRESENCE); + else + enable_sleep(SLEEP_MASK_PHYSICAL_PRESENCE); +} + /****************************************************************************/ /* TPM vendor-specific commands */ |