summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-12-15 15:55:27 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-12-18 22:55:02 -0800
commita6509d28ab33aedce55c12a081582fbe38b79235 (patch)
tree406362243bd819a1c853af1192cac941d045a66a /common
parentf889d14d4e08c9826c92dd2fa81d65908c97f6cd (diff)
downloadchrome-ec-a6509d28ab33aedce55c12a081582fbe38b79235.tar.gz
config: Add CONFIG_BUTTON_TRIGGERED_RECOVERY.
The CONFIG_BUTTON_RECOVERY option was a little confusing especially when we have the CONFIG_DEDICATED_RECOVERY_BUTTON option. This commit renames CONFIG_BUTTON_RECOVERY to CONFIG_BUTTON_TRIGGERED_RECOVERY to help make things a little clearer. Additionally, to avoid copy paste, defining CONFIG_BUTTON_TRIGGERED_RECOVERY will populate the recovery_buttons table with either the volume buttons or a dedicated recovery button depending what the board is configured for. Lastly, if CONFIG_DEDICATED_RECOVERY_BUTTON is defined, CONFIG_BUTTON_TRIGGERED_RECOVERY is defined as well since it's implicit. BUG=chromium:783371 BRANCH=None TEST=make -j buildall Change-Id: Idccaa4d049ace0df3b98b35bdd38ac9dbd843200 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/830917 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/button.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/common/button.c b/common/button.c
index 084cb35c47..5a48c8842e 100644
--- a/common/button.c
+++ b/common/button.c
@@ -83,7 +83,7 @@ static int raw_button_pressed(const struct button_config *button)
raw_value : !raw_value;
}
-#ifdef CONFIG_BUTTON_RECOVERY
+#ifdef CONFIG_BUTTON_TRIGGERED_RECOVERY
#ifdef CONFIG_LED_COMMON
static void button_blink_hw_reinit_led(void)
@@ -184,7 +184,7 @@ static int is_recovery_boot(void)
return 0;
return 1;
}
-#endif /* CONFIG_BUTTON_RECOVERY */
+#endif /* CONFIG_BUTTON_TRIGGERED_RECOVERY */
/*
* Button initialization.
@@ -201,13 +201,13 @@ void button_init(void)
gpio_enable_interrupt(buttons[i].gpio);
}
-#ifdef CONFIG_BUTTON_RECOVERY
+#ifdef CONFIG_BUTTON_TRIGGERED_RECOVERY
if (is_recovery_boot()) {
system_clear_reset_flags(RESET_FLAG_AP_OFF);
host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY);
button_check_hw_reinit_required();
}
-#endif
+#endif /* defined(CONFIG_BUTTON_TRIGGERED_RECOVERY) */
}
/*
@@ -716,6 +716,10 @@ DECLARE_HOOK(HOOK_TICK, debug_led_tick, HOOK_PRIO_DEFAULT);
#endif /* !CONFIG_DEDICATED_RECOVERY_BUTTON */
#endif /* CONFIG_EMULATED_SYSRQ */
+#if defined(CONFIG_VOLUME_BUTTONS) && defined(CONFIG_DEDICATED_RECOVERY_BUTTON)
+#error "A dedicated recovery button is not needed if you have volume buttons."
+#endif /* defined(CONFIG_VOLUME_BUTTONS && CONFIG_DEDICATED_RECOVERY_BUTTON) */
+
const struct button_config buttons[BUTTON_COUNT] = {
#ifdef CONFIG_VOLUME_BUTTONS
[BUTTON_VOLUME_UP] = {
@@ -733,9 +737,8 @@ const struct button_config buttons[BUTTON_COUNT] = {
.debounce_us = 30 * MSEC,
.flags = 0,
},
-#endif /* defined(CONFIG_VOLUME_BUTTONS) */
-#ifdef CONFIG_DEDICATED_RECOVERY_BUTTON
+#elif defined(CONFIG_DEDICATED_RECOVERY_BUTTON)
[BUTTON_RECOVERY] = {
.name = "Recovery",
.type = KEYBOARD_BUTTON_RECOVERY,
@@ -745,3 +748,16 @@ const struct button_config buttons[BUTTON_COUNT] = {
}
#endif /* defined(CONFIG_DEDICATED_RECOVERY_BUTTON) */
};
+
+#ifdef CONFIG_BUTTON_TRIGGERED_RECOVERY
+const struct button_config *recovery_buttons[] = {
+#ifdef CONFIG_DEDICATED_RECOVERY_BUTTON
+ &buttons[BUTTON_RECOVERY],
+
+#elif defined(CONFIG_VOLUME_BUTTONS)
+ &buttons[BUTTON_VOLUME_DOWN],
+ &buttons[BUTTON_VOLUME_UP],
+#endif /* defined(CONFIG_VOLUME_BUTTONS) */
+};
+const int recovery_buttons_count = ARRAY_SIZE(recovery_buttons);
+#endif /* defined(CONFIG_BUTTON_TRIGGERED_RECOVERY) */