From f5b3c81b0a84d9e6d7cf26eb4c70da19ce9639bf Mon Sep 17 00:00:00 2001 From: Diana Z Date: Fri, 25 Sep 2020 14:56:35 -0600 Subject: Ectool: Support printing typec status on older boards When boards don't have the new TYPEC_STATUS host command running, fallback to the older USB_PD_CONTROL command to display information. BRANCH=None BUG=None TEST=on waddledoo with no TYPEC_STATUS command present, ensure that "ectool typecstatus " prints port information Signed-off-by: Diana Z Change-Id: I78fbc0414c0c6cb73b91285b6900a34287cdf5dd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432458 Reviewed-by: Abe Levkoy --- util/ectool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'util/ectool.c') diff --git a/util/ectool.c b/util/ectool.c index 04e630051c..6d2a74d94e 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -9583,7 +9583,7 @@ int cmd_typec_status(int argc, char *argv[]) int rv; char *desc; - if (argc < 2) { + if (argc != 2) { fprintf(stderr, "Usage: %s \n" " is the type-c port to query\n", argv[0]); @@ -9598,7 +9598,10 @@ int cmd_typec_status(int argc, char *argv[]) rv = ec_command(EC_CMD_TYPEC_STATUS, 0, &p, sizeof(p), ec_inbuf, ec_max_insize); - if (rv < 0) + if (rv == -EC_RES_INVALID_COMMAND - EECRESULT) + /* Fall back to PD_CONTROL to support older ECs */ + return cmd_usb_pd(argc, argv); + else if (rv < 0) return -1; printf("Port C%d: %s, %s State:%s\n" -- cgit v1.2.1