summaryrefslogtreecommitdiff
path: root/common/mkbp_event.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2019-07-15 11:09:24 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-25 21:55:44 +0000
commit5645311fe86b4bf8ee1e2b0348aa98abef3f541a (patch)
tree6a030f428ca29d161fd6a0bd72dd573df32c69c8 /common/mkbp_event.c
parent286e3b9033c551f5fe24fe8c41de17b35bf27c81 (diff)
downloadchrome-ec-5645311fe86b4bf8ee1e2b0348aa98abef3f541a.tar.gz
ec_commands: Add EC_CMD_MKBP_WAKE_MASK.
This commit adds a new host command, EC_CMD_MKBP_WAKE_MASK which allows the host to retrieve and set the MKBP host event wake mask along with the MKBP event wake mask. An accompanying console command, `mkbpwakemask` is present as well to view and adjust the wake masks. In order to use this host command, one of the following EC CONFIG_* options must be enabled in the EC: CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK or CONFIG_MKBP_EVENT_WAKEUP_MASK. BUG=chromium:786721 BRANCH=None TEST=Deploy new version of ectool and EC firmware on nocturne, verify that ectool can view and adjust the wake masks. Verify that masks can be adjusted via the console command as well. Change-Id: I01a389ccd571328220eadd19ded4167dea8c6faa Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1700004 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/mkbp_event.c')
-rw-r--r--common/mkbp_event.c121
1 files changed, 119 insertions, 2 deletions
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index 8e05a17f17..90c1e90b76 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -68,6 +68,14 @@ struct mkbp_state {
static struct mkbp_state state;
uint32_t mkbp_last_event_time;
+#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK
+static uint32_t mkbp_event_wake_mask = CONFIG_MKBP_EVENT_WAKEUP_MASK;
+#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */
+
+#ifdef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
+static uint32_t mkbp_host_event_wake_mask = CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK;
+#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
+
#if defined(CONFIG_MKBP_USE_GPIO) || \
defined(CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT)
static int mkbp_set_host_active_via_gpio(int active, uint32_t *timestamp)
@@ -188,14 +196,14 @@ static void activate_mkbp_with_events(uint32_t events_to_add)
/* Check to see if this host event should wake the system. */
skip_interrupt = host_is_sleeping() &&
!(host_get_events() &
- CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK);
+ mkbp_host_event_wake_mask);
#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK
/* Check to see if this MKBP event should wake the system. */
if (!skip_interrupt)
skip_interrupt = host_is_sleeping() &&
- !(events_to_add & CONFIG_MKBP_EVENT_WAKEUP_MASK);
+ !(events_to_add & mkbp_event_wake_mask);
#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */
mutex_lock(&state.lock);
@@ -385,3 +393,112 @@ DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_WAKE_MASK,
EC_VER_MASK(0));
#endif /* CONFIG_MKBP_USE_HOST_EVENT */
#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
+
+static int hc_mkbp_wake_mask(struct host_cmd_handler_args *args)
+{
+ struct ec_response_mkbp_event_wake_mask *r = args->response;
+ const struct ec_params_mkbp_event_wake_mask *p = args->params;
+ enum ec_mkbp_event_mask_action action = p->action;
+
+ switch (action) {
+ case GET_WAKE_MASK:
+ switch (p->mask_type) {
+#ifdef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
+ case EC_MKBP_HOST_EVENT_WAKE_MASK:
+ r->wake_mask = mkbp_host_event_wake_mask;
+ break;
+#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
+
+#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK
+ case EC_MKBP_EVENT_WAKE_MASK:
+ r->wake_mask = mkbp_event_wake_mask;
+ break;
+#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */
+
+ default:
+ /* Unknown mask, or mask is not in use. */
+ CPRINTF("%s: mask_type=%d is unknown or not used.\n",
+ __func__, p->mask_type);
+ return EC_RES_INVALID_PARAM;
+ }
+
+ args->response_size = sizeof(*r);
+ break;
+
+ case SET_WAKE_MASK:
+ args->response_size = 0;
+
+ switch (p->mask_type) {
+#ifdef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
+ case EC_MKBP_HOST_EVENT_WAKE_MASK:
+ CPRINTF("MKBP hostevent mask updated to: 0x%08x "
+ "(was 0x%08x)\n",
+ p->new_wake_mask,
+ mkbp_host_event_wake_mask);
+ mkbp_host_event_wake_mask = p->new_wake_mask;
+ break;
+#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
+
+#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK
+ case EC_MKBP_EVENT_WAKE_MASK:
+ mkbp_event_wake_mask = p->new_wake_mask;
+ CPRINTF("MKBP event mask updated to: 0x%08x\n",
+ mkbp_event_wake_mask);
+ break;
+#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */
+
+ default:
+ /* Unknown mask, or mask is not in use. */
+ CPRINTF("%s: mask_type=%d is unknown or not used.\n",
+ __func__, p->mask_type);
+ return EC_RES_INVALID_PARAM;
+ }
+ break;
+
+ default:
+ return EC_RES_INVALID_PARAM;
+ }
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK,
+ hc_mkbp_wake_mask,
+ EC_VER_MASK(0));
+
+#if defined(CONFIG_MKBP_EVENT_WAKEUP_MASK) || \
+ defined(CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK)
+static int command_mkbp_wake_mask(int argc, char **argv)
+{
+ if (argc == 3) {
+ char *e;
+ uint32_t new_mask = strtoul(argv[2], &e, 0);
+
+ if (*e)
+ return EC_ERROR_PARAM2;
+
+#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK
+ if (strncmp(argv[1], "event", 5) == 0)
+ mkbp_event_wake_mask = new_mask;
+#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */
+
+#ifdef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
+ if (strncmp(argv[1], "hostevent", 9) == 0)
+ mkbp_host_event_wake_mask = new_mask;
+#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
+ } else if (argc != 1) {
+ return EC_ERROR_PARAM_COUNT;
+ }
+
+#ifdef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
+ ccprintf("MKBP host event wake mask: 0x%08x\n",
+ mkbp_host_event_wake_mask);
+#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
+#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK
+ ccprintf("MKBP event wake mask: 0x%08x\n", mkbp_event_wake_mask);
+#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(mkbpwakemask, command_mkbp_wake_mask,
+ "[event | hostevent] [new_mask]",
+ "Show or set MKBP event/hostevent wake mask");
+#endif /* CONFIG_MKBP_(HOST)?EVENT_WAKEUP_MASK */