summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2019-06-26 09:50:59 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-23 17:57:15 +0000
commitdb3058dffca5e7659a301256ef8869fa7929092a (patch)
tree208cdd9d05b3a42634f4157c626f6ba582e94a69
parent95e5dace9113ab9021fc426aa56bf55e362e369c (diff)
downloadchrome-ec-db3058dffca5e7659a301256ef8869fa7929092a.tar.gz
Reland: 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. Old-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> (cherry picked from commit 167648267e5307b497ca64948f3bd79ac0327eb0) Change-Id: Ice26680c2f61ff35ea93b99226e2aa1acec856dd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1715390 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com> Tested-by: Wai-Hong Tam <waihong@google.com>
-rw-r--r--board/servo_v4/usb_pd_policy.c28
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");