summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-10-20 23:31:28 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-24 01:37:58 +0000
commitd1ed75815efe513449c653d28fe7bd3c53a3441d (patch)
tree48a256c4154ad8f195ef5447abce6eeb99e3fd42 /include
parentbe2ed33b1976e407d107b20e90441a194f7b5fb7 (diff)
downloadchrome-ec-d1ed75815efe513449c653d28fe7bd3c53a3441d.tar.gz
MKBP event signalling implementation
This implements a new API for EC modules to define MKBP event sources and send MKBP event to the AP. Also, a new host command EC_CMD_GET_NEXT_EVENT is added for the AP to query the pending MKBP events. Each event type may have custom event data sent along with the event. BRANCH=None BUG=chrome-os-partner:33194 TEST=Enable MKBP event on Ryu. Set a host event from EC console, run 'ectool nextevent', and see MKBP event 0x01 (HOST_EVENT) and the set host event. Signed-off-by: Vic Yang <victoryang@chromium.org> Change-Id: I28a1b7e826bcc102bbe39016c9bb3e37d125664c Reviewed-on: https://chromium-review.googlesource.com/224905 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/config.h3
-rw-r--r--include/ec_commands.h23
-rw-r--r--include/link_defs.h5
-rw-r--r--include/mkbp_event.h37
4 files changed, 68 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h
index e6c0aa8583..7f637423d8 100644
--- a/include/config.h
+++ b/include/config.h
@@ -751,6 +751,9 @@
/* Support LPC interface */
#undef CONFIG_LPC
+/* Support MKBP event */
+#undef CONFIG_MKBP_EVENT
+
/* Support memory protection unit (MPU) */
#undef CONFIG_MPU
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 3675dfa6d9..3cea697cf9 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1811,6 +1811,29 @@ struct ec_result_keyscan_seq_ctrl {
};
} __packed;
+/*
+ * Get the next pending MKBP event.
+ *
+ * Returns EC_RES_UNAVAILABLE if there is no event pending.
+ */
+#define EC_CMD_GET_NEXT_EVENT 0x67
+
+enum ec_mkbp_event {
+ /* Keyboard matrix changed. The event data is the new matrix state. */
+ EC_MKBP_EVENT_KEY_MATRIX = 0,
+
+ /* New host event. The event data is 4 bytes of host event flags. */
+ EC_MKBP_EVENT_HOST_EVENT = 1,
+
+ /* Number of MKBP events */
+ EC_MKBP_EVENT_COUNT,
+};
+
+struct ec_response_get_next_event {
+ uint8_t event_type;
+ /* Followed by event data if any */
+} __packed;
+
/*****************************************************************************/
/* Temperature sensor commands */
diff --git a/include/link_defs.h b/include/link_defs.h
index 0aab55befe..67ae9779d2 100644
--- a/include/link_defs.h
+++ b/include/link_defs.h
@@ -11,6 +11,7 @@
#include "console.h"
#include "hooks.h"
#include "host_command.h"
+#include "mkbp_event.h"
#include "task.h"
#include "test_util.h"
@@ -75,6 +76,10 @@ extern const struct test_i2c_read_string_dev __test_i2c_read_string_end[];
extern const struct host_command __hcmds[];
extern const struct host_command __hcmds_end[];
+/* MKBP events */
+extern const struct mkbp_event_source __mkbp_evt_srcs[];
+extern const struct mkbp_event_source __mkbp_evt_srcs_end[];
+
/* IRQs (interrupt handlers) */
extern const struct irq_priority __irqprio[];
extern const struct irq_priority __irqprio_end[];
diff --git a/include/mkbp_event.h b/include/mkbp_event.h
new file mode 100644
index 0000000000..8da19fc02d
--- /dev/null
+++ b/include/mkbp_event.h
@@ -0,0 +1,37 @@
+/* Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Event handling in MKBP keyboard protocol
+ */
+
+#ifndef __CROS_EC_MKBP_EVENT_H
+#define __CROS_EC_MKBP_EVENT_H
+
+/*
+ * Sends an event to the AP.
+ *
+ * When this is called, the event data must be ready for query. Otherwise,
+ * when the AP queries the event, an error is returned and the event is lost.
+ *
+ * @param event_type One of EC_MKBP_EVENT_*.
+ */
+void mkbp_send_event(uint8_t event_type);
+
+/*
+ * The struct to store the event source definition. The get_data routine is
+ * responsible for returning the event data when queried by the AP. The
+ * parameter 'data' points to where the event data needs to be stored, and
+ * the size of the event data should be returned.
+ */
+struct mkbp_event_source {
+ uint8_t event_type;
+ int (*get_data)(uint8_t *data);
+};
+
+#define DECLARE_EVENT_SOURCE(type, func) \
+ const struct mkbp_event_source __evt_src_##type \
+ __attribute__((section(".rodata.evtsrcs"))) \
+ = {type, func}
+
+#endif /* __CROS_EC_MKBP_EVENT_H */