diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-01-14 17:33:02 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-01-20 00:05:06 -0800 |
commit | 90ae18655c01e880563add1c761193316a633034 (patch) | |
tree | 9860d1d35c8122406291eec6e479adb5be5bbb63 /common/button.c | |
parent | a1064d997902b567303e1eb6be5780baa4c0d4ae (diff) | |
download | chrome-ec-90ae18655c01e880563add1c761193316a633034.tar.gz |
button: Check volume up/down status and set recovery mode
Add support for entering recovery mode using volume up/down keys.
BRANCH=none
BUG=chrome-os-partner:61930
TEST=Press Power+Volume Up+Volume Down, poppy enters recovery
Change-Id: Id40a144e9b430cfb9dfd47048e9e96d598bc3db8
Reviewed-on: https://chromium-review.googlesource.com/428530
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/button.c')
-rw-r--r-- | common/button.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common/button.c b/common/button.c index fb47984ad9..a9fcca7904 100644 --- a/common/button.c +++ b/common/button.c @@ -9,8 +9,10 @@ #include "common.h" #include "console.h" #include "gpio.h" +#include "host_command.h" #include "hooks.h" #include "keyboard_protocol.h" +#include "system.h" #include "timer.h" #include "util.h" @@ -57,7 +59,7 @@ static int raw_button_pressed(const struct button_config *button) /* * Button initialization. */ -static void button_init(void) +void button_init(void) { int i; @@ -68,8 +70,16 @@ static void button_init(void) state[i].debounce_time = 0; gpio_enable_interrupt(buttons[i].gpio); } + +#ifdef CONFIG_BUTTON_RECOVERY + if (!system_jumped_to_this_image() && + (system_get_reset_flags() & RESET_FLAG_RESET_PIN) && + raw_button_pressed(&buttons[BUTTON_VOLUME_DOWN]) && + raw_button_pressed(&buttons[BUTTON_VOLUME_UP])) { + host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY); + } +#endif } -DECLARE_HOOK(HOOK_INIT, button_init, HOOK_PRIO_DEFAULT); /* * Handle debounced button changing state. |