summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-06-29 18:17:19 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-30 20:14:01 -0700
commitadac37bf0c99e90ef4767681ba9f1a293cdae518 (patch)
treedada0ef9b80312f17b5f573eb125260f1d0cf68b
parent1457ea2155f118d2e4127babadcdc417ad966db2 (diff)
downloadchrome-ec-adac37bf0c99e90ef4767681ba9f1a293cdae518.tar.gz
keyboard_scan: Support boot key recognition with stuck KSI2
For certain board configurations, KSI2 will be stuck asserted for all scan columns if the power button is held. We must be aware of this case in order to correctly handle recovery mode key combinations. BUG=chrome-os-partner:54602 BRANCH=None TEST=Manual on gru. Do three-key salute, verify EC detects recovery mode. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I03d76e1121107484f79520745858388f6cae096c Reviewed-on: https://chromium-review.googlesource.com/357590 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/kevin/board.h1
-rw-r--r--common/keyboard_scan.c15
-rw-r--r--include/config.h7
-rw-r--r--include/keyboard_config.h1
4 files changed, 24 insertions, 0 deletions
diff --git a/board/kevin/board.h b/board/kevin/board.h
index dea839bb54..2dc334228a 100644
--- a/board/kevin/board.h
+++ b/board/kevin/board.h
@@ -45,6 +45,7 @@
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_COL2_INVERTED
#define CONFIG_KEYBOARD_PROTOCOL_MKBP /* Instead of 8042 protocol of keyboard */
+#define CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI2
#define CONFIG_LTO
#define CONFIG_POWER_BUTTON
#define CONFIG_VBOOT_HASH
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c
index 58fe77d677..73a6e6fdaf 100644
--- a/common/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -524,6 +524,21 @@ static int check_key(const uint8_t *state, int index, int mask)
allowed_mask[index] |= mask;
allowed_mask[KEYBOARD_COL_REFRESH] |= KEYBOARD_MASK_REFRESH;
+#ifdef CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI2
+ /*
+ * Check if KSI2 is asserted for all columns due to power button hold,
+ * and ignore it if so.
+ */
+ for (c = 0; c < KEYBOARD_COLS; c++)
+ if ((keyscan_config.actual_key_mask[c] & KEYBOARD_MASK_KSI2) &&
+ !(state[c] & KEYBOARD_MASK_KSI2))
+ break;
+
+ if (c == KEYBOARD_COLS)
+ for (c = 0; c < KEYBOARD_COLS; c++)
+ allowed_mask[c] |= KEYBOARD_MASK_KSI2;
+#endif
+
for (c = 0; c < KEYBOARD_COLS; c++) {
if (state[c] & ~allowed_mask[c])
return 0; /* Disallowed key pressed */
diff --git a/include/config.h b/include/config.h
index 2db396f0a2..7595c796a1 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1227,6 +1227,13 @@
*/
#define CONFIG_KEYBOARD_KSO_BASE 0
+/*
+ * For certain board configurations, KSI2 will be stuck asserted for all
+ * scan columns if the power button is held. We must be aware of this case
+ * in order to correctly handle recovery mode key combinations.
+ */
+#undef CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI2
+
/* Enable extra debugging output from keyboard modules */
#undef CONFIG_KEYBOARD_DEBUG
diff --git a/include/keyboard_config.h b/include/keyboard_config.h
index 286b6d7560..6cb1b53a52 100644
--- a/include/keyboard_config.h
+++ b/include/keyboard_config.h
@@ -59,5 +59,6 @@
#define KEYBOARD_COL_KEY_2 4
#define KEYBOARD_ROW_KEY_2 6
#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2)
+#define KEYBOARD_MASK_KSI2 KEYBOARD_ROW_TO_MASK(2)
#endif /* __CROS_EC_KEYBOARD_CONFIG_H */