summaryrefslogtreecommitdiff
path: root/common/usbc
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2020-09-03 13:40:23 -0600
committerCommit Bot <commit-bot@chromium.org>2020-09-11 05:14:38 +0000
commit0757a13425f8f90c089c22265f23903ffe9603f6 (patch)
treeabb41020712babcc794d15ab7239b8a3a7717e02 /common/usbc
parenta4c08b77c4befb2694ca790cf9b90eb4eea968a3 (diff)
downloadchrome-ec-0757a13425f8f90c089c22265f23903ffe9603f6.tar.gz
TCPMv2: Improve timing in Attached.SRC
Don't wait an extra 15 ms to debounce CC after detecting CC open. Don't wait to react to CC open until PD is enabled. BUG=b:163143427 TEST=Attach volteer C1 to volteer C1; observe unstable Attach.SRC, but PE doesn't start BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ibd4bd4948fefd5f931dcdc98b1716744c46682b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2392563 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usbc')
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c68
1 files changed, 28 insertions, 40 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 80ab2eadea..287bea463f 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -2745,35 +2745,6 @@ static void tc_attached_src_entry(const int port)
static void tc_attached_src_run(const int port)
{
enum tcpc_cc_voltage_status cc1, cc2;
- enum pd_cc_states new_cc_state;
-
-#ifdef CONFIG_USB_PE_SM
- /*
- * Enable PD communications after power supply has fully
- * turned on
- */
- if (tc[port].timeout > 0 && get_time().val > tc[port].timeout) {
- tc_enable_pd(port, 1);
- tc[port].timeout = 0;
- }
-
- if (!tc_get_pd_enabled(port))
- return;
-
- /*
- * Handle Hard Reset from Policy Engine
- */
- if (TC_CHK_FLAG(port, TC_FLAGS_HARD_RESET_REQUESTED)) {
- /* Ignoring Hard Resets while the power supply is resetting.*/
- if (get_time().val < tc[port].timeout)
- return;
-
- if (tc_perform_src_hard_reset(port))
- TC_CLR_FLAG(port, TC_FLAGS_HARD_RESET_REQUESTED);
-
- return;
- }
-#endif
/* Check for connection */
tcpm_get_cc(port, &cc1, &cc2);
@@ -2782,18 +2753,9 @@ static void tc_attached_src_run(const int port)
cc1 = cc2;
if (cc1 == TYPEC_CC_VOLT_OPEN)
- new_cc_state = PD_CC_NONE;
+ tc[port].cc_state = PD_CC_NONE;
else
- new_cc_state = PD_CC_UFP_ATTACHED;
-
- /* Debounce the cc state */
- if (new_cc_state != tc[port].cc_state) {
- tc[port].cc_state = new_cc_state;
- tc[port].cc_debounce = get_time().val + PD_T_SRC_DISCONNECT;
- }
-
- if (get_time().val < tc[port].cc_debounce)
- return;
+ tc[port].cc_state = PD_CC_UFP_ATTACHED;
/*
* When the SRC.Open state is detected on the monitored CC pin, a DRP
@@ -2827,6 +2789,32 @@ static void tc_attached_src_run(const int port)
#ifdef CONFIG_USB_PE_SM
/*
+ * Enable PD communications after power supply has fully
+ * turned on
+ */
+ if (tc[port].timeout > 0 && get_time().val > tc[port].timeout) {
+ tc_enable_pd(port, 1);
+ tc[port].timeout = 0;
+ }
+
+ if (!tc_get_pd_enabled(port))
+ return;
+
+ /*
+ * Handle Hard Reset from Policy Engine
+ */
+ if (TC_CHK_FLAG(port, TC_FLAGS_HARD_RESET_REQUESTED)) {
+ /* Ignoring Hard Resets while the power supply is resetting.*/
+ if (get_time().val < tc[port].timeout)
+ return;
+
+ if (tc_perform_src_hard_reset(port))
+ TC_CLR_FLAG(port, TC_FLAGS_HARD_RESET_REQUESTED);
+
+ return;
+ }
+
+ /*
* PD swap commands
*/
if (tc_get_pd_enabled(port) && prl_is_running(port)) {