summaryrefslogtreecommitdiff
path: root/util
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 /util
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 'util')
-rw-r--r--util/ectool.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 46f98be760..f1e7758dc6 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -188,6 +188,8 @@ const char help_str[] =
" Set the color of an LED or query brightness range\n"
" lightbar [CMDS]\n"
" Various lightbar control commands\n"
+ " mkbpwakemask <get|set> <event|hostevent> [mask]\n"
+ " Get or Set the MKBP event wake mask, or host event wake mask\n"
" motionsense [CMDS]\n"
" Various motion sense control commands\n"
" panicinfo\n"
@@ -7718,6 +7720,75 @@ static int cmd_keyconfig(int argc, char *argv[])
return 0;
}
+static int cmd_mkbp_wake_mask(int argc, char *argv[])
+{
+ struct ec_params_mkbp_event_wake_mask p;
+ struct ec_response_mkbp_event_wake_mask r;
+ int rv;
+
+ if (argc < 3) {
+ fprintf(stderr, "Usage: %s get <event|hostevent>\n"
+ "\t%s set <event|hostevent> <mask>\n", argv[0],
+ argv[0]);
+ return -1;
+ }
+
+ /* Determine if the user want to get or set the wake mask. */
+ if (strncmp(argv[1], "get", 3) == 0) {
+ p.action = GET_WAKE_MASK;
+ } else if (strncmp(argv[1], "set", 3) == 0) {
+ p.action = SET_WAKE_MASK;
+ } else {
+ fprintf(stderr, "Invalid param: '%s'\n", argv[1]);
+ return -1;
+ }
+
+ /* Determine which mask is of interest. */
+ if (strncmp(argv[2], "event", 5) == 0) {
+ p.mask_type = EC_MKBP_EVENT_WAKE_MASK;
+ } else if (strncmp(argv[2], "hostevent", 9) == 0) {
+ p.mask_type = EC_MKBP_HOST_EVENT_WAKE_MASK;
+ } else {
+ fprintf(stderr, "Invalid param: '%s'\n", argv[2]);
+ return -1;
+ }
+
+ if (p.action == SET_WAKE_MASK) {
+ char *e;
+
+ if (argc < 4) {
+ fprintf(stderr, "Missing mask value!");
+ return -1;
+ }
+
+ p.new_wake_mask = strtol(argv[3], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad mask: '%s'", argv[1]);
+ return -1;
+ }
+ }
+
+ rv = ec_command(EC_CMD_MKBP_WAKE_MASK, 0, &p, sizeof(p), &r,
+ sizeof(r));
+ if (rv < 0) {
+ if (rv == -EECRESULT-EC_RES_INVALID_PARAM) {
+ fprintf(stderr, "Unknown mask, or mask is not in use. "
+ "You may need to enable the "
+ "CONFIG_MKBP_%s_WAKEUP_MASK option in the EC.\n"
+ , p.mask_type == EC_MKBP_EVENT_WAKE_MASK ?
+ "EVENT" : "HOSTEVENT");
+ }
+ return rv;
+ }
+
+ if (p.action == GET_WAKE_MASK)
+ printf("MBKP %s wake mask: 0x%08x\n", argv[2], r.wake_mask);
+ else if (p.action == SET_WAKE_MASK)
+ printf("MKBP %s wake mask set.\n", argv[2]);
+
+ return 0;
+}
+
/* Index is already checked. argv[0] is first param value */
static int cmd_tmp006cal_v0(int idx, int argc, char *argv[])
{
@@ -8736,6 +8807,7 @@ const struct command commands[] = {
{"kbpress", cmd_kbpress},
{"keyconfig", cmd_keyconfig},
{"keyscan", cmd_keyscan},
+ {"mkbpwakemask", cmd_mkbp_wake_mask},
{"motionsense", cmd_motionsense},
{"nextevent", cmd_next_event},
{"panicinfo", cmd_panic_info},