summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-06-15 15:07:30 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-06-23 22:56:49 -0700
commit92b7baff54aba25610a9b847037a3a41109ebce8 (patch)
tree3e2f93815cd0a0abcbe5c71a354e7dc8e07f9610 /common
parent7632f7c4ee958706a868b588985877a77976fd59 (diff)
downloadchrome-ec-92b7baff54aba25610a9b847037a3a41109ebce8.tar.gz
system: Add simplified sysrq
On a keyboard-less, volume-button-less board, we support simplified sysrq handling. For Fizz, we use the recovery button to trigger sysrq event and holding it down to trigger warm reset. BUG=b:38418116,b:38417391 BRANCH=none TEST=On Fizz, try 1. Press recovery button and release -> sysrq sent 2. Press and hold recovery button -> warm reset 3. Press recovery button and power button -> enter recovery mode Change-Id: If8760319dba3df4545e9805b396ac89c241dae80 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/537817 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/button.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/common/button.c b/common/button.c
index fc1b45167a..9ed2e015ce 100644
--- a/common/button.c
+++ b/common/button.c
@@ -292,6 +292,8 @@ static int console_command_button(int argc, char **argv)
button = button_present(KEYBOARD_BUTTON_VOLUME_UP);
else if (!strcasecmp(argv[1], "vdown"))
button = button_present(KEYBOARD_BUTTON_VOLUME_DOWN);
+ else if (!strcasecmp(argv[1], "rec"))
+ button = button_present(KEYBOARD_BUTTON_RECOVERY);
else
return EC_ERROR_PARAM1;
@@ -329,6 +331,44 @@ DECLARE_CONSOLE_COMMAND(button, console_command_button,
#ifdef CONFIG_EMULATED_SYSRQ
+#ifdef CONFIG_DEDICATED_RECOVERY_BUTTON
+
+/*
+ * Simplified sysrq handler
+ *
+ * In simplified sysrq, user can
+ * - press and release recovery button to send one sysrq event to the host
+ * - press and hold recovery button for 4 seconds to reset the AP (warm reset)
+ */
+static void debug_mode_handle(void)
+{
+ static int recovery_button_pressed = 0;
+
+ if (!recovery_button_pressed) {
+ if (is_recovery_button_pressed()) {
+ /* User pressed recovery button. Wait for 4 seconds
+ * to see if warm reset is requested. */
+ recovery_button_pressed = 1;
+ hook_call_deferred(&debug_mode_handle_data, 4 * SECOND);
+ }
+ } else {
+ /* We come here when recovery button is released or when
+ * 4 sec elapsed with recovery button still pressed. */
+ if (!is_recovery_button_pressed()) {
+ /* Cancel pending timer */
+ hook_call_deferred(&debug_mode_handle_data, -1);
+ host_send_sysrq('x');
+ CPRINTS("DEBUG MODE: sysrq-x sent");
+ } else {
+ chipset_reset(0);
+ CPRINTS("DEBUG MODE: Warm reset triggered");
+ }
+ recovery_button_pressed = 0;
+ }
+}
+
+#else /* CONFIG_DEDICATED_RECOVERY_BUTTON */
+
enum debug_state {
STATE_DEBUG_NONE,
STATE_DEBUG_CHECK,
@@ -616,4 +656,5 @@ static void debug_led_tick(void)
DECLARE_HOOK(HOOK_TICK, debug_led_tick, HOOK_PRIO_DEFAULT);
#endif /* CONFIG_LED_COMMON */
+#endif /* !CONFIG_DEDICATED_RECOVERY_BUTTON */
#endif /* CONFIG_EMULATED_SYSRQ */