summaryrefslogtreecommitdiff
path: root/test/fake_usbc.c
Commit message (Collapse)AuthorAgeFilesLines
* TCPM: Rename enum tcpm_sop_type and its constantsAbe Levkoy2021-08-311-3/+3
| | | | | | | | | | | | | | | As a followup to CL:3104290, give the TCPCI TRANSMIT and RX_BUF_FRAME_TYPE types more consistent names. Most of them can be used for receiving, not just transmitting. Fix lint errors thus revealed. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I399ec479eacc18622fc4d3f55f8bdabf4560fcff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3125995 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPM: Rename enum tcpm_transmit_typeAbe Levkoy2021-08-181-3/+4
| | | | | | | | | | | | | | | Rename tcpm_transmit_type to tcpm_sop_type to reflect that it can be used for Rx as well. Describe it in comments. This prepares to consolidate enum pd_msg_type into this enum. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ife97d4ad51c48f2e832b94e007954919e236a309 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3104290 Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpmv2: Don't enable USB mode until PD state resolvedKeith Short2021-06-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | Don't enable USB superspeed signals until the PD capability is known. This fixes an issue where platforms that enable the virtual USB mux violate the tSenderResponse timeout when the attached SRC sends the Source Capabilities message. BUG=b:187796705 BRANCH=none TEST=Volteer - connect PD charger, obsserve no hard reset TEST=Connect non-PD USB device, verify USB mode is enabled TEST=Connect USB+DP monitor, verify DP mode entry and USB mode enabled TEST=Connect USB4 dock, verify USB4 entry TEST=faft_pd test suite passes on Voxel Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I4be08874178d1e225cf41939b9626a81b0da0524 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2895424 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: caveh jalali <caveh@chromium.org>
* TCPMv2: Source out 3.0 A to non-PD portsDiana Z2021-02-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | When no PD sinks require 3.0 A and no FRS ports require it, offer this current level to non-PD sinking devices. The non-PD devices will be downgraded whenever a higher-priority type of port is connected. BRANCH=None BUG=b:141690755 TEST=on madoo, verify: - plugging in a flash drive, it is offered 3.0 A - plugging in a 3.0 A PD sink, flash drive CC resistor is downgraded - unplugging 3.0 A PD sink, flash drive CC resistor is back to 3.0 A - connect power to 3.0 A PD sink, flash drive CC resistor is back to 3.0 A With FRS config check commented out, verify: - flash drive is downgraded and FRS enabled on powered hub plug in - flash drive is back to 3.0 A on FRS hub detach Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iaa5c3f0a6a4f41db83978bb1e1d0b54f2519abb2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2692030 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Allocate FRS ports 3.0 A when neededDiana Z2021-02-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When there are no PD sinks requiring 3.0 A, any FRS ports which require that much current will have FRS detection enabled. If a PD sink requiring 3.0 A is attached, then FRS detection will be disabled on that port again. FRS port partners which require only USB or 1.5 A of current will always have FRS detection enabled. BRANCH=None BUG=b:141690755 TEST=on volteer-based system, verify: - FRS source partners requiring 1.5 A or less always have FRS detection enabled - FRS detection is disabled on detach - FRS source partner requiring 3.0 A has FRS detection enabled if no PD sink needing 3.0 A is present - Plugging in a 3.0 A PD sink disables FRS detection for the 3.0 A FRS partner - Unplugging a 3.0 A PD sink enables FRS detection for the 3.0 A FRS partner - When FRS occurs on 3.0 A port with detection enabled, partner is offered appropriate starting current in first source caps Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ib067ac7c1c2f4a6e64f36aeffd1b8dde5cb93760 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2676084 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Eric Herrmann <eherrmann@chromium.org> Tested-by: Eric Herrmann <eherrmann@chromium.org>
* TCPMv2: Update source-out configsDiana Z2020-12-241-0/+6
| | | | | | | | | | | | | | | | | | | | Now that the DPM will be handling source-out decisions for TCPMv2, remove references to its old configuration options from TCPMv2 boards in order to avoid any confusion as to what code is running now. Also remove the charge manager notifications of sink attach/detach since the policy is being centralized into the DPM. Note that the previous configuration options only ever allocated one 3.0 A port, and so the default number of 3.0 A ports has been set to 1. BRANCH=None BUG=b:168862110,b:141690755 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie452e3da32b04226503539daa67b6b9f4a58aa58 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2597431 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: DPM sourcing policy - 3.0 A PD sinksDiana Z2020-12-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | Move the sourcing policy from the charge_manager to the DPM for TCPMv2. The first step of this policy will be to allocate 3.0 A only if a peripheral reports requiring more than 1.5 A in their Sink Capabilities vSafe5V operational current. For this commit, leave in some charge_manager APIs for linking which will be re-named or removed later. BRANCH=None BUG=b:141690755,b:168862110 TEST=on drawcia verify: - non-PD sink only offered 1.5 A Rp - PD sink requiring 1.5 A or less Rp isn't offered 3.0 A - PD sink requiring 3.0 A is offered a new 3.0 A Source Capability after sink capability probing. Port continues to receive 3.0 A over both hard and soft resets. - When 2 3.0 A sinks are plugged in, only the first is offered 3.0 A. After the first is unplugged, the second receives a 3.0 A source capability message Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iec48312df1125086db2919c1503c7ba31fe12bcc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2597429 Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpci: Base retry count on active PD revAbe Levkoy2020-12-151-0/+5
| | | | | | | | | | | | | | | Retry twice when operating at PD 3.0 and thrice when operating at PD 2.0. Provide a TCPM-agnostic interface to get the number of retries. BUG=b:173025773,b:173025737 TEST=Pass TD.PD.LL.E3 Soft Reset Usage and TD.PD.LL.E4 Hard Reset Usage BRANCH=firmware-volteer-13521.B-master Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I422447718f1bfc9a9d4f8ffc5b284723a5332833 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2578201 Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* TBT:Add support for exit mode SOP'/SOP'' on chipset transitionAyushee2020-10-141-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Add common function for DPM entry and exit modeAyushee2020-07-171-5/+1
| | | | | | | | | | | | | | | | Added a common entry point into DPM for entering or exiting modes. BUG=b:155890173 BRANCH=None TEST=Tested on volteer, able to enter and exit 1. DisplayPort mode with type-C dock 2. Thunderbolt mode with a Thunderbolt dock Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I3bb996d96d0fff543ad7a2e1dc8e09d0b17d0171 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2299840 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add common exit mode for all the alternate modesAyushee2020-07-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Refactor DP mode to use a state machineAndrew McRae2020-06-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | 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: cache analog and collision Rp in CLDenis Brockus2020-06-111-0/+16
| | | | | | | | | | | | | | | | Adding update_cc mechanism to keep correct Rp set BUG=b:158291622 BRANCH=none TEST=check Rp value over attach, hard reset and pr-swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I369c71e637cbb6a8fc37b434194ce39cc9bf5417 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2232830 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: Separate DPM and DP from PEAbe Levkoy2020-06-101-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* TCPMv2: Wait for Safe0V on PR Swap SNK to SRC before PS_RDYDenis Brockus2020-06-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | We were out of spec for PR Swap transitioning from SNK to SRC by sending PS_RDY before we were Safe0V. We only waited for the TC state machine to go from attached.snk to attached.src, which happened on the first state machine tick after pe_prs_src_snk_transition_to_off_entry was called and this does not guarantee Safe0V as is needed. Added an extra state to reflect what the PD spec requests and now waiting for Safe0V before indicating we are powered off. BUG=b:157755939 BRANCH=none TEST=ThinkPad Dock G2 should attach Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I93eb36acc64f273e8b30ca0a0bb76d6fa96b64ba Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2223723 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Aborted PR Swap should not re-enable AutoDischargeDenis Brockus2020-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On a recovery path exit a TCPCI I2C FAULT occurs when we set the CC lines to open/open if AutoDischargeDisconnect is currently enabled. The TCPCI I2C FAULT is not a status of the I2C interface but rather a status of the last TCPCI I2C write performed with regards to the current state/settings of the TCPCI. This is usually caused when AutoDischargeDisconnect is enabled/disabled when it should not be. This change will make sure this path will not re-enable and that entering the recovery path will make sure AutoDischarge is disabled. We will wait to re-enable until the TC state machine is restarted. BUG=b:157755939 BRANCH=none TEST=ThinkPad Dock G2 attach should not cause FAULT-0x01 Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: If70ccd90b045949e54c131512d1fb294c61dd1dd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2223722 Tested-by: 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> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Move sink hard reset recovery into TCDiana Z2020-05-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | The PD spec requires that PE_SNK_Transition_to_default exits when the sink has reached the default level. Change how the TC handles sink hard resets to wait on notifying the PE hard reset is complete until Vbus has returned. BRANCH=None BUG=b:155923935,b:153593929 TEST=on kindred with TCPMv2, ensure: - port goes unattached after removing suzy-q - hard reset as source succeeds, gets back to SRC_Ready - hard reset as sink succeeds, no extra hard resets sent while source is recovering Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I60427204380067fc5ee36432eab0146a9ab0687b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2202077 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: SNK HardReset cleanup - fix final commentsDenis Brockus2020-05-011-1/+4
| | | | | | | | | | | | | | | | | | | | After CL:2172063 was submitted there were a couple of comments that needed to be addressed. This CL is to finish off the SNK HardReset cleanup BUG=b:154073581,b:154622375,b:154937258 BUG=b:154778807,b:155132904 BRANCH=none TEST=verify charger is still detected after hardreset Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ieb628eec1ca8be0e1ea5abb155ab1a7926626567 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2171883 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: SNK HardReset cleanupDenis Brockus2020-04-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tc_hard_reset tells tcpc we are starting a hard reset. It now disables AutoDischargeDisconnect and sets the flag to put TC in reset. When this happens, TCPC should not go to an unattached state. tc_hard_reset_complete was added to tell the TCPC we are done with the hard reset and going to an unattached state is allowed again. It enables AutoDischargeDisconnect and clears the flag that blocked the TCPC from going to an unattached state. hard reset changes the TCPCI mask register to be their default values. Alert will now detect this and will make sure the TCPC is initialized and back to what we expect it to be. BUG=b:154073581,b:154622375,b:154937258 BUG=b:154778807,b:155132904 BRANCH=none TEST=verify charger is still detected after hardreset Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I3e1dd04b04653b8fca5dccc9373533d5a5ff9586 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2172063 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Configure PE test for alternate modesDiana Z2020-04-161-5/+0
| | | | | | | | | | | | Configures the TCPMv2 PE test to build the alternate mode code. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I4cb5824875e2a4b4e93fbae0a4d8762195b987f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2137258
* TCPMv2: Add pd console commandSam Hurst2020-04-141-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add pd console commands that enables the device to work with PD FAFT. Other pd commands such as bist, vdm and ping will be added in another CL. BUG=b:151481791 BUG=chromium:1021235 BRANCH=none TEST=make -j buildall manual: Verified that system: pd tryscr 0 - did not trysrc pd tryscr 1 - did trysrc pd tryscr 2 - normal trysrc operation pd 0 tx - started as snk pd 0 charger - started as src pd 0 dev 5 - charged at 5V pd 0 dev 12 - charged at 12V pd 0 dev 15 - charged at 15V pd 0 dev 20 - charged at 20V pd 0 disable - pd was disabled pd 0 enable - pd was enabled pd 0 soft - sent soft reset pd 0 hard - sent hard reset pd 0 dualrole off - stayed in src and switched to snk on disconnect pd 0 dualrole on - toggled from snk to src and vice versa pd 0 dualrole sink - was a sink only pd 0 dualrole source - was a source only pd 0 dualrole freeze - stayed in current power role and switched to snk on disconnect pd 0 swap power - initiated a power role swap pd 0 swap vconn - initiated a vconn swap pd 0 swap data - initiated a data role swap Change-Id: Id1542001c0e52d1d5bfbc5b9cb826b9a204e5b2e Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1962506 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: move function from TC layer to PEJett Rink2020-04-031-11/+0
| | | | | | | | | | | | | | | | | | | | | - Move pd_ function that belong in PE layer to PE layer. Remove the extra pe_ layer. - Remove unnecessary PE and Vconn ifdef guards in TC layer - Remove unused print_dev_info function - Move host commands in TC layer to host command file - Move RW hash stuff from TC to PE, since this only has to do with VDO (Which is a PE layer thing) - Removed dependency for tc_drp test on usbc_fake as we don't really need it anymore once we don't pull in the PRL and PE layers anymore (based on previously landed CLs) BRANCH=none BUG=b:153071799 TEST=everything still builds and passes tests Change-Id: Id1d1efa291c3525f57bc26af9fddda6ddace1b58 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2132871
* TCPMv2: Restore PD state after SysjumpSam Hurst2020-04-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | 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>
* cleanup: drop the _TYPEC part of USB device configJett Rink2020-03-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | The three USB device configurations describe more than just the Type-C layer, so remove the _TYPEC part within the define. This is also in preparation to change how the usbc build.mk includes files. This was performed with the following commands: $ git grep --name-only CONFIG_USB_TYPEC_DRP_ACC_TRYSRC | xargs perl -i -ple 's/CONFIG_USB_TYPEC_DRP_ACC_TRYSRC/CONFIG_USB_DRP_ACC_TRYSRC/g' $ git grep --name-only CONFIG_USB_TYPEC_CTVPD | xargs perl -i -ple 's/CONFIG_USB_TYPEC_CTVPD/CONFIG_USB_CTVPD/g' $ git grep --name-only CONFIG_USB_TYPEC_VPD | xargs perl -i -ple 's/CONFIG_USB_TYPEC_VPD/CONFIG_USB_VPD/g' BRANCH=none BUG=none TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I4deab784b7c3479cffd3dee7fb3ea3c8a9d6081c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2121193 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Not enable PD comm on TX Phy reset if not in a connected stateWai-Hong Tam2020-03-241-6/+9
| | | | | | | | | | | | | | | | | | | | | | | If PD is not in a connected state, the previous approach was to enable PD comm on TX Phy reset and then disable it later (the SM_RUN case in prl_run()). In this short period of time, the TCPC wil respond GoodCRC to the PD message and the PD partner will go forward to the next state that messes up its state machine and causes an unexpected hard reset. We should not enable PD comm if not in a connected state. BRANCH=None BUG=b:151159750 TEST=Tested on Trogdor, with extra patches to fix the DP discovery and separate the Tx and Rx buffers. Unplugged battery and plugged a 20V charger and verified it boot fine, no reboot loop. TEST=Built chocodile_vpdmcu image successfully. TEST=make runtests -j Change-Id: Ic819787f1ec0085abdded3bab8ecbcb813495408 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2107882 Reviewed-by: Sam Hurst <shurst@google.com>
* 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>
* TCPMv1/v2: Move pd_process_source_cap() to common fileVijay Hiremath2020-02-121-0/+14
| | | | | | | | | | | 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 EC_CMD_USB_PD_CONTROL host command to common fileVijay Hiremath2020-01-301-0/+66
| | | | | | | | | | | 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>
* usb_mux: cleanup: Replace mux state enums with ec_command bit flagVijay Hiremath2020-01-281-0/+7
| | | | | | | | | | | BUG=b:145796172 BRANCH=none TEST=make buildall -j Change-Id: Ie4ffaf208745764262931501f0dff77b525a4e59 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2017569 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv1/v2: Move EC_CMD_USB_PD_DEV_INFO host command to common fileVijay Hiremath2020-01-241-0/+5
| | | | | | | | | | | 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>
* TCPMv1 & TCPMv2: Move common functions to common codeVijay Hiremath2020-01-141-0/+5
| | | | | | | | | | | BUG=b:147249926, b:146623068 BRANCH=none TEST=make buildall -j Change-Id: Ibb24bdad4e9ec24b02106c05ca5fe51269efcb1c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1990425 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* pd: use pd_get_[power/data]_role instead of the tc versionDenis Brockus2020-01-101-7/+2
| | | | | | | | | | | | | | the tc versions were doing the same thing as the pd version so removed the duplication BUG=b:147290482,b:147314832 BRANCH=none TEST=make buildall -j Signed-off-by: Denis Brockus <dbrockus@chromium.org> Change-Id: Iaa48dcd65e3a6c325b0ae2cca33e629fec6e33c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1993861 Reviewed-by: Edward Hill <ecgh@chromium.org>
* pd: cleanup pd_get_roleDenis Brockus2020-01-091-1/+1
| | | | | | | | | | | | | | | | | | pd_get_role in the TCPMv1 stack meant pd_get_power_role. pd_get_role in the TCPMv2 stack meant pd_get_data_role. This CL will clean that up and make them the correct naming. pd_get_power_role will also return an enum pd_power_role type instead of an int. BUG=b:147290482 BRANCH=none TEST=make buildall -j Change-Id: I73ee465401ccd050c2bd151f2fc043a59d95e079 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1991844 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usb_pd: Rename "Externally powered" to "Unconstrained Power"Benson Leung2019-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was changed in PD 2.0 years ago (via ECN authored by our own David Schneider), but our codebase still refers to BIT 27 of the Fixed PDO as "Externally powered" instead of "Unconstrained Power". This will search and replace all instances of "Externally powered" when it refers to BIT 27, as well as function names, other internal representations of that property, strings, and comments. seds: s/PD_FLAGS_PARTNER_EXTPOWER/PD_FLAGS_PARTNER_UNCONSTR/g s/partner_extpower/partner_unconstrained/g s/externally powered/unconstrained/g Some others too. Signed-off-by: Benson Leung <bleung@chromium.org> BUG=chromium:1030990 TEST=Codebase builds clean. No functional change, except for the property shows up in ectool as "Unconstrained power" now. Change-Id: I5ececa03f29eb31057be3d0ad5311117093bc6da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1956147 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Benson Leung <bleung@google.com> Tested-by: Benson Leung <bleung@google.com>
* usb_pd_policy: Make a lot of objects commonAseda Aboagye2019-12-101-9/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a board specific usb_pd_policy.c file that contains a lot of code for handling DisplayPort Alternate mode, Google Firmware Update Alternate mode, as well as some PD policy functions such as deciding to Accept or Reject a data role swap or a power role swap. Several boards simply copy/paste this code from project to project as a lot of this functionality is not actually board specific. This commit tries to refactor this by pulling the functions that are not mainly board specific into common code. The functions are made overridable such that boards that truly do require a different implementation may do so. Additionally, this consolidation changes the policy behaviour for some boards, but they should be for the better. Some examples include that data swaps are always allowed if we are a UFP (no system image requirement), power swaps are allowed to become a sink if we are no longer dual role (e.g. - in suspend), and DisplayPort Alternate Mode is not entered if the AP is off. In order to facilitate this refactor, a couple CONFIG_* options were introduced: - CONFIG_USB_PD_DP_HPD_GPIO /* HPD is sent to the GPU from the EC via a GPIO */ - CONFIG_USB_PD_CUSTOM_VDO /* * Define this if a board needs custom SNK and/or SRC PDOs. * * The default SRC PDO is a fixed 5V/1.5A with PDO_FIXED_FLAGS indicating * Dual-Role power, USB Communication Capable, and Dual-Role data. * * The default SNK PDOs are: * - Fixed 5V/500mA with the same PDO_FIXED_FLAGS * - Variable (non-battery) min 4.75V, max PD_MAX_VOLTAGE_MV, * operational current PD_MAX_CURRENT_MA, * - Battery min 4.75V, max PD_MAX_VOLTAGE_MV, operational power * PD_OPERATING_POWER_MW */ BUG=chromium:1021724,b:141458448 BRANCH=<as many as we can that are still supported> TEST=`make -j buildall` TEST=Flash a kohaku, verify that DP Alt Mode still works with a variety of DP peripherals TEST=Repeat above with a nocturne TEST=Repeat above with an atlas Change-Id: I18fd7e22dc77fe1dc6c21c38cd7f1bc53cae86cb Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1949052 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Fixed PR swap request from charge managerSam Hurst2019-12-101-3/+0
| | | | | | | | | | | | | | | | | | | The PR swap request from the charge manager was locking up the TC state machine. The pd_request_power_swap function was changed so that it sends the request to the policy engine instead of initiating it directly. BUG=chromium:1027247 BRANCH=none TEST=make -j buildall Tested with apple dongle "A2119 2019 HBR3" known to reproduce this problem. Change-Id: Ic59036056434ed525a839cd781cff93e3b5bfc53 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1928795 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* cleanup: clean up reference to power role vs cable plugJett Rink2019-10-241-0/+5
| | | | | | | | | | | | | | The PD header specifies the power role for SOP packets and cable plug for SOP' and SOP" packets. Refactor code to make this more obvious. BRANCH=none BUG=none TEST=builds and new stack runs on hatch Change-Id: I6cdb1561082d2142214ac65703ff42586b16d70b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1865986 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* cleanup: use power and data role enums instead of intJett Rink2019-10-241-6/+7
| | | | | | | | | | | | | | | Use first class enums types instead of int for power and data role. BRANCH=none BUG=none TEST=builds and new stack works with single charger on C1 hatch Change-Id: Ied4562e6a148803140cf277bd229b6c3ed801470 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1865985 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* pd: Add PE FRS unit test for new stackDenis Brockus2019-10-161-0/+116
BUG=none BRANCH=none TEST=make buildall -j Change-Id: I55453ddf1d1da0fdee902a33e14357716fb12c4a Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1859826 Reviewed-by: Jett Rink <jettrink@chromium.org>