summaryrefslogtreecommitdiff
path: root/common/usbc/tbt_alt_mode.c
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: Allow alternate mode reentryAbe Levkoy2020-11-051-2/+5
| | | | | | | | | | | | | | When the EC is waiting for the AP to direct it to enter alternate modes, allow the AP to direct an Exit Mode followed by another Enter Mode. BUG=b:168030639 TEST=Exit and reenter DP and TBT alt modes BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I9edf0ca0a787ed025de2d5a5403d4225a6683e3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518612 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Add support for USB4 active cableAyushee2020-11-051-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USB4 PD flow for active cables: Structured VDM version (cable revision)-- <2.0 -------->| | | >=2.0 | | | VDO version---- <1.3 -------> Modal op? -- N --| (B21:23 of | | Discover ID SOP'- y | Active cable VDO1) | | | TBT SVID? -- N --| >=1.3 | | | y | Cable USB4 support? - N | | | | Gen4 cable? - N - Skip USB4 mode entry y Skip USB4 | | mode entry | Enter USB4 y (SOP',SOP'',SOP) | | |<---- NAK ----- Enter mode TBT SOP'<---| | | | | ACK | | | | |<---- NAK ----- Enter mode TBT SOP'' | | | | Exit TBT mode SOP ACK | | | | ACK/NAK Enter USB4 mode | | SOP | Exit TBT mode SOP'' | | | ACK/NAK | | | Exit TBT mode SOP' | | | ACK/NAK | | | |--------Retry done? ---- N ------------| | y | Skip USB4 mode entry The CL also checks if the port is VCONN source before sending Enter USB SOP' and SOP'' messages and requests for a vconn swap is it isn't In case of reboot, the port sends exit Thunderbolt mode SOP' and SOP'' and skips sending exit Thunderbolt mode for SOP, since it didn't enter Thunderbolt mode SOP prior to reboot. Note: 1. This is only applicable when the port enters USB4 mode SOP and Thunderbolt mode with the cable plug. 2. It is a temporary behaviour until data reset feature is in place (b/141363146) BUG=b:156749387 BRANCH=None TEST=1.Able to enter into USB4 with active cable. 2.Able to exit Thunderbolt mode SOP' and SOP'' on reboot and re-enter into USB4 mode with active cable. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I828c7ca0fd9b7b1025f13bcc86c511692b9f9895 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432868 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Avoid alt mode files from changing DPM statesAyushee2020-10-141-21/+32
| | | | | | | | | | | | | | | | | | | | | | | | USB4 mode: Added a function to check if the USB4 entry is completed Thunderbolt mode: Added 2 flags TBT_RETRY_DONE, TBT_EXIT_DONE to track the Thunderbolt mode's exit and if retry is needed and a new function to check if if the Thunderbolt mode entry is completed DisplayPort mode: Added a function to check if the DisplayPort entry is completed BUG=b:169169804 BRANCH=None TEST=1. Able to enter alternate mode on hotplug and reboot 2. Able to exit the alternate mode on chipset transition and on DPM's exit mode request. Change-Id: I09662449143ad8d94b30ae102ed5ce79db852687 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2421425 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TBT:Add support for exit mode SOP'/SOP'' on chipset transitionAyushee2020-10-141-22/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When chipset is transitioning to a new state or on sysjump, the EC re-negotiates to enter an alternate mode on booting up. This commit adds support for exiting Thunderbolt mode for SOP' and SOP'' for active cable on chipset transition and also moves all the alternate mode exit rotines to their respective files. It also delays deleting the SVID data until after the EXIT_MODE message has ACKed and avoids pd_dfp_exit_mode() from changing the alternate mode's internal states. This commit also makes sure that the mux is set to safe state before exiting the alternate mode and it is reconfigured according to the port's current data role on receiving ACK/NAK from the cable/port partner. BUG=b:151169925, b:159717794 BRANCH=none TEST=On reboot, able to exit and re-enter into DisplayPort mode, Thunderbolt mode with passive cable and thunderbolt mode with active cable. Change-Id: If1e48e9f31cd678e23fe89bd3494551b5d1a78f1 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415082 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: check active cable SVID supportli feng2020-10-131-3/+18
| | | | | | | | | | | | | | | | | According to TBT4 PD flow, SOP' discovery SVID should support USB_VID_INTEL to enable Thunderbolt Alt mode. BUG=none BRANCH=master TEST=1. Volteer EVT connects to TBT dock with TBT passive cable, EC can enter TBT mode 2. Volteer EVT connects to TBT dock with TBT active cable which supports SVID USB_VID_INTEL, EC can enter TBT mode. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I10e16bff89175fe8425a6c7afc31141a6a5d573f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2441962 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Send SOP'/SOP'' VDM only when the port is VCONN srcAyushee2020-08-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | According to USB PD spec, section 2.5.4, only VCONN source can communicate with the cable plug. This CL checks if the port is the VCONN before sending SOP'/SOP'' messages. If there is a VCONN source failure, port retries swapping the VCONN times before marking the VDM as failed/naked. The CL also enables falling back to DP mode in case enter mode thunderbolt fails. BUG=b:148528713 BRANCH=None TEST=Tested on volteer, the port sends SOP'/SOP'' VDMs to the cable only if it's the VCONN source Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I5880104a7a42b3e7de9e472affd41e937d36f9a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368066 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TBT: Enter DP mode if Thunderbolt mode isn't supportedAyushee2020-08-071-9/+16
| | | | | | | | | | | | | | | This commit checks if the Thunderbolt mode is supported at TBT_START. If the port/port-partner/cable doesn't support Thunderbolt mode, fall back on DP mode instead. BUG=b:162776463 BRANCH=None TEST=Able to detect Thunderbolt docks as Display port dock on port 0. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I424772c96afa9f3f11e5d4d9daa562bbbb011381 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335883 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add thunderbolt entry flow for active cableli feng2020-07-181-53/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Order of Enter Mode: SOP', SOP''(if supported), SOP Order of Exit Mode: SOP, SOP''(if supported), SOP' Entry flow start from TBT_START, state changes to TBT_ACTIVE if succeed; changes to TBT_INACTIVE if fail. Handling of NAK If any enter mode SOP* is NAK'ed, exit modes of all SOP* and retry enter. If any enter mode in retry is NAK'ed again, will exit modes of all SOP*, TBT entry failed. Special case: Exit in TBT_ACTIVE: start from TBT_ACTIVE, exit all modes of SOP*, then chagne state to TBT_INACTIVE. BUG=b:148528713 BRANCH=none TEST=1. Attach Thunderbolt dock and active cable, DUT enter Thunderbolt mode 2. Attach Thunderbolt dock and passive cable, DUT enter Thunderbolt mode Signed-off-by: li feng <li1.feng@intel.com> Change-Id: Iaaa63f70c4abc9c269cdbb2a504214f924155901 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277487 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add common exit mode for all the alternate modesAyushee2020-07-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | When chipset is transitioning to a new state or on sysjump, the SOC re-negotiates to enter an alternate mode on booting up. This commit: 1. Adds a common DPM function to check for all the active alternate modes one at a time, construct the VDM and send the DPM request to exit the mode. 2. Marks thunderbolt mode as inactive in DFP's thunderbolt mode exit function. BUG=b:152235216 BRANCH=None TEST=Tested on volteer: 1. On connecting a DP dongle, able to enter into DP alternate mode on reboot 2. On connecting a Thunderbolt dock, able to enter into Thunderbolt mode on reboot Change-Id: I7da6a4b08cab9abb3446c0dafdc7c9e9378ef00e Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2270877 Tested-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Remove alt mode VDM "sent" statesAbe Levkoy2020-07-131-21/+9
| | | | | | | | | | | | | | | | | | | | | | | | | In alt mode modules, don't change state after constructing a VDM for the PE to send. At that point, the VDM has not been sent, it may never be sent due to message discard, and if it is sent, the AMS may be interrupted. Wait to change state until the DPM notifies the alt mode module of some response or non-response to the sent VDM. By doing this, allow the alt mode modules to react gracefully to a discarded message or interrupted AMS. Otherwise, they would get into an unexpected state and give up on alt mode setup. Reduce flash size by 104 bytes on average (volteer RO: 192; RW: 184). BUG=b:160701588,b:158572770 TEST=Observe DP and TBT setup recover from interrupted VDM sequence TEST=Observe DP still working after power cycle on puff BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I3e556771f603312b1f0f574ce8d6e7884c19cf16 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2274644 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv2: Don't enter Thunderbolt mode if the port doesn't support itAyushee2020-07-071-2/+3
| | | | | | | | | | | | | | | | This commit checks if the port supports Thunderbolt speed before entering into Thunderbolt alternate mode. BUG=b:160273134 BRANCH=None TEST=Tested on Volteer board with a USB3 DB, Thunderbolt dock enters into USB+DP mode. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I5c8497eaf20d505d2e863f010a57acc6d455b9b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277498 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Add Entry flow for Thunderbolt modeAyushee2020-06-301-0/+241
Create a separate module for representing Thunderbolt mode which decides whether and how we can enter into Thunderbolt alternate mode. Modify the Device Policy Manger (usb_pd_dpm.c) to first check if the port partner and cable is a Thunderbolt Compatible. If not, continue the rest of the PD flow undisturbed. BUG=b:148528713 BRANCH=none TEST=1. Attach Thunderbolt dock, DUT should enter Thunderbolt mode 2. Attach Type-C dock, DUT should enter DP mode 3. Attach DP dongle, DUT should enter DP mode Change-Id: I369eb6337144676996c9d94a412eec060eacd273 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250488 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>