summaryrefslogtreecommitdiff
path: root/common/usb_pd_alt_mode_dfp.c
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: Add support for linear re-driver cablesAyushee2020-11-061-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The linear re-driver cables enumerate as passive cables in the Discover mode SOP' response from the cable. But they have Active/Passive bit (B25) in the discover mode SOP' response set. Hence, if the cable is LRD, the port enters Thunderbolt mode SOP' before entering USB and it also sets the cable as active in the mux and retimer setting. USB4 PD flow for LRD cables: Is Discover mode SOP' B25? ----- N ----- Enter USB4 SOP with Gen 2 cable speed | y | Enter TBT SOP' | Enter USB4 SOP as per cable speed. TBT PD flow for LRD cables: Is Discover mode SOP' B25? ----- N ----- Enter TBT SOP | y | Enter TBT SOP' | Enter TBT SOP This CL also updates the retimer setting and Enter USB Data object for USB4 according to the type of cable detected (LRD/Active/passive) BUG=b:156749387 BRANCH=None TEST=With Linear re-driver cable, 1. Able to enter USB4 mode 2. Able to enter Thunderbolt mode 3. Able to exit and re-enter USB4 on reboot 4. Able to exit and re-enter Thunderbolt mode on reboot Change-Id: Ie5258f792e13a205dea71fc9f06b1d8987ec9194 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2470209 Reviewed-by: Tanu Malhotra <tanu.malhotra@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* BB retimer: Update USB4 related bitsAyushee2020-11-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | This CL updates the following bits: Bit 4: USB3 bit - If active cable V3, according to Discover Idenitity SOP response, Product VDO 2 B5. else set to 1 Bit 16: Thunderbolt support - According to B3:B5 of Discover Identity SOP response. Bit 19: VPro Support - If host is vPro capable and according to Discover Mode SOP response B26/B31. This CL also updates the thunderbolt related bits for the retimer if the thunderbolt mode SOP' and SOP'' is entered. BUG=b:156749387 BRANCH=None TEST=Able to update the retimer bits on entering USB4 mode Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Ic083001dee73d854379f1f3dfd85bebe5ee6ef5d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473597 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Add support for USB4 active cableAyushee2020-11-051-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* morphius: Wait 500ms before allowing DP event to cause resume.Edward Hill2020-10-301-2/+2
| | | | | | | | | | | | | | | | | Turning off the MST hub in S3 (via IOEX_HDMI_DATA_EN_DB) causes a VDM:Attention that immediately wakes us back up from S3. Wait 500ms after S3 entry before setting EC_MKBP_EVENT_DP_ALT_MODE_ENTERED in pd_notify_dp_alt_mode_entry(). BUG=b:167949458 BRANCH=zork TEST=powerd_dbus_suspend with display connected to MST hub DB Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I0d90d0a5130403b9aca1057725509814cac0d545 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2506424 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usb-pd: svdm_dp_attention used bit & instead of logical &&Denis Brockus2020-10-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | The code works the same but it is not clear why the && was not chosen and no comments to give a reason. Since both variables are always 0 or 1, the code will do exactly the same thing but this is really what is happening when you think about the logic behind this comparison. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I4daf780e370978b468a5d1c22536b904a591e089 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2490733 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Correct Enter Mode TBT payloadAyushee2020-10-211-15/+5
| | | | | | | | | | | | | | | | | | | | | | | According to Type-C ENGINEERING CHANGE NOTICE (ECN) "USB Type-C ECN Thunderbolt 3 Compatibility Updates for the document fix published by USB-IF, For Enter mode Thunderbolt payload, B25 - Active_Passive bit B24 - Thunderbolt Adapter This CL corrects setting B24 and B25 and sets lrx_comm(23), retimer_type(22), tbt_cable(21) irrespective of the cable speed. BUG=b:148534741 BRANCH=None TEST=Able to enter into Thunderbolt mode with Active and Passie cable Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I7fb29bea972f23ee0f87ee27ddcc1a50ce2d9a69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2481933 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TBT:Add support for exit mode SOP'/SOP'' on chipset transitionAyushee2020-10-141-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* USB-PD: Continue mode discovery after failureDenis Brockus2020-09-191-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pd_get_next_mode was searching the svid_mode_data looking for the next entry to discover, if there are any. Failed and needs discovery were handled the same way, return that entry. So if you had a discovery entry that fails that gets returned and causes the entry to stop, over and over again This issue was found using an ikling hub with attached AC connected to Morphius the SVID discovery finds two SVIDs, DP and Nintendo. The Nintendo fails and this caused the alt-mode to not enter for the valid DP mode. The change is to continue discovery even if there is a failure discovered. If any of the modes succeeded then it will be considered success if there are no new modes to discover. This is the order of returned values: no entries -> successful. an entry that need to be discovered -> return discovery entry. everything discovered properly in the list -> successful. discovered some good and some failed -> successful. all discovered fail -> return first fail. BUG=b:168804124 BRANCH=none TEST=verify morphius monitor when attached ikling powered hub Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Id2064079614c276f3d2054c5bcb194cdb997514c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2416990 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2:Correct get_usb4_cable_speed() functionAyushee2020-09-111-2/+2
| | | | | | | | | | | | | | | | | | | | | If a passive USB3gen2 cable NAKs to the discover SVID/mode query, we need to enter USB4 with USB3gen2 passive cable. When a cable NAKs to discover query, the port limits it's Thunderbolt speed to Passive Gen 2 cable speed. So, this CL modifies the get_usb4_cable_speed() function, to obtain the thunderbolt speed from get_tbt_cable_speed() instead of board_get_max_tbt_speed() function BUG=b:168060760 BRANCH=None TEST=Checked on volteer, able to enumerate the USB3Gen2 cables that NAKs to discover SVID query. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Id38ca12bb695ed256098d66b098aafa1bc75aed9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2404604 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* usb_mux: move usb_mux_set_safe_mode()Keith Short2020-08-241-19/+1
| | | | | | | | | | | | | | Move usb_mux_set_safe_mode() definition into usb_common.c so it's available to the test framework. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I789a470468ae441e366afbf94ce3c29db526dfd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370409 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPM common: Store number of Identity VDOsDiana Z2020-08-191-0/+1
| | | | | | | | | | | | | | Store the number of valid identity VDOs that were received for use later. BRANCH=None BUG=b:165264379 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I54f991c862c4b6589edff2476a79b5c3a8b69b4b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363416 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPM: Move dfp_discover_modes into usb_pd_policy.cAbe Levkoy2020-07-251-17/+0
| | | | | | | | | | | | | It is now only used by TCPMv1. BUG=b:152417597 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ifcb7023afabea16486d90336994c6cd93a96d69b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317903 Reviewed-by: Diana Z <dzigterman@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>
* usb_pd: Correct 'enter_tbt_compat_mode()' functionAyushee2020-07-081-2/+10
| | | | | | | | | | | | | | | Attempt to Enter Mode SOP'' with same object position and revision as SOP' since, the port doesn't query Discover SOP'' to the cable. BUG=b:158294748 b:150611251 BRANCH=None TEST=Able to enter into Thunderbolt mode for active cable. Change-Id: Ib1f58ff3bab78e1b0ace554ac63785b6e7baf192 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2274309 Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: Move 'is_vdo_present()' and 'is_usb4_vdo()' to TCPMv1Ayushee2020-07-061-22/+0
| | | | | | | | | | | | BUG=b:156749387 BRANCH=None TEST=make buildall -j Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I8ecffd3084de472ec3d145c3ff69df1ca2d89a56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2278562 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: Limit USB4 speed based on speed supported by portAyushee2020-07-061-27/+20
| | | | | | | | | | | | | | | | | | | For boards that do not support Thunderbolt compatible speed, shouldn't support USB4 speed as well. Hence this commit returns USB_R30_SS_U2_ONLY speed for boards not supporting Thunderbolt compatible speed. BUG=b:160273134 BRANCH=None TEST=Tested on Volteer with USB3 DB, able to enter into USB+DP mode with USB4 port partner and cable. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I14335ea28f0082b0f222ea2299b0d63e66e17697 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2277826 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: TBT: Cleanup limiting the cable speedAyushee2020-06-261-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | If the cable doesn't support Intel SVID, thunderbolt cable speed should be set to Passive Gen 2 cable. Ref: USB Type-C Cable and Connector Specification, Fig F-1. This Commit: 1. Removes setting the Thunderbolt cable speed if the Intel SVID is not supported on TCPMv1. 2. If, the cable doesn't support Intel SVID, set the maximum supported Thunderbolt cable speed according to the board's capability or TBT_SS_U32_GEN1_GEN2 cable speed 3. If, the cable supports Intel SVID, set the maximum supported Thunderbolt cable speed according to the board's or cable's capability. BUG=b:157671582 BRANCH=None TEST=Able to enter Thunderbolt-Compat mode for emark cable not supporting Intel SVID. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I1835f16dea755b96db127036350bdf60ba9c0734 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2259518 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* usb_pd: Remove pd_cable dependent Thunderbolt code from common codeAyushee2020-06-261-54/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Separated the common functions needed to check for port/cable's Thunderbolt mode compatibility back into TCPMv1. 2. Refactored the common Thunderbolt mode functions using pd_cable structure for mode information by adding a. Generic function that returns the Discover Mode response of specified SVID. b. Thunderbolt specific functiion that returns Discover Mode response of Intel SVID. 3. Removed the redundant pd_cable structure from DRP state machine policy engine. BUG=b:158294748 b:150611251 BRANCH=None TEST=1. Able to enter into Thunderbolt mode on TCPMv1 Change-Id: I30c8f1a007228408e08520502db00601ca3a2521 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2249020 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* usb_pd: Remove pd_cable usage from common codeAyushee2020-06-251-108/+73
| | | | | | | | | | | | | | | | | | | Previously, the Discovery Identity SOP' response for TCPMv1/2 was being stored in pd_discovery and in pd_cable. This commit removes the storage of Discover Identity SOP' response from the pd_cable structure. BUG=b:158294748 b:159504972 BRANCH=None TEST=1. Able to get the cable characteristics 2. Able to enter into Thunderbolt mode on TCPMv1 3. Able to enter into USB4 mode on TCPMv1 Change-Id: I1e5112f9aa158c41abb6226a3819f1612ed906bd Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2247211 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add some TODO bugs, fix indentAndrew McRae2020-06-251-1/+1
| | | | | | | | | | | | | | | | Add some TODO bugs, fix indents. BUG=b:159073520 TEST=Build all BRANCH=none Change-Id: Ic06450e50924bdcedd12829ba683cc6b3b308ae0 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2264693 Tested-by: Andrew McRae <amcrae@chromium.org> Auto-Submit: Andrew McRae <amcrae@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Refactor DP mode to use a state machineAndrew McRae2020-06-241-1/+7
| | | | | | | | | | | | | | | | | | | | | | | Refactor the DP alt mode handling to use a state machine to process the commands, ACKs and NAKs. Also add states to handle detecting a NAK on a DP mode enter command, and attempt to exit the mode and then retry. When a partner enters alt mode (e.g a monitor with DP alt mode), and the EC is reset or goes into recovery mode, the new negotiation will fail because the command to enter alt mode when the partner is already in that mode will fail with a NAK. BUG=b:159073520 TEST=Tested on duffy with a type-C monitor. BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I0b4506b17987ba71e51f019910db84b32a6da2c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2256620 Reviewed-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org>
* TCPMv2: Support mode entry for SOP' and SOP''Abe Levkoy2020-06-111-40/+54
| | | | | | | | | | | | | | | | | | | | | | Add a transmit type parameter to functions involved in mode entry; also add such a parameter to various functions calling those functions. For DisplayPort-specific definitions or calls, specify SOP; we do not currently support DisplayPort mode for cable plugs. For TCPMv1-specific code, specify SOP. TCPMv1 generally assumes that the discovery/mode structures are 1-dimensional, as they were previously, and changing that is outside the scope of this CL. BUG=b:155890173 TEST=Enter DP mode on Volteer with TCPMv2 TEST=Enter DP mode on Volteer with TCPMv1 TEST=Enter TBT mode on Volteer with TCPMV1 BRANCH=none Change-Id: I8afc75b3f3be8939c4645058ac4a31f24c88fb9e Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2229279 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* dp-hpd: abstract HPD gpio pinEric Yilun Lin2020-06-101-7/+19
| | | | | | | | | | | | | | | The HPD GPIO active level and naming may vary across boards. This CL abstract the layer for board customization by adding config CONFIG_USB_PD_DP_HPD_GPIO_CUSTOM. BRANCH=master BUG=b:154565980, b:150341271 TEST=ensure HPD works on asurada. Change-Id: I237c10722f13e5f31144e142f63e2694a23fe899 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2167128 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* TCPMv2: Separate DPM and DP from PEAbe Levkoy2020-06-101-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Create separate modules representing DisplayPort (which decides whether and how we can set up the DP alt mode) and the Device Policy Manager (which decides whether we should). The end goal is to have essentially all code with DP-specific decisions or information in the DP module and all code with DPM-specific decisions or information in the DPM module. This will allow the PE to map as directly as practical to its behaviors defined in the PD spec. Essentially detach PE_DO_PORT_DISCOVERY from the rest of the PE state machine in preparation for deleting it. This change paves the way for 1) Allowing the AP to drive mode entry and 2) Allowing new alt modes to be supported via largely self-contained modules. BUG=b:155890173 TEST=Attach DP dongle; observe discovery and DP setup via Twinkie BRANCH=none Change-Id: Ie63a2e62d1ac6178722477dc53244898a04ef92f Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2203842 Reviewed-by: Diana Z <dzigterman@chromium.org>
* usb_pd: Cleanup: Cable flagsAyushee2020-06-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | Instead of using CABLE_FLAGS_SOP_PRIME_ENABLE and CABLE_FLAGS_SOP_PRIME_PRIME_ENABLE cable flags, add the type of message to be transmitted directly in the message header. BUG=b:148528713 BRANCH=none TEST=1. make buildall -j 2. Able to enter DP mode with Type-C dock and Type-C to DP connector. 3. Able to enter Thunderbolt-Compatible mode with thunderbolt dock with both Active and Passive cables. 4. Able to Enter USB4 mode with USB4 device with thunderbolt Gen2 cable. Change-Id: Ib0cac818200e7ab8f73cace85ffee65203019709 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2159592 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* usb_pd: Move USB4 functions to common fileAyushee2020-06-051-0/+69
| | | | | | | | | | | | | | | | | Added a check for CONFIG_USB_PD_ALT_MODE_DFP in pd_send_enter_usb() and added separate configs for USB4 DRD and USB3.2 DRD BUG=b:148528713 BRANCH=none TEST=Able to enter USB4 mode with following passive cables - a. Rev 3 USB3.2 Gen 1, USB3.2 Gen 2 and USB4 Gen 3 b. Rev 2 USB3.1 Gen1/Gen2 Change-Id: I80c9b7569429bc54db08d78b5a6eee16780d6fe1 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051631 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* usb_pd: USB4: Limit the cable speedAyushee2020-06-051-12/+32
| | | | | | | | | | | | | | | | | | | | | | | Added 'get_usb4_cable_speed()' to return USB4 speed as per the port, the speed supported by DUT's port or cable speed whichever is lowest. Added configuring the cable speed in cros_ec_usb_pd_control according to the mux setting. Removed 'set_max_usb4_cable_speed()' to retain cable's actual VDO response. BUG=b:157671582 BRANCH=none TEST=1. Able to set USB4/USB3.2 Gen2 cable speed when DFP isn't gen 3 capable. 2. Able to limit cable speed according to the port, if the cable speed is higher. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I21bba7e5a2aa8ca54f304ef8418320f319f020b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2220826 Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: TBT: Refactor limiting the cable speedAyushee2020-06-051-3/+14
| | | | | | | | | | | | | | | | | | | | Refactored 'get_tbt_cable_speed()' to return thunderbolt-compatible speed as per the speed supported by DUT's port or cable speed whichever is lowest. Also removed 'usb_pd_limit_cable_speed()' to retain cables's actual VDO response. BUG=b:157671582 BRANCH=none TEST=Able to limit thunderbolt cable speed, if the cable speed is higher than the speed supported by DUT's port. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I77d3efddb425daa7bd12e9ed21be7088074285bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2227088 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* BB retimer: Correct setting USB4 cable speedAyushee2020-05-291-0/+31
| | | | | | | | | | | | | | | | For DFP, TBT/USB4_cable_speed_support is set according to a. Discover mode SOP' response for Thunderbolt-compat mode and b. Discover ID SOP' response for USB4 mode. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=make buildall -j Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Ic031489878dab701177936ea8e2f50d434dba25b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2152287 Reviewed-by: Keith Short <keithshort@chromium.org>
* BB retimer: For USB/DP/USB4, set 'Re-timer_Driver' bit based on SOP' VDO2Ayushee2020-05-271-0/+12
| | | | | | | | | | | | | | | For DFP, if the mux state is either USB/DP/USB4, then the re-timer_Driver bit is set according to the SOP' VDO2 response. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=Able to set Re-timer_Driver bit with a Gen3 Active cable Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Idb1134600617161137c6f500790b6c0c3b836200 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2152286 Reviewed-by: Keith Short <keithshort@chromium.org>
* BB retimer: Add 'USB3_Speed' bitAyushee2020-05-211-0/+16
| | | | | | | | | | | | | | | | | USB3_Speed bit is set to 1 if USB3 Gen1/Gen2 is supported. Hence, added functions to return cable rev 2.0 speed and cable rev 3.0 speed. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=Tested on volteer, with a Type-C dock, able to get USB3 Gen1/2 speed by checking "lsusb -t" on CPU console. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Idd7d7de3446e82ac81025cda36ee8a7e1f274138 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2139279 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* BB retimer: Add 'USB2_connection' bitVijay Hiremath2020-05-211-0/+8
| | | | | | | | | | | | | | | | | | USB2_CONNECTION bit is set to 1 if the cable is either Passive or a Gen3 active cable with USB2.0 support. Hence, added a function that indicates if the cable supports USB2 connection. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=Tested on volteer by connecting a dock using a Gen3 Active cable with a USB2.0 connected to the dock, able to set USB2_connection bit. Change-Id: I125182b23becaa7d00011f6eadb1916b48c79803 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2139278 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: Cleanup is_modal operation functionAyushee2020-05-151-2/+1
| | | | | | | | | | | | | | | | | | Removing CONFIG_USB_PD_TBT_COMPAT_MODE check as the enable_tbt_compat_mode() checks if CONFIG_USB_PD_TBT_COMPAT_MODE is enabled. BUG=b:148528713 BRANCH=none TEST=Tested with Thunderolt dock, able to enter Thunderbolt-Compatible mode. Change-Id: Id2b1f6a5ac53221f976becc753b17156b07c359d Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2128267 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* usb_pd_alt_mode_dfp: Move pd_set_svids_discoveryAbe Levkoy2020-05-121-9/+8
| | | | | | | | | | | | | Place it next to the other SVIDs accessor functions. BUG=none TEST=make buildall BRANCH=none Change-Id: I1ddfd5cc1d4617671e78c6405ddecc3d27be16fc Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2194260 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Implement mode discovery for port partnerAbe Levkoy2020-05-121-6/+85
| | | | | | | | | | | | | | | | Implement PE_INIT_VDM_Modes_{Request,ACKed,NAKed}. Store mode discovery state for each discovered SVID and provide accessors for that state. Consider transmit type when consuming modes. BUG=b:152420269,b:152419795 TEST=Attach port partner; TCPM discovers modes for previously discovered TEST=SVIDs and then continues with discovery/mode-entering process. BRANCH=none Change-Id: I72a605fa500e7eea0a5fa3b65a74d8b567a78751 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2174466 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Define fields for SVID discovery stateAbe Levkoy2020-05-121-32/+64
| | | | | | | | | | | | | | | Index discovery results by SOP type and track SVID discovery state for each type. Define accessors for this state and modify existing accessors to be SOP-type-aware. BUG=b:152419850,b:152418267 TEST=make buildall; attach port partner; observe discovery via Twinkie BRANCH=none Change-Id: I24ee19aac087c5752a3a822ab2b0c9da7a55af1b Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2174464 Reviewed-by: Diana Z <dzigterman@chromium.org>
* usb_pd: Move Thunderbolt-Compatible functions to common fileAyushee2020-05-041-3/+166
| | | | | | | | | | | | | | | | | Added 'get_tcpm_transmit_msg_type()' to return type of SOP message transmitted since, 'PD_HEADER_GET_SOP' is not a part of PD spec and TCPMv1 will return 0 irrespective of type of SOP message transmitted. BUG=b:148528713 BRANCH=none TEST=Able to enter Thunderbolt-Compat mode with both Active and Passive cable on TCPMv1. Change-Id: Ic53efeda9d9e012571f3047bc2a0d65969296b8c Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051630 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Store Tx type in PE stateAbe Levkoy2020-05-021-1/+4
| | | | | | | | | | | | | | | | | This will be used for VDM request state for discovery. Also change names of identity discovery timer and counter fields to comport with PD spec. This is substantially based on https://crrev.com/c/2148427. BUG=none TEST=make buildall BRANCH=none Change-Id: Iabda5c4cd169944a6c84bc72f551de7eb82ab424 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2174463 Reviewed-by: Diana Z <dzigterman@chromium.org>
* usb_pd_alt_mode_dfp: Don't store too many SVIDsAbe Levkoy2020-04-301-1/+1
| | | | | | | | | | | | | | | | | | Do not assume that the number of already-discovered SVIDs will be even. Protect against misbehavior by callers of dfp_consume_svids. BUG=none TEST=Implement discovery to incorrectly send Discover SVIDs indefinitely TEST=and run it against a device with only one SVID. Observe process TEST=exception. Apply this patch and no longer observe process TEST=exception. BRANCH=none Change-Id: I80c63b1d495b9726047ad7735070724574d9006b Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2162199 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* PD: Store cable identity in pd_discovery structureDiana Z2020-04-211-0/+14
| | | | | | | | | | | | | | Stores SOP' cable response in pd_discovery identity array. BRANCH=None BUG=b:152417977 TEST=on kindred with TCPMv2, ensure "pe" command shows correct information for cable and port partner Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia1186e25b92d9ae4f34e8c039b2ad1d1abbff9eb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2148426 Reviewed-by: Jett Rink <jettrink@chromium.org>
* PD: Use new structure for storing SOP identity responsesDiana Z2020-04-161-8/+39
| | | | | | | | | | | | | | | | Use the newly created identity_data structure to store the SOP discover identity response. For older boards which are almost out of static space, only allocate space for the SOP response. BRANCH=None BUG=b:152417977 TEST=on kindred with TCPMv2, confirm discovery can complete and correct data is given from the pe console command Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If63d9770bdfcc268734f7b45ce08a0a7abb396e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2130476 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv1/v2: Move pd_prepare_sysjump() to common fileVijay Hiremath2020-04-141-4/+27
| | | | | | | | | | | BUG=b:137493121 BRANCH=none TEST=make buildall -j Change-Id: I5123f26137d7590bcc00d86894eb981ac23d502a Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2140534 Reviewed-by: Keith Short <keithshort@chromium.org>
* PD: Move pd_discovery init out of dfp_consume_identityDiana Z2020-04-071-1/+0
| | | | | | | | | | | | | | | | | | | | | Moves initialization of pd_discovery from dfp_consume_identity in order to support folding the cable identity into the pd_discovery structure (the cable discovery may or may not precede partner discovery). Also removes a cable structure reset which would clear the cable during a power role swap, and unnecessary references to the TCPMv1 message ID trackers which are a part of the PRL in TCPMv2. BRANCH=None BUG=b:152417977 TEST=on kindred with TCPMv2, ensure discovery information is cleared when unpluggging discovered partner and inserting one with no discover identity response Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I646b3796704fb6980c64d1b9c60327abee19e371 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2130474 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* PD: Rename pd_policy to pd_discoveryDiana Z2020-04-071-51/+51
| | | | | | | | | | | | | | Rename struct pd_policy to struct pd_discovery to more accurately reflect what the structure contains. BRANCH=None BUG=b:152417977 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I51de48103053aa60b3cdb15cf9fbf15dd75d727a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2130473 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* usb_pd: Move cable communication functions to common fileAyushee2020-03-271-0/+47
| | | | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=Verified on TCPMV1 and TCPMv2, able to get correct cable characteristics. Change-Id: I812b21c87661952bf4e86acaa194d4b136371594 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051628 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* usb_pd: Move common alt mode DFP functions to it's fileVijay Hiremath2020-02-061-0/+340
| | | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I5a9a70095940aa57408685584352e602b42b298e Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2037133 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv1/v2: Move DFP alternate mode functions to common fileVijay Hiremath2020-02-041-0/+49
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I34bf543b381fc9e4f858a48d3d1568de42438509 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032725 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move dfp_discover_modes() to common fileVijay Hiremath2020-02-041-0/+13
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I83c6dca9652a9c613849b292b4c2329da3f9d424 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032161 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move dfp_consume_modes() to common fileVijay Hiremath2020-02-041-0/+17
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I0a587a68b5c814595d78905f1cdd611f710f2182 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032160 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move dfp_consume_svids() to common fileVijay Hiremath2020-02-041-0/+39
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I3ba96a803fa68d800a3ca41b4ac31e43325c0266 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032159 Reviewed-by: Keith Short <keithshort@chromium.org>