From 90ae18655c01e880563add1c761193316a633034 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sat, 14 Jan 2017 17:33:02 +0800 Subject: 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 Tested-by: Nicolas Boichat Reviewed-by: Randall Spangler --- common/button.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'common/button.c') 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. -- cgit v1.2.1