summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-09-06 13:08:15 -0700
committerGerrit <chrome-bot@google.com>2012-09-09 11:45:11 -0700
commit39fd02c1286c838b8144f468addce60adf56ded1 (patch)
treebb5e02a7b4fb17db8c0b07816954e90665b41c68
parenta3d62a3700206b9cd34e129f6a04967bed5e46e4 (diff)
downloadchrome-ec-39fd02c1286c838b8144f468addce60adf56ded1.tar.gz
Check boot key combos if refresh key is held down
Instead of how it is now, where the boot key combinations are only tested if it was a keyboard-controlled reset. This is important for testing/debugging EC software sync, which has a tendancy to blow away your RW EC as soon as you flash a test EC and it reboots. Now you can hold down refresh+downarrow while flashing. This does not affect keyboard-controlled dev switching, since that's done in the AP after the EC boots. It also does not add any new key combos, just makes it possible to trigger the existing ones without a Silego reset. BUG=chrome-os-partner:13753 BRANCH=link TEST=manual 1. Boot normally. Works. 2. Power+Refresh. Boots normally. 3. Power+Refresh+Esc. Boots to recovery. 4. Power+Refresh+Down. EC reboots, system powers down. 5. Hold down Esc and reboot from EC console. Boots normally. 6. Hold down Refresh+Esc and reboot from EC console. Boots to recovery. Change-Id: Iabe4fd13589428a40b83f591ea679cbc6f83959d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/32425 Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--chip/lm4/keyboard_scan.c61
-rw-r--r--chip/lm4/power_button.c3
2 files changed, 42 insertions, 22 deletions
diff --git a/chip/lm4/keyboard_scan.c b/chip/lm4/keyboard_scan.c
index 3163724f41..a26a1fe116 100644
--- a/chip/lm4/keyboard_scan.c
+++ b/chip/lm4/keyboard_scan.c
@@ -258,6 +258,42 @@ static int check_key(int index, int mask)
return 1;
}
+/**
+ * Check what boot key is down, if any.
+ *
+ * @return the key which is down, or BOOT_KEY_OTHER if an unrecognized
+ * key combination is down or this isn't the right type of boot to look at
+ * boot keys.
+ */
+static enum boot_key keyboard_scan_check_boot_key(void)
+{
+ const struct boot_key_entry *k = boot_key_list;
+ int i;
+
+ /*
+ * If we jumped to this image, ignore boot keys. This prevents
+ * re-triggering events in RW firmware that were already processed by
+ * RO firmware.
+ */
+ if (system_jumped_to_this_image())
+ return BOOT_KEY_OTHER;
+
+ /* If reset was not caused by reset pin, refresh must be held down */
+ if (!(system_get_reset_flags() & RESET_FLAG_RESET_PIN) &&
+ !(raw_state[MASK_INDEX_REFRESH] & MASK_VALUE_REFRESH))
+ return BOOT_KEY_OTHER;
+
+ /* Check what single key is down */
+ for (i = 0; i < ARRAY_SIZE(boot_key_list); i++, k++) {
+ if (check_key(k->mask_index, k->mask_value)) {
+ CPRINTF("[%T KB boot key %d]\n", i);
+ return i;
+ }
+ }
+
+ return BOOT_KEY_OTHER;
+}
+
enum boot_key keyboard_scan_get_boot_key(void)
{
return boot_key_value;
@@ -290,27 +326,12 @@ int keyboard_scan_init(void)
/* Initialize raw state */
update_key_state();
- /*
- * If we're booting due to a reset-pin-caused reset, check what other
- * single key is held down (if any).
- */
- if ((system_get_reset_flags() & RESET_FLAG_RESET_PIN) &&
- !system_jumped_to_this_image()) {
- const struct boot_key_entry *k = boot_key_list;
- int i;
-
- for (i = 0; i < ARRAY_SIZE(boot_key_list); i++, k++) {
- if (check_key(k->mask_index, k->mask_value)) {
- CPRINTF("[%T KB boot key %d]\n", i);
- boot_key_value = i;
- break;
- }
- }
+ /* Check for keys held down at boot */
+ boot_key_value = keyboard_scan_check_boot_key();
- /* Trigger event if recovery key was pressed */
- if (boot_key_value == BOOT_KEY_ESC)
- host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY);
- }
+ /* Trigger event if recovery key was pressed */
+ if (boot_key_value == BOOT_KEY_ESC)
+ host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY);
return EC_SUCCESS;
}
diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c
index dd1712cb69..0da44db822 100644
--- a/chip/lm4/power_button.c
+++ b/chip/lm4/power_button.c
@@ -304,8 +304,7 @@ static void set_initial_pwrbtn_state(void)
CPRINTF("[%T PB init-jumped]\n");
}
} else if ((reset_flags & RESET_FLAG_AP_OFF) ||
- ((reset_flags & RESET_FLAG_RESET_PIN) &&
- keyboard_scan_get_boot_key() == BOOT_KEY_DOWN_ARROW)) {
+ (keyboard_scan_get_boot_key() == BOOT_KEY_DOWN_ARROW)) {
/*
* Reset triggered by keyboard-controlled reset, and down-arrow
* was held down. Or reset flags request AP off.