summaryrefslogtreecommitdiff
path: root/baseboard
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2022-01-22 14:12:23 -0700
committerCommit Bot <commit-bot@chromium.org>2022-02-09 01:24:05 +0000
commitf9f4caf1d2e180630975c896742e43899f191a73 (patch)
tree14bb2bbe6f37b290d0d1d47a6f8a7c5914b1ed14 /baseboard
parent6ebb212a166d1a53a32770815e77439ec0ecc2af (diff)
downloadchrome-ec-f9f4caf1d2e180630975c896742e43899f191a73.tar.gz
TBT UFP: Correct TBT UFP VDM ACK timing with mux task
When an EnterMode command comes in, the Responder should be in the USB mode or safe state before configuring its pins to the new mode and sending an ACK. However, since our virtual mux ACK sequence may take longer than the allowed tVDMEnterMode, the best we can do is wait as long as we can without violating this timing before sending the ACK. BRANCH=None BUG=b:213024508 TEST=on brya, ensure TBT UFP mode entry completes successfully and in a timely manner with the mux task enabled Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5c6325022cdbd925548c3de7c01a279d0666f130 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3411537 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r--baseboard/brya/usb_pd_policy.c15
-rw-r--r--baseboard/volteer/usb_pd_policy.c14
2 files changed, 25 insertions, 4 deletions
diff --git a/baseboard/brya/usb_pd_policy.c b/baseboard/brya/usb_pd_policy.c
index f2ee86a6b4..4d5ece38ca 100644
--- a/baseboard/brya/usb_pd_policy.c
+++ b/baseboard/brya/usb_pd_policy.c
@@ -15,6 +15,7 @@
#include "console.h"
#include "ec_commands.h"
#include "gpio.h"
+#include "timer.h"
#include "usbc_ppc.h"
#include "usb_mux.h"
#include "usb_pd.h"
@@ -200,13 +201,23 @@ static int svdm_tbt_compat_response_enter_mode(
mux_state = usb_mux_get(port);
/*
* Ref: USB PD 3.0 Spec figure 6-21 Successful Enter Mode sequence
- * UFP (responder) should be in USB mode or safe mode before sending
- * Enter Mode Command response.
+ * UFP (responder) should be in USB mode or safe mode before entering a
+ * Mode that requires the reconfiguring of any pins.
*/
if ((mux_state & USB_PD_MUX_USB_ENABLED) ||
(mux_state & USB_PD_MUX_SAFE_MODE)) {
pd_ufp_set_enter_mode(port, payload);
set_tbt_compat_mode_ready(port);
+
+ /*
+ * Ref: Above figure 6-21: UFP (responder) should be in the new
+ * mode before sending the ACK. However, our mux set sequence
+ * may exceed tVDMEnterMode, so wait as long as we can
+ * before sending the reply without violating that timer.
+ */
+ if (!usb_mux_set_completed(port))
+ usleep(PD_T_VDM_E_MODE / 2);
+
CPRINTS("UFP Enter TBT mode");
return 1; /* ACK */
}
diff --git a/baseboard/volteer/usb_pd_policy.c b/baseboard/volteer/usb_pd_policy.c
index c806548052..5b9000b3f7 100644
--- a/baseboard/volteer/usb_pd_policy.c
+++ b/baseboard/volteer/usb_pd_policy.c
@@ -197,13 +197,23 @@ static int svdm_tbt_compat_response_enter_mode(
mux_state = usb_mux_get(port);
/*
* Ref: USB PD 3.0 Spec figure 6-21 Successful Enter Mode sequence
- * UFP (responder) should be in USB mode or safe mode before sending
- * Enter Mode Command response.
+ * UFP (responder) should be in USB mode or safe mode before entering a
+ * Mode that requires the reconfiguring of any pins.
*/
if ((mux_state & USB_PD_MUX_USB_ENABLED) ||
(mux_state & USB_PD_MUX_SAFE_MODE)) {
pd_ufp_set_enter_mode(port, payload);
set_tbt_compat_mode_ready(port);
+
+ /*
+ * Ref: Above figure 6-21: UFP (responder) should be in the new
+ * mode before sending the ACK. However, our mux set sequence
+ * may exceed tVDMEnterMode, so wait as long as we can
+ * before sending the reply without violating that timer.
+ */
+ if (!usb_mux_set_completed(port))
+ usleep(PD_T_VDM_E_MODE / 2);
+
CPRINTS("UFP Enter TBT mode");
return 1; /* ACK */
}