diff options
author | Furquan Shaikh <furquan@chromium.org> | 2017-04-25 15:13:58 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-05-02 14:05:08 -0700 |
commit | 5bc66e29950cb57cc545f571d5111cbce1fec0da (patch) | |
tree | a849406fa0fa453c40a0adfd3897f91bf16791bf /common/button.c | |
parent | 32eebe3c5f12c1963bf9bc921839de1168cd7396 (diff) | |
download | chrome-ec-5bc66e29950cb57cc545f571d5111cbce1fec0da.tar.gz |
common/button: Add support for HW_REINIT button combo
If volume up + volume down + power buttons are held down for 30
seconds, then indicate to AP that HW_REINIT is requested by the
user. Since recovery mode is triggered by holding down the three buttons
for 10 seconds, button_check_hw_reinit_required checks for 20 more
seconds only.
BUG=b:37682514
BRANCH=None
TEST=Verified that:
1. If volume up, volume down and power are held for 30 seconds, AP
sees the hw reinit request.
2. If either of the buttons is released before 30 seconds, AP does not
see the hw reinit request.
Change-Id: I3a53966dcdcb84d73f160578411b6c0f62225b95
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/487002
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'common/button.c')
-rw-r--r-- | common/button.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/common/button.c b/common/button.c index 278ac36ffc..71d1af95fb 100644 --- a/common/button.c +++ b/common/button.c @@ -12,9 +12,11 @@ #include "host_command.h" #include "hooks.h" #include "keyboard_protocol.h" +#include "power_button.h" #include "system.h" #include "timer.h" #include "util.h" +#include "watchdog.h" /* Console output macro */ #define CPRINTS(format, args...) cprints(CC_SWITCH, format, ## args) @@ -56,6 +58,40 @@ static int raw_button_pressed(const struct button_config *button) raw_value : !raw_value; } +#ifdef CONFIG_BUTTON_RECOVERY +/* + * If the EC is reset and recovery is requested, then check if HW_REINIT is + * requested as well. Since the EC reset occurs after volup+voldn+power buttons + * are held down for 10 seconds, check the state of these buttons for 20 more + * seconds. If they are still held down all this time, then set host event to + * indicate HW_REINIT is requested. Also, make sure watchdog is reloaded in + * order to prevent watchdog from resetting the EC. + */ +static void button_check_hw_reinit_required(void) +{ + timestamp_t deadline; + timestamp_t now = get_time(); + + deadline.val = now.val + (20 * SECOND); + + CPRINTS("Checking for HW_REINIT request"); + + while (!timestamp_expired(deadline, &now)) { + if (!raw_button_pressed(&buttons[BUTTON_VOLUME_UP]) || + !raw_button_pressed(&buttons[BUTTON_VOLUME_DOWN]) || + !power_button_signal_asserted()) { + CPRINTS("No HW_REINIT request"); + return; + } + now = get_time(); + watchdog_reload(); + } + + CPRINTS("HW_REINIT requested"); + host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT); +} +#endif + /* * Button initialization. */ @@ -77,6 +113,7 @@ void button_init(void) raw_button_pressed(&buttons[BUTTON_VOLUME_DOWN]) && raw_button_pressed(&buttons[BUTTON_VOLUME_UP])) { host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY); + button_check_hw_reinit_required(); } #endif } |