summaryrefslogtreecommitdiff
path: root/common/usbc/usb_tc_drp_acc_trysrc_sm.c
diff options
context:
space:
mode:
authorMichał Barnaś <mb@semihalf.com>2021-07-13 18:29:46 +0200
committerCommit Bot <commit-bot@chromium.org>2021-07-16 18:19:09 +0000
commitef75b89e05691b1a5a60d2f265a707f9966293e7 (patch)
tree1921798a4509d61bb1876a3c3de3c59cd28d8c73 /common/usbc/usb_tc_drp_acc_trysrc_sm.c
parent6e4ed0664ef649b0170894cc2ac1a738d3673ce1 (diff)
downloadchrome-ec-ef75b89e05691b1a5a60d2f265a707f9966293e7.tar.gz
TCPMv2: Add delay for detecting CC state in tc_attached_src state
Some TCPCs require time to return correct status of CC lines after changing ROLE_CONTROL register. If no delay is applied, these TCPCs can incorrectly report CC lines as open which result in changing state to Unattached.Src. This makes power swap not working. For lazor board it takes about 8ms to detect correct values on CC lines, where maximum time from specification is 20ms. Considering this, value of 15ms was set as delay. BUG=b:192353324 BRANCH=main TEST=Running PD FAFTs on lazor gives positive results Signed-off-by: Michał Barnaś <mb@semihalf.com> Change-Id: I25937fcd996d5a67b4acb1833b07c80c395e66b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3024268 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usbc/usb_tc_drp_acc_trysrc_sm.c')
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index d03bd35aae..0c9fde99a6 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -3075,6 +3075,17 @@ static void tc_attached_src_entry(const int port)
tcpm_debug_accessory(port, 1);
set_ccd_mode(port, 1);
}
+
+ /*
+ * Some TCPCs require time to correctly return CC status after
+ * changing the ROLE_CONTROL register. Due to that, we have to ignore
+ * CC_NONE state until PD_T_SRC_DISCONNECT delay has elapsed.
+ * From the "Universal Serial Bus Type-C Cable and Connector
+ * Specification" Release 2.0 paragraph 4.5.2.2.9.2:
+ * The Source shall detect the SRC.Open state within tSRCDisconnect,
+ * but should detect it as quickly as possible
+ */
+ pd_timer_enable(port, TC_TIMER_CC_DEBOUNCE, PD_T_SRC_DISCONNECT);
}
static void tc_attached_src_run(const int port)
@@ -3102,7 +3113,8 @@ static void tc_attached_src_run(const int port)
* AttachWait.SNK shall enter TryWait.SNK for a Sink detach from
* Attached.SRC.
*/
- if (tc[port].cc_state == PD_CC_NONE) {
+ if (tc[port].cc_state == PD_CC_NONE &&
+ pd_timer_is_expired(port, TC_TIMER_CC_DEBOUNCE)) {
bool tryWait;
enum usb_tc_state new_tc_state = TC_UNATTACHED_SNK;
@@ -3262,6 +3274,7 @@ static void tc_attached_src_exit(const int port)
if (TC_CHK_FLAG(port, TC_FLAGS_TS_DTS_PARTNER))
tcpm_debug_detach(port);
+ pd_timer_disable(port, TC_TIMER_CC_DEBOUNCE);
pd_timer_disable(port, TC_TIMER_TIMEOUT);
}