diff options
author | Todd Broch <tbroch@chromium.org> | 2014-09-08 17:18:42 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-11 20:00:12 +0000 |
commit | f5b7b3242349aeabe55779541f34133681a96193 (patch) | |
tree | 91734c93fbfa7eb2976d5c59447925c59b51ac5d /util | |
parent | 7698c323eae7da62890a7d01447894629d29b22b (diff) | |
download | chrome-ec-f5b7b3242349aeabe55779541f34133681a96193.tar.gz |
samus: enhance usbpd host command to return port status.
CL provides some useful information similar to the EC console command
'pd state <port>' when host command 'usbpd <port>' is sent from host
with no additional arguments.
Also added a few build asserts for role & mux strings.
BRANCH=none
BUG=chrome-os-partner:31690
TEST=manual
ectool --interface=lpc --dev=1 usbpd 1
Port C1 is enabled. Role:SNK Polarity:CC1 State:6
# has zinger attached
ectool --interface=lpc --dev=1 usbpd 0
Port C0 is enabled. Role:SNK Polarity:CC1 State:2
Change-Id: Id44eb7bf6a6fcfa888a0008a2249601967c50bcc
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217138
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/util/ectool.c b/util/ectool.c index 822a418260..e816a7828b 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -23,6 +23,7 @@ #include "misc_util.h" #include "panic.h" #include "sha1.h" +#include "usb_pd.h" /* Command line options */ enum { @@ -2621,17 +2622,21 @@ int cmd_usb_mux(int argc, char *argv[]) int cmd_usb_pd(int argc, char *argv[]) { const char *role_str[] = {"", "toggle", "toggle-off", "sink", "source"}; - const char *mux_str[] = {"", "none", "usb", "dp", "dock"}; + const char *mux_str[] = {"", "none", "usb", "dp", "dock", "auto"}; struct ec_params_usb_pd_control p; + struct ec_response_usb_pd_control *r = + (struct ec_response_usb_pd_control *)ec_inbuf; int rv, i, j; int option_ok; char *e; + BUILD_ASSERT(ARRAY_SIZE(role_str) == USB_PD_CTRL_ROLE_COUNT); + BUILD_ASSERT(ARRAY_SIZE(mux_str) == USB_PD_CTRL_MUX_COUNT); p.role = USB_PD_CTRL_ROLE_NO_CHANGE; p.mux = USB_PD_CTRL_MUX_NO_CHANGE; - if (argc <= 2) { - fprintf(stderr, "No option specified.\n"); + if (argc < 2) { + fprintf(stderr, "No port specified.\n"); return -1; } @@ -2688,7 +2693,14 @@ int cmd_usb_pd(int argc, char *argv[]) } } - rv = ec_command(EC_CMD_USB_PD_CONTROL, 0, &p, sizeof(p), NULL, 0); + rv = ec_command(EC_CMD_USB_PD_CONTROL, 0, &p, sizeof(p), + ec_inbuf, ec_max_insize); + + if ((rv >= 0) && (argc == 2)) + printf("Port C%d is %sabled, Role:%s Polarity:CC%d State:%d\n", + p.port, (r->enabled) ? "en" : "dis", + r->role == PD_ROLE_SOURCE ? "SRC" : "SNK", + r->polarity + 1, r->state); return (rv < 0 ? rv : 0); } |