diff options
author | Wai-Hong Tam <waihong@google.com> | 2019-06-26 09:50:59 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-22 23:07:23 +0000 |
commit | f3b9617bdbac366b5377856f3137e57129f8e1ef (patch) | |
tree | a31716ee42b67e7d8bf874953d3237beed0f8d88 | |
parent | 71a51e7b9070ab04c6506669806a32a8ceedd78c (diff) | |
download | chrome-ec-f3b9617bdbac366b5377856f3137e57129f8e1ef.tar.gz |
servo_v4: Support command to limit the max_voltage
firmware_PDVbusRequest forces servo v4 to different max_voltage
limits to verify the PD negotiation. Add the firmware support for it.
The console command usbc_action is the same as Plankton. So the test
side doesn't need any change.
BRANCH=servo
BUG=b:134700685
TEST=Tried usbc_action command and ran firmware_PDVbusRequest passed.
Change-Id: I5f05d73d9a2f92fe26514285e7c251e9fa27aba8
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1686221
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | board/servo_v4/usb_pd_policy.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c index b4746628f9..b09803b839 100644 --- a/board/servo_v4/usb_pd_policy.c +++ b/board/servo_v4/usb_pd_policy.c @@ -131,10 +131,15 @@ static int cc_pull_stored = TYPEC_CC_RD; */ #define MAX_MV_RED_BLUE 9000 +static int user_limited_max_mv = 20000; + static uint32_t max_supported_voltage(void) { - return board_get_version() >= BOARD_VERSION_BLACK ? + int board_max_mv = board_get_version() >= BOARD_VERSION_BLACK ? PD_MAX_VOLTAGE_MV : MAX_MV_RED_BLUE; + + return board_max_mv < user_limited_max_mv ? board_max_mv : + user_limited_max_mv; } static int charge_port_is_active(void) @@ -241,6 +246,7 @@ static void update_ports(void) if (pd_src_voltages_mv[i] > max_supported_voltage()) break; + /* Find the 'best' PDO <= voltage */ pdo_index = pd_find_pdo_index( CHG, pd_src_voltages_mv[i], &pdo); @@ -913,7 +919,23 @@ static int cmd_usbc_action(int argc, char *argv[]) if (argc != 2) return EC_ERROR_PARAM_COUNT; - if (!strcasecmp(argv[1], "drp")) { + if (!strcasecmp(argv[1], "5v")) { + do_cc(CONFIG_SRC(cc_config)); + user_limited_max_mv = 5000; + update_ports(); + } else if (!strcasecmp(argv[1], "12v")) { + do_cc(CONFIG_SRC(cc_config)); + user_limited_max_mv = 12000; + update_ports(); + } else if (!strcasecmp(argv[1], "20v")) { + do_cc(CONFIG_SRC(cc_config)); + user_limited_max_mv = 20000; + update_ports(); + } else if (!strcasecmp(argv[1], "dev")) { + /* Set the limit back to original */ + user_limited_max_mv = 20000; + do_cc(CONFIG_PDSNK(cc_config)); + } else if (!strcasecmp(argv[1], "drp")) { /* Toggle the DRP state, compatible with Plankton. */ do_cc(cc_config ^ CC_ENABLE_DRP); CPRINTF("DRP = %d, host_mode = %d\n", @@ -926,5 +948,5 @@ static int cmd_usbc_action(int argc, char *argv[]) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(usbc_action, cmd_usbc_action, - "<drp>", + "5v|12v|20v|dev|drp", "Set Servo v4 type-C port state"); |