diff options
author | Randall Spangler <rspangler@chromium.org> | 2017-07-12 12:56:48 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-19 14:41:21 -0700 |
commit | a6060f53ee2c2736031b5fea80884886c6e08816 (patch) | |
tree | c412e882d29a0e65fb90ad29e66ac98798fc69e2 /board/cr50 | |
parent | 1082d99ca629c88a46996f3911f0a5af98dd3ba8 (diff) | |
download | chrome-ec-a6060f53ee2c2736031b5fea80884886c6e08816.tar.gz |
cr50: Add physical presence state machine
This will be used as part of case closed debugging configuration.
Currently, this only adds the state machine, and a test command which
is available when CR50_DEV=1. It also adds a new sleep mask flag for
physical presence detect, instead of oveloading FORCE_NO_DSLEEP.
The physical presence state machine supports both short (tap 5 times
in 15 seconds) and long (short, followed by 4 more taps 1-5 minutes
apart) sequences. It will call a callback function at the end of the
sequence, so that multiple things can each request physical presence
in turn. This will be used by ccdopen / ccdunlock / testlab commands
for CCD V1.
Eventually, CCD config will replace the unlock sequence handling in
wp.c. But for now, we don't touch that.
See go/cr50-ccd-wp for more information.
BUG=b:62537474
BRANCH=none
TEST=manual
Short sequence:
pp short
pp
pp
pp # See "Physical presence good"
Timeout
pp short
pp # 15 sec later, get timeout error
Long sequence:
pp long
pp
pp
pp
(wait 2 sec)
pp
(wait 2 sec)
pp # See "PP good"
Long sequence, presses too fast:
pp long
pp
pp
pp
pp # See "PP L too soon"
(wait 2 sec)
pp
(wait 2 sec)
pp # See "Physical presence good"
Abort:
pp short
pp abort # See "Physical presence aborted"
Change-Id: I09da81ad11d328e7d7740c3fe838a5f67d7b8708
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/568796
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'board/cr50')
-rw-r--r-- | board/cr50/board.h | 6 | ||||
-rw-r--r-- | board/cr50/wp.c | 22 |
2 files changed, 24 insertions, 4 deletions
diff --git a/board/cr50/board.h b/board/cr50/board.h index 9d0ebbce43..b6ebedd7b0 100644 --- a/board/cr50/board.h +++ b/board/cr50/board.h @@ -102,6 +102,12 @@ /* Enable Case Closed Debugging */ #define CONFIG_CASE_CLOSED_DEBUG +#define CONFIG_PHYSICAL_PRESENCE + +#ifdef CR50_DEV +/* Enable unsafe dev features for physical presence in dev builds */ +#define CONFIG_PHYSICAL_PRESENCE_DEBUG_UNSAFE +#endif #define CONFIG_USB_PID 0x5014 #define CONFIG_USB_SELF_POWERED 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 */ |