diff options
author | Zhuohao Lee <zhuohao@chromium.org> | 2022-08-16 16:04:33 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-16 18:55:12 +0000 |
commit | a0e820d517ad4672e526c191d6e16c86d06b8887 (patch) | |
tree | f51f9af9afcbcfa2a268d5c43357925a9c96b3a3 | |
parent | 863474ebc60e9e19f621fb4fdd8158a80c3f0588 (diff) | |
download | chrome-ec-a0e820d517ad4672e526c191d6e16c86d06b8887.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.
This patch is synced from the brya patch: http://crrev/c/3411537
BRANCH=None
BUG=b:213024508
TEST=build pass
Signed-off-by: Zhuohao Lee <zhuohao@chromium.org>
Change-Id: I5112d031dbdbf8c9667d22c6c20f434f8fd2b1a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3833263
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | baseboard/brask/usb_pd_policy.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/baseboard/brask/usb_pd_policy.c b/baseboard/brask/usb_pd_policy.c index da39d2004f..c203e9a41b 100644 --- a/baseboard/brask/usb_pd_policy.c +++ b/baseboard/brask/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" @@ -191,13 +192,23 @@ static int svdm_tbt_compat_response_enter_mode(int port, uint32_t *payload) 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 */ } |