summaryrefslogtreecommitdiff
path: root/common/button.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-04-20 17:44:38 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-05-09 23:20:08 -0700
commit9c488952251502b5f56e4b2d5181a332a27f8639 (patch)
tree5c382faeddba47af0f9b0039c3918e85ae92c4f0 /common/button.c
parente8982ea3cd66941e518b829a37834a534e71b3bc (diff)
downloadchrome-ec-9c488952251502b5f56e4b2d5181a332a27f8639.tar.gz
button: Allow board to define recovery buttons
This patch declares recovery_buttons array, where each board lists recovery buttons. Pressing those while the board reboots makes the system enter recovery mode. BUG=none BRANCH=none TEST=buildall Change-Id: I1f204156efbd6d2a507d67ba90f75ce857b03559 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/486944
Diffstat (limited to 'common/button.c')
-rw-r--r--common/button.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/common/button.c b/common/button.c
index 531467240b..079b26acdf 100644
--- a/common/button.c
+++ b/common/button.c
@@ -85,6 +85,19 @@ static void button_blink_hw_reinit_led(void)
#endif
/*
+ * Whether recovery button (or combination of equivalent buttons) is pressed
+ */
+static int is_recovery_button_pressed(void)
+{
+ int i;
+ for (i = 0; i < recovery_buttons_count; i++) {
+ if (!raw_button_pressed(recovery_buttons[i]))
+ return 0;
+ }
+ return 1;
+}
+
+/*
* 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
@@ -102,8 +115,7 @@ static void button_check_hw_reinit_required(void)
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]) ||
+ if (!is_recovery_button_pressed() ||
!power_button_signal_asserted()) {
CPRINTS("No HW_REINIT request");
return;
@@ -139,8 +151,7 @@ void button_init(void)
#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])) {
+ is_recovery_button_pressed()) {
host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY);
button_check_hw_reinit_required();
}