summaryrefslogtreecommitdiff
path: root/include/usb_pd.h
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* tcpc: change name of get_vbus_level to check_vbus_levelDenis Brockus2020-05-151-1/+9
| | | | | | | | | | | | | | | | | | | | this is to add near future functionality to allow not only the current PRESENT range check but to add Save0V range checking as well, for platforms that allow for this. This just lays the framework and is functionally equivalent. BUG=none BRANCH=none TEST=verify basic USB functionality Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I1eb3411bc3aa9b792c9b97799e1721e5cb229f64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2199036 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Implement mode discovery for port partnerAbe Levkoy2020-05-121-3/+41
| | | | | | | | | | | | | | | | 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-35/+73
| | | | | | | | | | | | | | | 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>
* tcpmv2: warm start DBG_ACC_SNK correctlyDenis Brockus2020-05-111-0/+1
| | | | | | | | | | | | | | | | | | | DBG_ACC_SNK connections are warm starting in ATTACHED_SNK and this is not correct. Added BBRMFLG to keep track and jump back to the correct SNK entry state. BUG=none BRANCH=none TEST=connect a DBGACC and reboot should reconnect DBGACC Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I4a17c2487a18ed0e4d58954e8d5ade08b4d44fff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2191815 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* usb_pd: Move Thunderbolt-Compatible functions to common fileAyushee2020-05-041-0/+66
| | | | | | | | | | | | | | | | | 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-3/+0
| | | | | | | | | | | | | | | | | 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>
* it83xx tcpc: Captured received SOP message typeKeith Short2020-05-011-1/+1
| | | | | | | | | | | | | | | | | | | Add support to the IT83xx TCPC driver to capture the received SOP messaage type, matching the implementation of all other TCPC drivers. This change also does a minor cleanup of the PD_HEADER_SOP macro to ensure callers cannot overflow the field. BUG=none BRANCH=none TEST=make buildall -j Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I63d324761538c6fe1ae6cee9ad172ee052c474b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2173303 Tested-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* TCPMv1: skip cable probing when not VCONN sourceKeith Short2020-04-281-4/+1
| | | | | | | | | | | | | | | | | | | | | | USB PD specification only permits the port that is currently sourcing VCONN to send SOP' and SOP'' messages to the cable. Ensure USB4 and TBT modes are not probed or entered if the EC is not sourcing VCONN. BUG=b:155073708 BRANCH=none TEST=make buildall TEST=connect Gatkex board to Volteer, with PD analyzer observe that when Gatkex claims VCONN source, EC code skips all SOP' messages but otherwise completes PD discovery. TEST=connect TBT dock, verify SOP' messages sent and TBT mode is entered. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ie7cf2910c0d9d78ba809ca25943585cfc96031a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2169476 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Ayushee Shah <ayushee.shah@intel.com>
* TCPMv2: Cleanup: Ensure PD_FLAGS_* are not used.Edward Hill2020-04-251-22/+4
| | | | | | | | | | | | | | | PD_FLAGS_* are TCPMv1 only, so make sure they are not used with TCPMv2. BUG=none BRANCH=none TEST=none Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I7a119c9745b0004b6067862205f185557f704cb5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2161923 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpci: Add trigger for VBUS presence changesAseda Aboagye2020-04-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | Some boards don't have a direct interrupt indicating ACOK, but the TCPC can provide this notification via the POWER_STATUS register. This commit adds a lightweight trigger which calls board_vbus_presence_change() whenever the TCPC gets a POWER_STATUS alert. The default implementation does nothing, but a board may override it to make it useful. BUG=b:154113446,b:154113465 BRANCH=None TEST=Add override for waddledoo. Build and flash waddledoo, plug in AC, verify that "AC on" prints are seen. Unplug AC, verify that "AC off" prints are seen. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I6ab1a2649c12a0525502eac6baab2e1b31168212 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2159941 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Remove storage for SOP'' discoveryDiana Z2020-04-211-1/+1
| | | | | | | | | | | | | | SOP'' cable plugs aren't required to respond to Discover Identity, so removing storage for the SOP'' response. BUG=b:152417977 BRANCH=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ic51e3ed647d5bca45848fb878698673b27591cd1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2155123 Reviewed-by: Jett Rink <jettrink@chromium.org>
* USB/PD: Skip pd_prepare_sysjump for EFS2 boardsDaisuke Nojiri2020-04-211-2/+0
| | | | | | | | | | | | | | | | | | | | | | Since in EFS2, USB/PD won't be enabled in RO or if it's enabled in RO, EC won't jump to RW, pd_prepare_sysjump is not needed. Even if PD is enabled because the device is not write protected, EFS2 jumps to RW before PD tasks start. So, there is no states to clean up. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:1072743, b:137493121, b:154440914 BRANCH=none TEST=Boot Puff successfully. Change-Id: Ie598105779d2a605cb63842cb6c8428f0e2c5367 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2157728 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Kangheui Won <khwon@chromium.org> Commit-Queue: Kangheui Won <khwon@chromium.org> Tested-by: Kangheui Won <khwon@chromium.org>
* PD: Use new structure for storing SOP identity responsesDiana Z2020-04-161-2/+41
| | | | | | | | | | | | | | | | 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-0/+7
| | | | | | | | | | | 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>
* TCPMv2: Send VDM version according to PD rev setDiana Z2020-04-081-14/+2
| | | | | | | | | | | | | | | | | Sets the VDM version field according to the PD revision being used for the port and type. Also removes the pd_get_rev() declaration from the usb_pd header as it's only used in the TCPMv1 protocol file. BRANCH=None BUG=b:150784275 TEST=on kindred with TCPMv2, confirm VMDs sent to PD 3.0 partner are versioned as VDM 2.0 and PD 2.0 partner is versioned as VDM 1.0. Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ibff3f020ecf494773da7038c59d50667cd40bfa7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2136904 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* PD: Create unified structure for all SOP* identityDiana Z2020-04-071-52/+22
| | | | | | | | | | | | | | | | | Creates a structure to be used by all SOP* types to store identity information. Combines the full response size storage currently used for SOP, as well as some of the structure accessibility introduced with the cable attributes. Currently not all product type VDOs have defined structures, but these may be added as needed by the code. BRANCH=None BUG=b:152417977 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I7b57b43447653dfbe1024b8fe71375916e0821b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2130475 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* PD: Rename pd_policy to pd_discoveryDiana Z2020-04-071-7/+7
| | | | | | | | | | | | | | 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>
* TCPMv2: Restore PD state after SysjumpSam Hurst2020-04-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a PD explicit contract is negotiated in RO, the contract is maintained while performing a sysjump to RW. This is done by serializing the PD Power, Data, and VCONN Roles, along with the explicit contract flag. After jumping to RW, deserialization is performed by restoring the power roles and setting the explicit contract flag. BUG=b:152350558,b:152027807,b:152967274 BRANCH=none TEST=make -j buildall Manual tests: Used total phase to verify that charging voltage was maintained across sysjump from RO to RW and that DP was reestablished when a dock was used. Tested that Kohaku booted properly without a battery and a charger connected to port 0. This test was repeated with a charger connected to port 1. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I349c41f2279e9af9830564d44ac73ad8435f1f80 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2119131 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usb_pd: Move cable communication functions to common fileAyushee2020-03-271-0/+22
| | | | | | | | | | | | | 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-C: Determine port partner's data role based on PD's data roleVijay Hiremath2020-03-191-7/+0
| | | | | | | | | | | | | | | | | | | | | Current code uses the CC lines to find out the data role of a port partner, however when the PD based data role swap happens DR_swap command has no effect on the CC lines. Hence need to use PD's data role to determine port partner's data role. Reference: USB Type-C cable and connector specification, Release 2.0 4.5.1.4.2 USB PD-based Power Role, Data Role and VCONN Swapping Table 4-12 USB PD Swapping Port Behavior Summary BUG=b:151653348 BRANCH=none TEST=UFP/DFP is correctly configured hence no PMC timeout errors observed on Volteer. Change-Id: I237d5c3f88096f4bd2d043ab823c98fe47686fa9 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2107890 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Allow reduced functionality to PD2.0 featuresSam Hurst2020-03-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Some TCPCs only work with PD2.0 messages. So a config flag is added to restrict the TCPMv2 stack to working at PD2.0 revision. If the config flag is defined, the PD revision is fixed at PD2.0. In a future CL, the config flag can also be used to reduce code size by not compiling in PD3.0 features. BUG=chromium:1021235 BRANCH=none TEST=make -j buildall Manual tests: Verified that the stack only works at PD2.0 rev, using a twinki and several docks. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ic5fc8d24baec3bdecffb4dd54a6aac28d72550cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032145 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
* TCPMv2: Probe cable identity in PE_SRC_DiscoveryDiana Z2020-03-061-7/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds probing of the cable identity during startup as a source. There is no timing requirement for message spacing when sent from discovery, but this change starts with DiscoverIdentityTimer spacing to avoid spamming the cable too quickly. This can be tuned later if desired. When the port partner is running PD 2.0, the communications with the cable must also use PD 2.0. Otherwise, communications may be whatever revision the cable responds with. This change also corrects the tVDMBusy timer, which is 50 ms in both the PD 2.0 and PD 3.0 specs, and only clears discovery information when not power swapping. BUG=b:148834626 BRANCH=None TEST=on kindred, confirmed: 1. cable was probed during startup on connection as source a. cable probing stopped after an ACK b. cable probing did not continue past 20 messages with no GoodCRC 2. cable was note probed during startup as sink (charger connected) Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I65979f30d26ad8a37f507994a24ddc86c5cb41ff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2084012 Reviewed-by: Jett Rink <jettrink@chromium.org>
* common/system: Unify ec_current_image and system_image_copy_tTom Hughes2020-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "enum ec_current_image" is exposed in ec_commands.h (and used by non-EC code, such as biod). We also have an "enum system_image_copy_t" that is the exact same thing (though has a few more definitions). A followup CL (I714b6bd8c0d7192386404c25a831e38438fa5238) adds the "sysinfo" host command, so we want to be able to expose all the potential image variants. Rather than maintain two enums that can potentially get out of sync, unify the code to use a single enum. We choose to keep the "enum ec_current_image", since external code depends on it. To verify that this change results in no changes to the generated binaries: ./util/compare_build.sh --board all BRANCH=none BUG=b:146447208 TEST=./util/compare_build.sh --board=all Change-Id: I13776bc3fd6e6ad635980476a35571c52b1767ac Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2036599 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* usb_set_suspend: Use "enable" consistentlyAbe Levkoy2020-02-271-2/+2
| | | | | | | | | | | | | | The port is enabled when suspend is not enabled and vice versa. Avoid confusing these idioms. BUG=none TEST=make buildall BRANCH=none Change-Id: I3063793334ac875afee8a176f96625e8903d2694 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2057979 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_set_polarity() to common fileVijay Hiremath2020-02-241-0/+8
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: Idf6908bfc3e79a960a7de6e4249c2f50b41b56e6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2052645 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv1/v2: Move pd_is_try_source_capable() to common fileVijay Hiremath2020-02-191-0/+5
| | | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I79f75d23f6091a264c11b4da6cf0cea26205df60 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2052648 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* nct38xx: auto-toggle exit cleanupDenis Brockus2020-02-151-9/+0
| | | | | | | | | | | | | | | | | | Don't set the polarity behind the back of the PD stack. Just clear the DRP and leave the CC lines so they look just as we found them. This will allow TRY to work and we will no go OPEN because we set the CC lines to something that was not expected. BUG=b:149415919 BRANCH=none TEST=verify USB-C connections are working Change-Id: I766514bd46922000ea8916d61d00265e7e5e4fd4 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2053461 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv1/v2: Move PD & Partner type detection code to common fileVijay Hiremath2020-02-141-2/+2
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: Icb9dfe998df889e8e2d6de7776d9889295115708 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2052644 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Reduce number of arguments of pd_build_request()Vijay Hiremath2020-02-141-6/+0
| | | | | | | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=Manually tested on Volteer 1. When only one charger connected: Able to negotiate to PD max. 2. When two chargers are connected (one on each port): Non charging port is rejected Swaps the charging port based on charger's priority Change-Id: Ib7fdc5d31bf36189a85f8cd3217bec78f83a9efe Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051318 Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpmv2: make connect after auto-toggle driver specificDenis Brockus2020-02-131-0/+9
| | | | | | | | | | | | | | | | | | | | | nct38xx needs to have the cached polarity set in order to leave DRP mode without going back to an OPEN line. Other TCPCI implementations break when this happens. So moved it to a driver specific function instead TODO(b/149415919): Consider trying to clear the DRP mode instead of changing the polarity BUG=b:149311437 BRANCH=none TEST=verify charger functions on Trogdor Change-Id: I5092a468d860b573a6e5acaf7c013b3425916efb Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2050336 Tested-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Diana Z <dzigterman@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv1/v2: Move pd_process_source_cap() to common fileVijay Hiremath2020-02-121-0/+10
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I6bd6b5875a322ca4ba6d77a4cfc96a72630e5f5c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051220 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_check_requested_voltage() to common fileVijay Hiremath2020-02-121-1/+1
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I5ba854552b5c6124e3c6758273651edc0e3c23ae Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051214 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move "pdcable" console command to common fileVijay Hiremath2020-02-071-0/+10
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I7f78efeb74536d5d6c5dd0b4bd5f32325c1500ec Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2036604 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move dfp_discover_modes() to common fileVijay Hiremath2020-02-041-0/+9
| | | | | | | | | | | 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/+9
| | | | | | | | | | | 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/+9
| | | | | | | | | | | 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>
* TCPMv1/v2: Move dfp_consume_identity() to common fileVijay Hiremath2020-02-041-0/+9
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I5b0bbd553cbe4fc76478b1c89b0f3f391f074a27 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032158 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_dfp_exit_mode() to common fileVijay Hiremath2020-02-041-0/+8
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I9d6a219ae031ed9954819c12563867e07bcc8668 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032157 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_dfp_enter_mode() to common fileVijay Hiremath2020-02-041-0/+16
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: Id1d3e8bc27d895a53b53a77cf1c8fd36c69b47dc Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032156 Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd TCPMv1: Maintain independent MessageId for SOP''Ayushee2020-02-031-6/+35
| | | | | | | | | | | | | | | | | | | This patchset enables checking and storaging the MessageId counter received from the SOP'' messages. Since SOP*(Cable) communication and SOP(Port Partner) have separate MessageID counters, it is necessary to store separate messageIDs to avoid the the incoming packets from getting dropped. BUG=b:148481858 BRANCH=None TEST=Tested on Volteer, able to maintain separate MessageId count for SOP, SOP' and SOP'' communication. Change-Id: Id3a29594c5f9b354ecb650c6d351b16883d2126b Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2032344 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1: Add support for Thunderbolt active cablesAyushee2020-01-311-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | For entering into Thunderbolt-Compatible mode with active cable, the port sends Enter mode command for SOP', SOP'' (if the cable has a SOP'' controller) and SOP respectively. If the port doesn't receive GoodCRC from Enter Mode SOP'', the port resets the cable characteristic and exits the Thunderbolt-Compatible mode discovery. This CL enables SOP'' communication with the cable plug and adds support to enter into Thunderbolt-compatible mode with active cables. BUG=b:140643923 BRANCH=None TEST=Able to enter into Thunderbolt-Compatible mode for active cables. Change-Id: Iea0c652043933047e0158265c911775d4afe5758 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2001938 Reviewed-by: Diana Z <dzigterman@chromium.org>
* usb_pd TCPMv1: Maintain independent MessageID for SOP PrimeAyushee2020-01-311-0/+22
| | | | | | | | | | | | | | | | | | | This patchset enables storage of MessageId counter received from the cable plug. Since SOP*(Cable) communication and SOP(Port Partner) have separate MessageID counters, it is necessary to store separate messageIDs to avoid the the incoming packets from getting dropped. BUG=b:148481858 BRANCH=None TEST=Tested on Volteer, able to maintain separate MessageId count for SOP and SOP' communication. Change-Id: Iac2dc616f99a9e19914588e59441df8b09068afa Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2026650 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1: Add support for USB4.0Ayushee Shah2020-01-311-18/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USB4 is based on the Thunderbolt 3 protocol specification. It supports 40 Gbit/s throughput, is compatible with Thunderbolt 3, and backwards compatible with USB 3.2, USB 2.0. USB4.0 PD Flow: Ref: USB Type-C Cable and Connector Specification 2.0 Figure 5-1 USB4 Discovery and Entry Flow Model USB PD Explicit Contract Discover ID SOP -------- USB4 compatible? | -------------yes------------|------No----- Exit USB4 Discovery | Discover ID SOP' --------- Product type | Passive cable----------|----Active Cable---USB4? | | | (Not implemented in this CL) USB Signaling ----------------------- | | | | USB4 with USB4 active cable Exit USB4 | Discovery --------------------------------------------- | | | | USB4 Gen3 USB3.2 Gen2 USB3.2 Gen1 USB2.0 | | | | Enter USB4 with | Enter USB4 with Exit USB4 Discovery USB4 Gen3 | USB4 Gen1 Passive cable | Passive cable | DFP Gen3 capable? | ------yes---- |---------No-------- | | Discover SVID SOP Enter USB4 with USB3.2 Gen2 Passive Cable | Discover SVID SOP' | Discover Mode SOP | Discover Mode SOP' --------Is TBT3? | -----yes----|-----No---- | | Enter USB4 with TBT3 Enter USB4 with TBT Gen3 passive cable Gen2 passive cable BUG=b:140819518 BRANCH=None TEST=With Gatkex creek 3 device, TGLRVP can enter to USB4.0 mode Change-Id: Id861661c66c53a0a32679388bb7e2e81aae3ceb5 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1926382 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv1/v2: Move EC_CMD_USB_PD_CONTROL host command to common fileVijay Hiremath2020-01-301-2/+61
| | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: Iadb75b9b187a0444c445c2641ec71d592cf4ac92 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2013228 Reviewed-by: Keith Short <keithshort@chromium.org>
* PD 3.0: Add AMS start detection to collision avoidanceDiana Z2020-01-291-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an explicit contract is in place for PD 3.0, the source shall control the Rp value in order to facilitate collision avoidance. When the value is set to 1.5 A, the sink can only respond to an existing AMS, and not start a new one. An Atomic Message Sequence (AMS) is defined as "a Message sequence that starts and/or ends in either the PE_SRC_Ready, PE_SNK_Ready or PE_CBL_Ready states." This means any given PD message may be starting an AMS (requiring the source to set Rp, and sink to check the CC level) or it may be a response within an AMS (in which case, sink may send regardless of CC levels). This change adjusts the pd_transmit() calls to indicate whether any given PD message is the beginning of an AMS. There are many AMS's defined, which may be found in section 8.3.2 of the PD 3.0 spec. Anytime the source returns to its ready state, it will reset Rp to reflect that the sink may start an AMS. Additionally, this removes the buffer for sending PD messages. If an AMS cannot be started, then it's better to fail the send so the pd_task state machine can handle the unsent message. BRANCH=None BUG=b:64411727, b:147476471 TEST=Tested with bip board with PD 3.0 config using 2 different PD 3.0 hubs. Monitored Twinkie output with hubs acting as source, sink, and power swapping to source. Also turned off PD 3.0 to ensure PD 2.0 behavior with the hubs was unaffected. TEST=Tested on volteer board with PD 3.0 config using Thunderbolt capable dock. Change-Id: Ib02670add1a125217a981a846e6e2c31681de169 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1246273 Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* TCPMv1: Cleanup sending TBT control flags to hostVijay Hiremath2020-01-291-1/+1
| | | | | | | | | | | BUG=b:148114593 BRANCH=none TEST=tested on Volteer, able to get correct TBT control flags Change-Id: If673d4a194d3cc6b9579f0f32511c6363f2614f3 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2013825 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move EC_CMD_USB_PD_GET_AMODE host command to common fileVijay Hiremath2020-01-281-0/+37
| | | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: I0b9cb76adbc5e385cb20256f693bd2b0687b30de Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2024428 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv1/v2: Move EC_CMD_USB_PD_DISCOVERY host command to common fileVijay Hiremath2020-01-281-0/+8
| | | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: Ia2ad22669a908e9b9c23c4b73e97872399049e75 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2024427 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv1/v2: Move EC_CMD_USB_PD_DEV_INFO host command to common fileVijay Hiremath2020-01-241-0/+11
| | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: If9d902ef77da7d56a123c0c78b1ebbcd0d95bc3b Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2008301 Reviewed-by: Keith Short <keithshort@chromium.org>