summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyushee Shah <ayushee.shah@intel.com>2021-01-21 10:10:49 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-25 20:57:21 +0000
commite9eefa1d997c24219f14f48675b95a5d89c5f4f3 (patch)
tree5add75fd2521c4027d4c51e5b48c1b4468572cc0
parentbfc29b475e280e442fed7a234d1b381f0dd70ec6 (diff)
downloadchrome-ec-e9eefa1d997c24219f14f48675b95a5d89c5f4f3.tar.gz
tcpmv2: Re-discover cable if the port parter is PD 2.0
If the cables has been queried with PD 3.0, but the port partner supports PD 2.0, re-discover the cable capabilities. BUG=b:178077239 BRANCH=None TEST=Tested with PD2.0 dock and PD3.0 cable, able to enter Thunderbolt mode. Signed-off-by: Ayushee Shah <ayushee.shah@intel.com> Change-Id: I559f57a64a525a7ee0ae8744f88ec347688fe880 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2643580 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 893bdd4244..b9d969845c 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -826,6 +826,27 @@ static inline void send_ctrl_msg(int port, enum tcpm_transmit_type type,
prl_send_ctrl_msg(port, type, msg);
}
+static void set_cable_rev(int port)
+{
+ /*
+ * If port partner runs PD 2.0, cable communication must
+ * also be PD 2.0
+ */
+ if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV20) {
+ /*
+ * If the cable supports PD 3.0, but the port partner supports PD 2.0,
+ * redo the cable discover with PD 2.0
+ */
+ if (prl_get_rev(port, TCPC_TX_SOP_PRIME) == PD_REV30 &&
+ pd_get_identity_discovery(port, TCPC_TX_SOP_PRIME) ==
+ PD_DISC_COMPLETE) {
+ pd_set_identity_discovery(port, TCPC_TX_SOP_PRIME,
+ PD_DISC_NEEDED);
+ }
+ prl_set_rev(port, TCPC_TX_SOP_PRIME, PD_REV20);
+ }
+}
+
/* Compile-time insurance to ensure this code does not call into prl directly */
#define prl_send_data_msg DO_NOT_USE
#define prl_send_ext_data_msg DO_NOT_USE
@@ -2187,12 +2208,7 @@ static void pe_src_send_capabilities_run(int port)
prl_set_rev(port, TCPC_TX_SOP,
MIN(PD_REVISION, PD_HEADER_REV(rx_emsg[port].header)));
- /*
- * If port partner runs PD 2.0, cable communication must
- * also be PD 2.0
- */
- if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV20)
- prl_set_rev(port, TCPC_TX_SOP_PRIME, PD_REV20);
+ set_cable_rev(port);
/* We are PD connected */
PE_SET_FLAG(port, PE_FLAGS_PD_CONNECTION);
@@ -2991,12 +3007,7 @@ static void pe_snk_evaluate_capability_entry(int port)
prl_set_rev(port, TCPC_TX_SOP,
MIN(PD_REVISION, PD_HEADER_REV(rx_emsg[port].header)));
- /*
- * If port partner runs PD 2.0, cable communication must
- * also be PD 2.0
- */
- if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV20)
- prl_set_rev(port, TCPC_TX_SOP_PRIME, PD_REV20);
+ set_cable_rev(port);
pd_set_src_caps(port, num, pdo);