summaryrefslogtreecommitdiff
path: root/common/usb_pd_protocol.c
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-06-12 15:21:06 -0700
committerCommit Bot <commit-bot@chromium.org>2020-06-16 19:38:10 +0000
commit818c57442ae1d4d52b7ad9aa2a9d800075d2b055 (patch)
tree4c08bbdf6aa721a1197386ad9001980eb717a829 /common/usb_pd_protocol.c
parent2264f108f13885317445c837c0b1cfdbc867acfc (diff)
downloadchrome-ec-818c57442ae1d4d52b7ad9aa2a9d800075d2b055.tar.gz
usb_pd: TCPMv1: Enable VCONN swap at explicit contract
According to Section 2.6.2 of both USB-PD Spec Revision 2.0, Version 1.3 & USB-PD Spec Revision 3.0, Version 2.0, at explicit contract, The Sink can initiate or receive a request for an exchange of VCONN Source and The Sink when it is the VCONN Source can communicate with a Cable Plug using SOP’ or SOP’’ Communication. PD_FLAGS_CHECK_VCONN_STATE flag enables the DUT to request for a VCONN swap at explicit contract. Earlier, when UFP requested for a power role swap, PD_FLAGS_CHECK_VCONN_STATE flag wasn't being enabled and hence, DUT was not entering Thunderbolt/USB4 alternate mode. Enabling the PD_FLAGS_CHECK_VCONN_STATE flag in PD_STATE_SNK_REQUESTED and in PD_STATE_SRC_POWERED allows DUT to request for VCONN swap at explicit contract. BUG=b:158455025 BRANCH=None TEST=Able to enter into Thunderbolt/USB4 when UFP requests for a power role swap. Change-Id: I68f2e2de3186ea367ace497b47930e30976c9e6b Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244022 Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r--common/usb_pd_protocol.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index b8cd5d7340..99d1e33ae1 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -3608,6 +3608,7 @@ void pd_task(void *u)
case PD_STATE_SRC_POWERED:
/* Switch to the new requested voltage */
if (pd[port].last_state != pd[port].task_state) {
+ pd[port].flags |= PD_FLAGS_CHECK_VCONN_STATE;
pd_transition_voltage(pd[port].requested_idx);
set_state_timeout(
port,
@@ -3696,18 +3697,9 @@ void pd_task(void *u)
pd_check_pr_role(port, PD_ROLE_SOURCE,
pd[port].flags);
pd[port].flags &= ~PD_FLAGS_CHECK_PR_ROLE;
- /*
- * USB PD version 1.3 section 2.6.1:
- * During Explicit contract the Sink can
- * initiate or receive a request an exchange
- * of VCONN Source. Hence, enable Vconn swap
- * during explicit contract.
- */
- pd[port].flags |= PD_FLAGS_CHECK_VCONN_STATE;
-
- break;
}
+
/* Check data role policy, which may trigger a swap */
if (pd[port].flags & PD_FLAGS_CHECK_DR_ROLE) {
pd_check_dr_role(port, pd[port].data_role,
@@ -3718,6 +3710,14 @@ void pd_task(void *u)
/* Check for Vconn source, which may trigger a swap */
if (pd[port].flags & PD_FLAGS_CHECK_VCONN_STATE) {
+ /*
+ * Ref: Section 2.6.1 of both
+ * USB-PD Spec Revision 2.0, Version 1.3 &
+ * USB-PD Spec Revision 3.0, Version 2.0
+ * During Explicit contract the Sink can
+ * initiate or receive a request an exchange
+ * of VCONN Source.
+ */
pd_try_execute_vconn_swap(port,
pd[port].flags);
pd[port].flags &= ~PD_FLAGS_CHECK_VCONN_STATE;
@@ -4268,6 +4268,7 @@ void pd_task(void *u)
case PD_STATE_SNK_REQUESTED:
/* Wait for ACCEPT or REJECT */
if (pd[port].last_state != pd[port].task_state) {
+ pd[port].flags |= PD_FLAGS_CHECK_VCONN_STATE;
hard_reset_count = 0;
set_state_timeout(port,
get_time().val +
@@ -4318,14 +4319,6 @@ void pd_task(void *u)
pd_check_pr_role(port, PD_ROLE_SINK,
pd[port].flags);
pd[port].flags &= ~PD_FLAGS_CHECK_PR_ROLE;
- /*
- * USB PD version 1.3 section 2.6.2:
- * During Explicit contract the Sink can
- * initiate or receive a request an exchange
- * of VCONN Source. Hence, enable Vconn swap
- * during explicit contract.
- */
- pd[port].flags |= PD_FLAGS_CHECK_VCONN_STATE;
break;
}
@@ -4339,6 +4332,14 @@ void pd_task(void *u)
/* Check for Vconn source, which may trigger a swap */
if (pd[port].flags & PD_FLAGS_CHECK_VCONN_STATE) {
+ /*
+ * Ref: Section 2.6.2 of both
+ * USB-PD Spec Revision 2.0, Version 1.3 &
+ * USB-PD Spec Revision 3.0, Version 2.0
+ * During Explicit contract the Sink can
+ * initiate or receive a request an exchange
+ * of VCONN Source.
+ */
pd_try_execute_vconn_swap(port,
pd[port].flags);
pd[port].flags &= ~PD_FLAGS_CHECK_VCONN_STATE;