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>
This commit is contained in:
Daisuke Nojiri
2017-06-15 15:07:30 -07:00
committed by chrome-bot
parent 7632f7c4ee
commit 92b7baff54
4 changed files with 51 additions and 1 deletions

View File

@@ -19,6 +19,10 @@
#define CONFIG_BOARD_VERSION
#define CONFIG_BUTTON_COUNT 1
#define CONFIG_BUTTON_RECOVERY
#define CONFIG_DEDICATED_RECOVERY_BUTTON
#define CONFIG_EMULATED_SYSRQ
#define CONFIG_KEYBOARD_PROTOCOL_MKBP
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_CASE_CLOSED_DEBUG_EXTERNAL
#define CONFIG_DPTF
#define CONFIG_FLASH_SIZE 0x80000

View File

@@ -23,6 +23,7 @@ GPIO_INT(RSMRST_L_PGOOD, PIN(B, 0), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(PMIC_DPWROK, PIN(C, 7), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(WP_L, PIN(9, 3), GPIO_INT_BOTH, switch_interrupt)
GPIO_INT(USB_C0_VBUS_WAKE_L, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, vbus0_evt)
GPIO_INT(RECOVERY_L, PIN(8, 2), GPIO_INT_BOTH, button_interrupt) /* Recovery button */
GPIO(PCH_RTCRST, PIN(E, 7), GPIO_OUT_LOW) /* RTCRST# to SOC */
GPIO(WLAN_OFF_L, PIN(7, 2), GPIO_OUT_LOW) /* Disable WLAN */
GPIO(PP3300_DX_WLAN, PIN(A, 7), GPIO_OUT_LOW) /* Enable WLAN 3.3V Power */
@@ -42,7 +43,6 @@ GPIO(PMIC_INT_L, PIN(6, 0), GPIO_INPUT) /* PMIC interrupt */
/* Fizz specific pins */
GPIO(LAN_PWR_EN, PIN(8, 3), GPIO_OUT_HIGH) /* Ethernet power enabled */
GPIO(RECOVERY_L, PIN(8, 2), GPIO_INPUT) /* Recovery button */
GPIO(PWR_RED_LED, PIN(8, 0), GPIO_OUT_HIGH) /* Power Red LED */
GPIO(PWR_GRN_LED, PIN(B, 7), GPIO_OUT_HIGH) /* Power Green LED */

View File

@@ -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 */

View File

@@ -371,6 +371,11 @@
*/
#undef CONFIG_BUTTON_RECOVERY
/*
* Indicates there is a dedicated recovery button.
*/
#undef CONFIG_DEDICATED_RECOVERY_BUTTON
/*
* Enable case close debug (CCD) mode in the EC.
*/