summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-11-19 09:35:00 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-03 17:06:32 +0000
commit74ae3c01ed6d9bcc02c0468e3b5f1aa2d4eaaca4 (patch)
tree418e013d22aa54efae55f340586c1441a3ee2a3f
parentd4944f211943323506f5ddf98418b1bc2fa6095c (diff)
downloadchrome-ec-74ae3c01ed6d9bcc02c0468e3b5f1aa2d4eaaca4.tar.gz
tcpmv2: change SOP' Discover Identity retry logic.
To further improve the time to enter alternate modes, limit the number of SOP' DiscID retries that are performed before a contract is in place. This ensures interoperability with captive cable devices that cannot respond to SOP' until a contract is established. BUG=b:169741906, b:166650426 BRANCH=firmware-volteer-13521.B-master TEST=Connect TBT3 loopack device and verify TBT mode is entered. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I007780df567cd0e66236b2c3067d065eecf07fe1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2550307 Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index ab481bffe5..9a764cb716 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -182,11 +182,23 @@
#define N_DISCOVER_IDENTITY_COUNT 6
/*
- * tDiscoverIdentity is only defined while an explicit contract is in place.
- * To support captive cable devices that power the SOP' responder from VBUS
- * instead of VCONN stretch out the SOP' Discover Identity messages when
- * no contract is present. 200 ms provides about 1 second for the cable
- * to power up (200 * 5 retries).
+ * It is permitted to send SOP' Discover Identity messages before a PD contract
+ * is in place. However, this is only beneficial if the cable powers up quickly
+ * solely from VCONN. Limit the number of retries without a contract to
+ * ensure we attempt some cable discovery after a contract is in place.
+ */
+#define N_DISCOVER_IDENTITY_PRECONTRACT_LIMIT 2
+
+/*
+ * Once this limit of SOP' Discover Identity messages has been set, downgrade
+ * to PD 2.0 in case the cable is non-compliant about GoodCRC-ing higher
+ * revisions. This limit should be higher than the precontract limit.
+ */
+#define N_DISCOVER_IDENTITY_PD3_0_LIMIT 4
+
+/*
+ * tDiscoverIdentity is only defined while an explicit contract is in place, so
+ * extend the interval between retries pre-contract.
*/
#define PE_T_DISCOVER_IDENTITY_NO_CONTRACT (200*MSEC)
@@ -1946,7 +1958,9 @@ static void pe_src_discovery_run(int port)
*/
if (pd_get_identity_discovery(port, TCPC_TX_SOP_PRIME) == PD_DISC_NEEDED
&& get_time().val > pe[port].discover_identity_timer
- && pe_can_send_sop_prime(port)) {
+ && pe_can_send_sop_prime(port)
+ && (pe[port].discover_identity_counter <
+ N_DISCOVER_IDENTITY_PRECONTRACT_LIMIT)) {
pe[port].tx_type = TCPC_TX_SOP_PRIME;
set_state_pe(port, PE_VDM_IDENTITY_REQUEST_CBL);
return;
@@ -2209,7 +2223,6 @@ static void pe_src_transition_supply_run(int port)
if (PE_CHK_FLAG(port, PE_FLAGS_PS_READY)) {
PE_CLR_FLAG(port, PE_FLAGS_PS_READY);
- /* NOTE: Second pass through this code block */
/*
* Set first message flag to trigger a wait and add
@@ -2219,6 +2232,7 @@ static void pe_src_transition_supply_run(int port)
if (!pe_is_explicit_contract(port))
PE_SET_FLAG(port, PE_FLAGS_FIRST_MSG);
+ /* NOTE: Second pass through this code block */
/* Explicit Contract is now in place */
pe_set_explicit_contract(port);
@@ -5068,10 +5082,10 @@ static void pe_vdm_identity_request_cbl_exit(int port)
pd_set_identity_discovery(port, pe[port].tx_type,
PD_DISC_FAIL);
else if (pe[port].discover_identity_counter ==
- (N_DISCOVER_IDENTITY_COUNT / 2))
+ N_DISCOVER_IDENTITY_PD3_0_LIMIT)
/*
- * Downgrade to PD 2.0 if the partner hasn't replied halfway
- * through discovery as well, in case the cable is
+ * Downgrade to PD 2.0 if the partner hasn't replied before
+ * all retries are exhausted in case the cable is
* non-compliant about GoodCRC-ing higher revisions
*/
prl_set_rev(port, TCPC_TX_SOP_PRIME, PD_REV20);