summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Granata <egranata@chromium.org>2018-11-16 16:41:23 -0800
committerCommit Bot <commit-bot@chromium.org>2021-09-10 23:13:36 +0000
commiteb8f1c18f9f2962a2990d7258e0f972118134fa7 (patch)
tree6230996567817e93aa4a7371054f568218a9f08c
parent45ddfdd402f3997c2108c6c945bd497c9f863e81 (diff)
downloadchrome-ec-eb8f1c18f9f2962a2990d7258e0f972118134fa7.tar.gz
mkbp: Enable the EC to report whether it has more events on mkbp_get_next_event
On all platforms where there is a GPIO interrupt line between EC and AP for MKBP events, the EC will keep the interrupt pin set as long as there are events to be served, but the AP will need to re-enter its IRQ handler once per event in order to serve all the events in the FIFO. This commit adds a version 2 of EC_CMD_GET_NEXT_EVENT, such that the EC will use the most-significant bit of the event type to record the fact that the EC has more events available. This, in turn, enables the AP to keep its interrupt handler thread awake and loop until all events are served. Since it uses a new command version, this change is forward and backward compatible: - new EC, old kernel: the old kernel will use the V1 command and never see the flag - new kernel, old EC: the old EC will not accept the V2 command and never send the flag BUG=b:119570064,b:139001152 TEST=patched Linux kernel can see and use the flag on nocturne BRANCH=nocturne,rammus Signed-off-by: Enrico Granata <egranata@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1341159 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit fd6412f0ec89fd5570279d6081ae425107b3c9ea) Change-Id: I5bae7fdc85efcd26f7bdebcd31a7f27ecf570d88 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1776336 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r--common/mkbp_event.c4
-rw-r--r--include/ec_commands.h12
2 files changed, 15 insertions, 1 deletions
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index 44cec336b5..9dddcab519 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -164,6 +164,8 @@ static int mkbp_get_next_event(struct host_cmd_handler_args *args)
if (!events)
set_host_interrupt(0);
+ else if (args->version >= 2)
+ resp[0] |= EC_MKBP_HAS_MORE_EVENTS;
if (data_size < 0)
return EC_RES_ERROR;
@@ -173,7 +175,7 @@ static int mkbp_get_next_event(struct host_cmd_handler_args *args)
}
DECLARE_HOST_COMMAND(EC_CMD_GET_NEXT_EVENT,
mkbp_get_next_event,
- EC_VER_MASK(0) | EC_VER_MASK(1));
+ EC_VER_MASK(0) | EC_VER_MASK(1) | EC_VER_MASK(2));
#ifdef CONFIG_MKBP_WAKEUP_MASK
static int mkbp_get_wake_mask(struct host_cmd_handler_args *args)
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 6d99bb54a1..5f4c17ad0f 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -3315,6 +3315,17 @@ struct ec_result_keyscan_seq_ctrl {
*/
#define EC_CMD_GET_NEXT_EVENT 0x0067
+#define EC_MKBP_HAS_MORE_EVENTS_SHIFT 7
+
+/*
+ * We use the most significant bit of the event type to indicate to the host
+ * that the EC has more MKBP events available to provide.
+ */
+#define EC_MKBP_HAS_MORE_EVENTS (1 << EC_MKBP_HAS_MORE_EVENTS_SHIFT)
+
+/* The mask to apply to get the raw event type */
+#define EC_MKBP_EVENT_TYPE_MASK ((1 << EC_MKBP_HAS_MORE_EVENTS_SHIFT) - 1)
+
enum ec_mkbp_event {
/* Keyboard matrix changed. The event data is the new matrix state. */
EC_MKBP_EVENT_KEY_MATRIX = 0,
@@ -3355,6 +3366,7 @@ enum ec_mkbp_event {
/* Number of MKBP events */
EC_MKBP_EVENT_COUNT,
};
+BUILD_ASSERT(EC_MKBP_EVENT_COUNT <= EC_MKBP_EVENT_TYPE_MASK);
union __ec_align_offset1 ec_response_get_next_data {
uint8_t key_matrix[13];