diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2022-03-14 14:15:30 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-16 07:33:41 +0000 |
commit | a16de7acf4650571463019fa6cba1312e36161fa (patch) | |
tree | aa47d839321db84ec594366fd03fcc905d3521be | |
parent | 2cec5f70c986767c4a3f73504fd29e99fab22a71 (diff) | |
download | chrome-ec-a16de7acf4650571463019fa6cba1312e36161fa.tar.gz |
ectool: support dps enable/disable command
Support dps host command for factory test.
BUG=b:223937130
TEST=ectool usbpddps disable|enable
BRANCH=cherry
Change-Id: I050c724b5caab41644248a6f72704edbc76554a0
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3522247
Tested-by: Eric Yilun Lin <yllin@google.com>
Auto-Submit: Eric Yilun Lin <yllin@google.com>
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Queue: Rong Chang <rongchang@chromium.org>
(cherry picked from commit 00b93c2d75ee4b52e2a7f07230be2142a5dd486f)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3525639
Reviewed-by: Chen-Tsung Hsieh <chentsung@chromium.org>
Commit-Queue: Chen-Tsung Hsieh <chentsung@chromium.org>
Commit-Queue: Eric Yilun Lin <yllin@google.com>
-rw-r--r-- | common/dps.c | 12 | ||||
-rw-r--r-- | include/ec_commands.h | 9 | ||||
-rw-r--r-- | util/ectool.c | 34 |
3 files changed, 55 insertions, 0 deletions
diff --git a/common/dps.c b/common/dps.c index fe9bd33b97..b9fd40aebb 100644 --- a/common/dps.c +++ b/common/dps.c @@ -16,6 +16,7 @@ #include "charge_manager.h" #include "charge_state.h" #include "charge_state_v2.h" +#include "ec_commands.h" #include "math_util.h" #include "task.h" #include "timer.h" @@ -644,3 +645,14 @@ DECLARE_CONSOLE_COMMAND(dps, command_dps, "\t\t set(tstable|tcheck) <int>\n" "\t\t fakepwr [dis|<mV> <mA>]", "Print/set Dynamic PDO Selection state."); + +static enum ec_status hc_usb_pd_dps_control(struct host_cmd_handler_args *args) +{ + const struct ec_params_usb_pd_dps_control *p = args->params; + + dps_enable(p->enable); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_USB_PD_DPS_CONTROL, + hc_usb_pd_dps_control, + EC_VER_MASK(0)); diff --git a/include/ec_commands.h b/include/ec_commands.h index 652b491cd2..9b763e2f24 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -5666,6 +5666,15 @@ struct ec_response_charge_port_count { uint8_t port_count; } __ec_align1; +/* + * This command enable/disable dynamic PDO selection. + */ +#define EC_CMD_USB_PD_DPS_CONTROL 0x0106 + +struct ec_params_usb_pd_dps_control { + uint8_t enable; +} __ec_align1; + /* Write USB-PD device FW */ #define EC_CMD_USB_PD_FW_UPDATE 0x0110 diff --git a/util/ectool.c b/util/ectool.c index c6cc36d97d..563d14af12 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -337,6 +337,8 @@ const char help_str[] = "[toggle|toggle-off|sink|source] [none|usb|dp|dock] " "[dr_swap|pr_swap|vconn_swap]>\n" " Control USB PD/type-C [deprecated]\n" + " usbpddps [enable | disable]\n" + " Enable or disable dynamic pdo selection\n" " usbpdmuxinfo [tsv]\n" " Get USB-C SS mux info.\n" " tsv: Output as tab separated values. Columns are defined " @@ -6349,6 +6351,37 @@ int cmd_usb_pd(int argc, char *argv[]) return 0; } +int cmd_usb_pd_dps(int argc, char *argv[]) +{ + struct ec_params_usb_pd_dps_control p; + int rv; + + /* + * Set up requested flags. If no flags were specified, p.mask will + * be 0 and nothing will change. + */ + if (argc < 1) { + fprintf(stderr, "Usage: %s [enable|disable]\n", argv[0]); + return -1; + } + + if (!strcasecmp(argv[1], "enable")) { + p.enable = 1; + } else if (!strcasecmp(argv[1], "disable")) { + p.enable = 0; + } else { + fprintf(stderr, "Usage: %s [enable|disable]\n", argv[0]); + return -1; + } + + rv = ec_command(EC_CMD_USB_PD_DPS_CONTROL, 0, + &p, sizeof(p), NULL, 0); + if (rv < 0) + return rv; + + return 0; +} + static void print_pd_power_info(struct ec_response_usb_pd_power_info *r) { switch (r->role) { @@ -10598,6 +10631,7 @@ const struct command commands[] = { {"usbchargemode", cmd_usb_charge_set_mode}, {"usbmux", cmd_usb_mux}, {"usbpd", cmd_usb_pd}, + {"usbpddps", cmd_usb_pd_dps}, {"usbpdmuxinfo", cmd_usb_pd_mux_info}, {"usbpdpower", cmd_usb_pd_power}, {"version", cmd_version}, |