summaryrefslogtreecommitdiff
path: root/test/usb_pe_drp.c
Commit message (Collapse)AuthorAgeFilesLines
* TCPM: Rename enum tcpm_sop_type and its constantsAbe Levkoy2021-08-311-31/+31
| | | | | | | | | | | | | | | 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: Remove enum pd_msg_typeAbe Levkoy2021-08-181-9/+9
| | | | | | | | | | | | | Convert usages of this enum to tcpm_sop_type. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I5fed273d72e7ad0e191db0cb0d121b70bdd9ecdb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3104291 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Allow tests to clear PE data between runsDiana Z2021-07-271-0/+1
| | | | | | | | | | | | | | The PE stores internal state (ex. capabilities, identity responses) which should be cleared out between unit test runs. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I77b3faefd3f887a68ca9593a7398ae9c3ffb2f17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3025864 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Gate requesting sink capabilities on related featuresDiana Z2021-07-121-13/+0
| | | | | | | | | | | | | | | | | There are a number of features that may cause a board to need sink capabilities (3.0 A port balancing, FRS, or AP host commands). However, other boards may not need these and the added traffic can increase the liklihood of collisions on PD 2.0 connections. BRANCH=None BUG=b:192051705 TEST=connect honeybuns to TCPMv1 DUT and verify DP alternate mode can be reliably entered Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I70e2f360a9a45eee85ed555cb0165937c01a661a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3016407 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* PE Test: Add unit test for PR swap interruption during power transitionDiana Z2021-05-171-0/+62
| | | | | | | | | | | | | | | | | When a non-interruptible AMS is interrupted during power transition, send a hard reset. Attempting a soft reset here will result in a bad connection state since Vbus is currently discharging and the soft reset process can't complete without Vbus presence. Add a unit test to enforce this. BRANCH=None BUG=b:184764468 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ifa20a7cea2c2c3a52e4ba4e88712c262c7c18967 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2897128 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Don't check VBUS when entering BIST modeAbe Levkoy2021-02-231-80/+0
| | | | | | | | | | | | | | | | | Temporarily remove check for VBUS = vSafe5V when entering BIST mode. It does this by measuring VBUS, but this facility is inadequate to the purpose on Volteer. Since this even more of an edge case than actually running BIST tests, remove the check for now, pending a more general solution. BUG=b:180957710,b:173023378 TEST=make buildall; pass TDA.2.1.2.2 BMC PHY RX INT REJ on voxel BRANCH=firmware-volteer-13672.B-main Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I172c1bcc10731c2e405344cdc6ad2b5a1ed80ced Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2714203 Reviewed-by: Diana Z <dzigterman@chromium.org>
* tcpmv2: Only issue SOP' soft reset following PR swapKeith Short2021-02-161-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | Entry to the PE_SNK_Startup and PE_SRC_Startup states resets the protocol layer, and clears the message IDs for all SOP types. These states are entered during initial connect, hard reset, and after a power role swap. The cable should automatically clear it's message IDs on the initial connect (because it didn't have power) and on a hard reset, so modify the PE policy to only send SOP' soft reset after power role swaps. BUG=b:179325862 BRANCH=volteer TEST=Connect TBT loopback device, verify no SOP' soft reset is sent and that TBT entry is successful. TEST=Connect USB+DP monitor when EC starts as SRC/DFP and VCONN source. Verify EC sends SOP' soft reset is sent after power role swap. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I2c133eec0e76c1ecb7b79cea94a541fdb55ee9c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2691423 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Wait for tSrcTransition after AcceptAbe Levkoy2021-01-261-3/+3
| | | | | | | | | | | | | | | | | During power contract negotiation, after sending Accept, wait for tSrcTransition before transitioning the supply and sending PS_RDY. See PD r3.0, v2.0, Table 7-22. BUG=b:173023378 TEST=Pass TDA.2.1.2.2 using MQP compliance tester (or at least don't fail due to sending PS_RDY too early). BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I76e31ff5df6bfd71f78642bda25e1e8f9f590f9c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2644179 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: JC Huang <j.c.huang@quanta.corp-partner.google.com>
* TCPMv2: Test that PE ignores invalid BIST requestsAbe Levkoy2021-01-221-0/+81
| | | | | | | | | | | | | | | Send the PE BIST requests with inappropriate VBUS voltages or inappropriate BIST modes. Verify that the PE ignores them. BUG=b:173023378,b:169385081,b:172709198,b:173028832,b:173028791 BUG=b:173141941,b:173142113 TEST=run-usb_pe_drp passes BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I240ff6746debcf49934419940ab4f49b54e2b7e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2639585 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Process DPMs before discoveryDiana Z2021-01-141-37/+17
| | | | | | | | | | | | | | | | | | | | | | Some devices may reply to discovery differently if they're not yet being offered sufficient current. Process DPM requests before running discovery in order to get these devices into the best state for discovery probing. This also moves the cable soft reset DPM request up to the common DPM request function. Otherwise, it will be considered an unhandled request and dropped before attempting discovery. BRANCH=volteer BUG=b:177303467,b:177001425 TEST=verify we can reliably receive DiscoverSVIDs ACK from LaCie SSD Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I0917476c2aeb0cb9551edde3df14ddd1fd47fcab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2627805 Tested-by: Utkarsh H Patel <utkarsh.h.patel@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpmv2: always issue SOP' soft resetKeith Short2021-01-091-0/+20
| | | | | | | | | | | | | | | | | | | After entering a PD contract, always issue an SOP' soft reset before sending any discovery VDMs to the cable. BUG=b:172364575 BRANCH=volteer TEST=connect monitor with emarked cable, verify SOP' soft reset is sent when EC starts as SNK/DFP. TEST=Connect monitor with non-emark cable. Verify SOP' soft reset is sent once regardless of starting role. TEST=Connect USB4 dock, verify USB4 entry. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Id5026a2c8c9877b860e1356dd33763bad3e51841 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2596838 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* mock: Clean up TCPMv2 mocksAbe Levkoy2020-12-151-4/+2
| | | | | | | | | | | | | | | | | | | | | | Place mock functions in the mock libraries corresponding to the layers of the real implementations. Broadly, move towards one layer of the TCPM stack as a UUT, with mocks for the other layers as needed. There should be a one-to-one correspondence between real modules and mock modules. usb_pd_mock.c does not correspond to any real implementation module or TCPM stack layer, so remove it and move its contents to the layers corresponding to their real implementations. Also clean up some redundant or misplaced mocks inside tests. BUG=b:153071799,b:173791979 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ic44df8675de2b9f1f8c7669cd97dcdc296bf107f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2578200 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* task_set_event: remove the wait argumentDawid Niedzwiecki2020-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | There is an option in the task_set_event function which force the calling task to wait for an event. However, the option is never used thus remove it. This also will help in the Zephyr migration process. BUG=b:172360521 BRANCH=none TEST=make buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ic152fd3d6862d487bcc0024c48d136556c0b81bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521599 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* usbc: Wake PD task on PE TX and RXEdward Hill2020-12-011-14/+14
| | | | | | | | | | | | | | Wake the PD task from pe_message_received(), pe_message_sent(), and pe_report_error() to avoid having to wait USBC_EVENT_TIMEOUT. BUG=none BRANCH=none TEST=make run-usb_pe_drp Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I2fd1465796224507e1eb64ea20572165918d5bf3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2564818 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* test: Add test_send_caps_error_before_connected to usb_pe_drpEdward Hill2020-12-011-38/+120
| | | | | | | | | | | | | | | | Add a test for the other half of handling an error on sending source capabilities. Before connection, PE_SRC_Send_Capabilities goes to PE_SRC_Discovery on send error. Once connected, to goes to PE_Send_Soft_Reset. BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I92df9159286536bdda76e5b8530494c6aa368af1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2553344 Reviewed-by: Diana Z <dzigterman@chromium.org>
* test: Improve test_send_caps_error in usb_pe_drpEdward Hill2020-12-011-64/+105
| | | | | | | | | | | | | Better mock tx and rx messages, add sop type. BUG=b:161835483 b:173791979 BRANCH=none TEST=make run-usb_pe_drp Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: If1f91b6385d6841d662a8a6262af6382645da92e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2553343 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Always probe sink capsDiana Z2020-11-201-0/+17
| | | | | | | | | | | | | | | | | | | | | This commit adds the ability to always probe the partner for sink capabilities, and re-names the state to reflect that sources may use it now too. This also fixes some issues in the state to get sink capabilities, including correcting the message detection and soft resetting with the SOP* of the unexpected message. This also updates the unit tests to expect a Get_Sink_Caps message as a part of typical startup. BRANCH=None BUG=b:168862110,b:160009733 TEST=on drawcia, observe sink caps are requested from source and sink partners Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5da3adc17ccec71f6cad9e8f152b9570ec99691d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2540389 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Avoid VCONN-Source discovery failureAbe Levkoy2020-10-211-0/+1
| | | | | | | | | | | | | | | | | Remove redundant checks for VCONN Source in pe_attempt_port_discovery (which prevent discovery from running). Allow pe_vdm_send_request to attempt to become VCONN Source if necessary. Make the checks in the VDM request child states more complete (not just checking for VCONN Source). BUG=b:170662791 TEST=Attach Tapex Creek board; observed successful discovery BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Id7d3a1b82d1029f69b3e05b845632e7237524bc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486303 Tested-by: Li1 Feng <li1.feng@intel.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* test: Add test_send_caps_error to usb_pe_drpEdward Hill2020-09-221-0/+90
| | | | | | | | | | | | | | | | | As requested in CL:2321869 review, make a new version of test_send_caps_error that uses the external interface of the PE layer. BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I983b145cd1e731e844363955896898a2374a0a30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2419834 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* usb_pe_drp: new unit test with mocksPaul Fagerburg2020-08-311-0/+56
| | | | | | | | | | | | | | | | | | | Add a new unit test for usb_pe_drp with mocks for the various subsystems that it will use. The fake_prl module is already essentially a mock for the PRL layer, so just move it into the mocks directory and make it available as mock to other tests. BUG=b:163421994 BRANCH=None TEST=`make runhosttests` succeeds Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2aea3fa0694e8d9e6bae1f47516cb4d5d2a1e714 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364050 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* test: rename usb_pe_drp to usb_pe_drp_oldPaul Fagerburg2020-08-171-359/+0
| | | | | | | | | | | | | | | | | Rename the current usb_pe_drp test to usb_pe_drp_old. There will be a new usb_pe_drp test that uses mocks and we will move the tests over in a controlled fashion. BUG=b:163421994 BRANCH=None TEST=`TEST_LIST_HOST=usb_pe_drp_old make runhosttests` works. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2e0f79eb793d888109d00a96567042356c770502 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357519 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* test: remove no_empty_state testsJett Rink2020-08-131-1/+0
| | | | | | | | | | | | | | | | When we use IS_ENABLED style code we may have empty state machine states that are unused. The linker ensures that we never try to reference these states. This does mean that extra states do cost ~20 bytes each. This cost does seem worth it to keep the value of usb states stable. BRANCH=none BUG=none TEST=buildall Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I44c1454bed91c9e28d89ebd6b75e9df684c41844 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354192 Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: correctly handle Get_Source_Cap as a sinkPeter Marheine2020-08-061-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | USB Power Delivery Specification Revision 3.0, version 2.0 section 6.3.7 states that a dual-role port shall respond to Get_Source_Cap with its source capabilities, but this was incorrectly handled by responding with a request for source capabilities. Per section 8.3.3.18.10, implement the PE_DR_SNK_Give_Source_Cap state to handle this correctly. To support the new test, some helper functions for the fake PE are added and the test code's copy of the PE state enum is updated to be in sync with the real one. BUG=b:161400825,b:161331630 TEST=New host test for this state, and verified on Dalboz that requesting a PRS via the EC console (`pd 1 swap power`) now sends source capabilities when the partner requests them. BRANCH=None Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I87c27d406e0a3f57cf2c25fa583bee51155b6b12 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2336233 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Soft reset on failure to send source capsEdward Hill2020-08-011-0/+36
| | | | | | | | | | | | | | | | | | | | pe_report_error() defers to PE_SRC_SEND_CAPABILITIES for custom error handling (via PE_FLAGS_PROTOCOL_ERROR). pe_src_send_capabilities_run() was correctly going to PE_SRC_DISCOVERY when we are not connected (PD 3.0 8.3.3.2.3), but it was failing to send soft reset when we are already connected (PD 3.0 8.3.3.4.1.1). BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp PD 3.0 compliance test TD.PD.SRC3.E26 (Soft_Reset sent regardless of Rp value) Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Id71e38a69006e95b7ff4f7145e86bd5ac64c7577 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321869 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Use named constants for extended messagesAbe Levkoy2020-07-291-1/+1
| | | | | | | | | | | | | | These correspond to MaxExtendedMsgLen and MaxExtendedMsgChunkLen (PD 3.0, rev 2.0, ss 6.13). BUG=b:160374787 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I3640df18724c3c04e9f644ca59a6542563d723f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316135 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Optionally build extended message supportAbe Levkoy2020-07-291-1/+126
| | | | | | | | | | | | | | | | | | If CONFIG_USB_PD_EXTENDED_MESSAGES is defined, support sending and receiving extended messages. If it is not, remove the chunking state machines from the PRL and modify the PE to respond with Not Supported as appropriate. BUG=b:160374787,b:158572770 TEST=Attach various devices; observe PD traffic TEST=make run-usb_prl_noextended; make run-usb_pe_drp_noextended BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I862020155927b5613d599274708e60678c49c43c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304263 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec: change usage of "sane" per inclusive languagePaul Fagerburg2020-07-221-1/+1
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "sane", "sanity check", and similar with inclusive/non-stigmatizing alternatives. BUG=b:161832469 BRANCH=None TEST=`make buildall -j` succeeds. `grep -Eir "sane|sanity" .` shows results only in third-party code or documentation. Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: I29e78ab27f84f17b1ded75cfa10868fa4e5ae88c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311169 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test: Use pd_task for pe testJett Rink2020-07-211-21/+17
| | | | | | | | | | | | | | | | Instead of calling pe function direction in unit test, use the existing state machine task for unit tests. This allows the real code to call into a task_set_event on the PD tasks. See CL:1786462 where this is needed. BRANCH=none BUG=none TEST=run test passes with and without CL:1786462 Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: If31f946e2253c724dd314b2b22e2265cf46197f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2307713 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Rename discovery flagsAbe Levkoy2020-06-191-1/+1
| | | | | | | | | | | | | | | | | | PE_FLAGS_DISCOVER_PORT_IDENTITY_DONE has been used to indicate that DisplayPort configuration is done for some time. PE_FLAGS_DISCOVER_PORT_CONTINUE is now only used to resume non-discovery VDM requests. Maybe the way they are used should change. For now, rename them to reflect their current use; this should make subsequent changes easier to understand. BUG=b:155890173,b:158813138 TEST=make buildall BRANCH=none Change-Id: Icbb6a44412b1b901ed160da58d4fbe016348bc2b Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250921 Reviewed-by: Diana Z <dzigterman@chromium.org>
* test: Pass commandline arguments to run_testTom Hughes2020-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | run_test is called by the "runtest" console command. Console commands can take arguments, so pass along the arguments to run_test to allow parameters to be passed to run_test. The following command was used for automatic replacement: git grep --name-only 'void run_test(void)' |\ xargs sed -i 's#void run_test(void)#void run_test(int argc, char **argv)##' BRANCH=none BUG=b:155897971 TEST=make buildall -j TEST=Build and flash flash_write_protect test > runtest 1 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ib20b955d5ec6b98f525c94c24aadefd7a6a320a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2209418 Reviewed-by: Yicheng Li <yichengli@chromium.org> Commit-Queue: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org>
* TCPMv2: Revamp pe_attempt_port_discoveryDiana Z2020-04-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revamps pe_attempt_port_discovery to be called from the ready run states, try once to be DFP and Vconn source, and moves timer check and discovery calls into this function. Note that nDiscoverIdentityCount and DiscoverIdentityTimer are only applicable to cable plugs, though here the discover identity timer is also repurposed to space out requests to a BUSY partner. Long term, the policy decisions regarding our data and vconn role will be moved out into their own file in order to support allowing the AP to override EC default policies. BRANCH=None BUG=b:152417977 TEST=on kindred running TCPMv2, ensured we could complete discovery and enter mode DP mode (when applicable) with: - PD 2.0 Apple dongle, with and without external power - PD 2.0 Acer hub - PD 2.0 charger which would DR swap - PD 3.0 Cable Matters hub, with and without external power - PD 3.0 Hoo Too hub, with and without external power Ensured we did not attempt discovery with: - PD 2.0 charger which won't DR swap Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I9c049690a87f3fc0eca3b9d2c85128470cbb2a91 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2130478 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Configure PE test for alternate modesDiana Z2020-04-161-0/+7
| | | | | | | | | | | | 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: move function from TC layer to PEJett Rink2020-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | - 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
* config: update TCPMv2 config optionsJett Rink2020-03-271-0/+5
| | | | | | | | | | | | | | | | | | | Reorganize how the TCPMv2 options are used - Update documentation in config.h and bring TCPMv2 items close together - Make the layer defines consistent on how they include compilation units - Update tests to account for how files are included now - Remove unnecessary defines in board.h since they are default on BRANCH=none BUG=none TEST=builds Change-Id: I91fca51648912deef44db23492ecc7775b2e3062 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2120063 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Split PD message buffers into separate TX/RX buffersSam Hurst2020-03-211-2/+2
| | | | | | | | | | | | | | | | | | | | | Use separate buffers for transmit and reception of PD messages. This prevents the potential corruption of PD messages waiting to be transmitted when an unexpected PD message is received BUG=b:150637227 BUG=b:149662829 BRANCH=none TEST=make -j buildall Manual tests: Tested hatch device and powered dock. Used total phase to verify that transmitted messages were not corrupted by unexpected message reception. Change-Id: I12df471f59fb7510e642bb92b769ccbddd79c84f Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2103253 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv1/v2: Move pd_set_vbus_discharge() to common fileVijay Hiremath2020-02-121-0/+5
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: Id7b0d10396300c4bd5b8253b7ce77c1fe59c9bc8 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051216 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move EC_CMD_PD_CHIP_INFO host command to common fileVijay Hiremath2020-01-241-0/+2
| | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: Ia858db061811c58a14b2525d17d6abdc35ea6fa7 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2008299 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Fixed PR swap request from charge managerSam Hurst2019-12-101-0/+4
| | | | | | | | | | | | | | | | | | | 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>
* usbc: fix vbus discharge path for GPIOJett Rink2019-11-071-0/+17
| | | | | | | | | | | | | Code on Tot assumes that port count was the port to discharge instead of port parameter BRANCH=none BUG=none TEST=verified with unit test (in this CL) Change-Id: I17658a0c555f9cea56fa4ec1652e0faf62e3d6cc Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1896125
* pd: Add PE FRS unit test for new stackDenis Brockus2019-10-161-0/+134
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>