summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2020-03-16 17:40:20 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-18 03:00:14 +0000
commite2521fe6b22c6b267c453b9a02b036f51baaf95f (patch)
tree7e7d882251f3fe6d07177e6dbf64c29955c4536a
parent5fbedbfeda018901403be523eaaffa947b161fa7 (diff)
downloadchrome-ec-e2521fe6b22c6b267c453b9a02b036f51baaf95f.tar.gz
TCPMv1: Cleanup: Set initial data role based on power role
Set initial data role of the PD based on the current power role. - Initial data role for sink is UFP - Initial data role for source is DFP Reference: USB Type-C cable and connector specification, Release 2.0 2.3.3 Initial Power (Source-to-Sink) Detection and Establishing the Data (Host-to-Device) Relationship Once initial connection is established, the Source supplies VBUS and behaves as a DFP, and the Sink consumes VBUS and behaves as a UFP. USB PD, when supported by both ports, may then be used to independently swap both the power and data roles of the ports. BUG=b:151653348 BRANCH=none TEST=make buildall -j Change-Id: I69e01f5b98a656394d61ee6cf657ea63a570abd8 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2106944 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Divya S Sasidharan <divya.s.sasidharan@intel.com>
-rw-r--r--common/usb_pd_protocol.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index bd3585d8fe..82e0a1e0e4 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1287,7 +1287,7 @@ bool pd_is_disconnected(int port)
;
}
-static void pd_set_data_role(int port, int role)
+static void pd_set_data_role(int port, enum pd_data_role role)
{
pd[port].data_role = role;
#ifdef CONFIG_USB_PD_DUAL_ROLE
@@ -1358,9 +1358,10 @@ void pd_execute_hard_reset(int port)
pd_power_supply_reset(port);
}
- /* Set initial data role (matching power role) */
- pd_set_data_role(port, pd[port].power_role);
if (pd[port].power_role == PD_ROLE_SINK) {
+ /* Initial data role for sink is UFP */
+ pd_set_data_role(port, PD_ROLE_UFP);
+
/* Clear the input current limit */
pd_set_input_current_limit(port, 0, 0);
#ifdef CONFIG_CHARGE_MANAGER
@@ -1382,7 +1383,11 @@ void pd_execute_hard_reset(int port)
set_state(port, PD_STATE_SNK_HARD_RESET_RECOVER);
return;
+ } else {
+ /* Initial data role for source is DFP */
+ pd_set_data_role(port, PD_ROLE_DFP);
}
+
#endif /* CONFIG_USB_PD_DUAL_ROLE */
if (!hard_rst_tx)