summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-08-11 13:45:04 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-11 22:34:30 +0000
commite477345da07a552148b6e45d3f109fa459b45bb6 (patch)
tree1888f0a81729f8b88a4c00af24869d1fdd76dd7a
parent80bdc75768a3d2d09ac54e2289ef952e258c888d (diff)
downloadchrome-ec-e477345da07a552148b6e45d3f109fa459b45bb6.tar.gz
TCPMv2: Fix ordering of Vbus application in Attached.SRC entry
Per the TCPCI spec figures, we should be setting the CC lines and enabling Auto Discharge Disconnect before attempting to source Vbus. Doing these things out of order may cause Vbus sourcing to appear to fail when a TCPC is waiting for ADD to set before enabling Vbus. BRANCH=None BUG=b:195966013 TEST=on guybrush, verify both C0 and C1 successfully detect that they are sourcing Vbus with an unpowered Apple 3-in-1 dongle Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Icb0bd221a7d8eb069b74327c27894e5d92e95329 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3088003 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index c56bcd2b81..1049326e42 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -2979,11 +2979,23 @@ static void tc_attached_src_entry(const int port)
* completed and tc_pr_swap_complete is called.
*/
} else {
+ /*
+ * Set up CC's, Vconn, and ADD before Vbus, as per
+ * Figure 4-24. DRP Initialization and Connection
+ * Detection in TCPCI r2 v1.2 specification.
+ */
+
/* Get connector orientation */
tcpm_get_cc(port, &cc1, &cc2);
tc[port].polarity = get_src_polarity(cc1, cc2);
pd_set_polarity(port, tc[port].polarity);
+ /* Attached.SRC - enable AutoDischargeDisconnect */
+ tcpm_enable_auto_discharge_disconnect(port, 1);
+
+ /* Apply Rp */
+ typec_update_cc(port);
+
/*
* Initial data role for sink is DFP
* This also sets the usb mux
@@ -3013,23 +3025,29 @@ static void tc_attached_src_entry(const int port)
tc[port].polarity);
}
- /* Attached.SRC - enable AutoDischargeDisconnect */
- tcpm_enable_auto_discharge_disconnect(port, 1);
-
- /* Apply Rp */
- typec_update_cc(port);
-
tc_enable_pd(port, 0);
pd_timer_enable(port, TC_TIMER_TIMEOUT,
MAX(PD_POWER_SUPPLY_TURN_ON_DELAY,
PD_T_VCONN_STABLE));
}
} else {
+ /*
+ * Set up CC's, Vconn, and ADD before Vbus, as per
+ * Figure 4-24. DRP Initialization and Connection
+ * Detection in TCPCI r2 v1.2 specification.
+ */
+
/* Get connector orientation */
tcpm_get_cc(port, &cc1, &cc2);
tc[port].polarity = get_src_polarity(cc1, cc2);
pd_set_polarity(port, tc[port].polarity);
+ /* Attached.SRC - enable AutoDischargeDisconnect */
+ tcpm_enable_auto_discharge_disconnect(port, 1);
+
+ /* Apply Rp */
+ typec_update_cc(port);
+
/*
* Initial data role for sink is DFP
* This also sets the usb mux
@@ -3056,12 +3074,6 @@ static void tc_attached_src_entry(const int port)
usb_mux_set(port, USB_PD_MUX_NONE,
USB_SWITCH_DISCONNECT, tc[port].polarity);
}
-
- /* Attached.SRC - enable AutoDischargeDisconnect */
- tcpm_enable_auto_discharge_disconnect(port, 1);
-
- /* Apply Rp */
- typec_update_cc(port);
}
/* Inform PPC and OCP module that a sink is connected. */