From a240040cbf59c743d762b2c6a2eae1421840a66e Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 9 Mar 2017 14:26:48 -0800 Subject: servo_v4: Set desired data role for DUT port to UFP The default for servo_v4 DUT port is to be SRC to charge the DUT, but a UFP data role so that the DUT's usb mux gets connected. BUG=b:35586526 BRANCH=servo TEST=Connect to Electro and verify that servo_v4 data role is that of UFP and that electro is getting an IP address from the enet port on servo_v4. Change-Id: I8f2e4242777bf879598852004096f683d68c091c Signed-off-by: Scott Reviewed-on: https://chromium-review.googlesource.com/452725 Commit-Ready: Scott Collyer Tested-by: Scott Collyer Reviewed-by: Vincent Palatin --- board/servo_v4/usb_pd_policy.c | 21 +++++++++++---------- common/usb_pd_protocol.c | 2 ++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c index b6c395a860..3268b343fd 100644 --- a/board/servo_v4/usb_pd_policy.c +++ b/board/servo_v4/usb_pd_policy.c @@ -326,10 +326,11 @@ int pd_board_checks(void) int pd_check_power_swap(int port) { /* - * TODO(crosbug.com/p/60792): CHG port can't do a power swap as it's SNK - * only. Don't allow DUT port to accept a power role swap request. More - * support still needs to be added so that servo_v4 DUT port behaves - * properly when acting as a SNK device. + * When only host VBUS is available, then servo_v4 is not setting + * PDO_FIXED_EXTERNAL in the src_pdo sent to the DUT. When this bit is + * not set, the DUT will always attempt to swap its power role to + * SRC. Let servo_v4 have more control over its power role by always + * rejecting power swap requests from the DUT. */ return 0; } @@ -357,12 +358,12 @@ void pd_check_pr_role(int port, int pr_role, int flags) void pd_check_dr_role(int port, int dr_role, int flags) { - /* - * TODO(crosbug.com/p/60792): CHG port is SNK only and should not need - * to change from default UFP role. DUT port behavior needs to be - * flushed out. Don't request any data role change for either port for - * now. - */ + if (port == CHG) + return; + + /* If DFP, try to switch to UFP */ + if ((flags & PD_FLAGS_PARTNER_DR_DATA) && dr_role == PD_ROLE_DFP) + pd_request_data_swap(port); } diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 1447dccc71..2986e84843 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1962,6 +1962,8 @@ void pd_task(void) /* Enable TCPC RX */ if (pd_comm_is_enabled(port)) tcpm_set_rx_enable(port, 1); + pd[port].flags |= + PD_FLAGS_CHECK_DR_ROLE; hard_reset_count = 0; timeout = 10*MSEC; set_state(port, PD_STATE_SRC_STARTUP); -- cgit v1.2.1