diff options
author | Diana Z <dzigterman@chromium.org> | 2020-09-25 14:45:14 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-05 18:11:43 +0000 |
commit | 1efa0109d3a12ac00ef958744ba17bfebdceee9a (patch) | |
tree | af47fd909fa9c62431348cb4ccca38608d57dc1c | |
parent | a44234c5f3741e4849809e1b57b0b2f007549769 (diff) | |
download | chrome-ec-1efa0109d3a12ac00ef958744ba17bfebdceee9a.tar.gz |
TCPMv2: Add event clear to TYPEC_CONTROL
When the AP has finished processing events, it can use TYPEC_CONTROL to
clear the specific events it has completed. This also fixes an issue
with the control command structure byte alignment.
BRANCH=None
BUG=b:148816435
TEST=on waddledoo, plug in Apple dongle and clear SOP discovery event
with "ectool typecontrol"
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I38d522f346bfd500b72109db46f78a9c135ce96e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432457
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/usbc/usb_pd_host.c | 3 | ||||
-rw-r--r-- | include/ec_commands.h | 6 | ||||
-rw-r--r-- | util/ectool.c | 18 |
3 files changed, 24 insertions, 3 deletions
diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c index be9a1c81aa..61c1c69966 100644 --- a/common/usbc/usb_pd_host.c +++ b/common/usbc/usb_pd_host.c @@ -108,6 +108,9 @@ static enum ec_status hc_typec_control(struct host_cmd_handler_args *args) case TYPEC_CONTROL_COMMAND_EXIT_MODES: pd_dpm_request(p->port, DPM_REQUEST_EXIT_MODES); break; + case TYPEC_CONTROL_COMMAND_CLEAR_EVENTS: + pd_clear_events(p->port, p->clear_events_mask); + break; default: return EC_RES_INVALID_PARAM; } diff --git a/include/ec_commands.h b/include/ec_commands.h index 8286f22c0d..555d5a954d 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -6368,17 +6368,21 @@ struct ec_response_typec_discovery { enum typec_control_command { TYPEC_CONTROL_COMMAND_EXIT_MODES, + TYPEC_CONTROL_COMMAND_CLEAR_EVENTS, }; struct ec_params_typec_control { uint8_t port; - enum typec_control_command command; + uint8_t command; /* enum typec_control_command */ + uint16_t reserved; + /* * This section will be interpreted based on |command|. Define a * placeholder structure to avoid having to increase the size and bump * the command version when adding new sub-commands. */ union { + uint32_t clear_events_mask; uint8_t placeholder[128]; }; } __ec_align1; diff --git a/util/ectool.c b/util/ectool.c index 770c94e2e0..04e630051c 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -9475,10 +9475,11 @@ int cmd_typec_control(int argc, char *argv[]) if (argc < 3) { fprintf(stderr, - "Usage: %s <port> <command>\n" + "Usage: %s <port> <command> [args]\n" " <port> is the type-c port to query\n" " <type> is one of:\n" - " 0: Exit modes\n", argv[0]); + " 0: Exit modes\n" + " 1: Clear events\n", argv[0]); return -1; } @@ -9494,6 +9495,19 @@ int cmd_typec_control(int argc, char *argv[]) return -1; } + if (p.command == TYPEC_CONTROL_COMMAND_CLEAR_EVENTS) { + if (argc < 4) { + fprintf(stderr, "Missing event mask\n"); + return -1; + } + + p.clear_events_mask = strtol(argv[3], &endptr, 0); + if (endptr && *endptr) { + fprintf(stderr, "Bad event mask\n"); + return -1; + } + } + rv = ec_command(EC_CMD_TYPEC_CONTROL, 0, &p, sizeof(p), ec_inbuf, ec_max_insize); if (rv < 0) |