summaryrefslogtreecommitdiff
path: root/include/usb_prl_sm.h
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: Remove prl_resetAbe Levkoy2021-02-081-7/+0
| | | | | | | | | | | | | It is now unused in implementation code. BUG=b:179198412,b:173725284 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: If9ce77f5958d4ee168412b22bd77cba2c4d0ec49 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2679992 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Reset stored PD revs at appropriate timesAbe Levkoy2021-02-081-1/+12
| | | | | | | | | | | | | | | | | | | | Stored PD revs for partners should only be reset upon Detach, Hard Reset, or Error Recovery. Don't do it when the PE enters a Startup state, e.g. after a Power Role Swap. BUG=b:173725284,b:179198412 TEST=make buildall TEST=PR Swap after SOP' Discover Identity with PD 2.0 cable; subsequent SOP' messages still PD 2.0; subsequent Enter_USB message has correct cable speed BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I2c12287c99154fba96e4f04a76ebc48273b0bb2e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2676265 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Divya Sasidharan <divya.s.sasidharan@intel.corp-partner.google.com> Tested-by: Ayushee Shah <ayushee.shah@intel.com>
* test: Improve test_send_caps_error in usb_pe_drpEdward Hill2020-12-011-24/+0
| | | | | | | | | | | | | 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: Don't interrupt RX/TX Extended Chunked Msg sequenceSam Hurst2020-08-221-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delay sending a new message during the reception or transmitting of Chunked messages. BRANCH=none BUG=b:161836223 TEST=make -j buildall manual: Transmitted an extended message and verified that the sequence was not interrupted by attempting to send a VDM message. Without patch Chunked message request that was interrupted. 20-08-14 10:46:13.473 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:46:13.494 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:46:13.516 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:46:13.535 C1: RECV 909f/1 [0]0000a400 Try to send VDM. MSG_TYPE is corrupted, was 0x1f, now 0x0f 20-08-14 10:46:13.563 C1: RECV 928f/1 [0]0000ac00 20-08-14 10:46:13.591 C1: RECV 948f/1 [0]0000b400 20-08-14 10:46:13.618 C1: RECV 968f/1 [0]0000bc00 20-08-14 10:46:13.645 C1: RECV 988f/1 [0]0000c400 20-08-14 10:46:13.674 C1: RECV 9a8f/1 [0]0000cc00 With patch. Chunked message request was not interrupted. 20-08-14 10:50:56.052 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:50:56.075 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:50:56.093 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:50:56.114 C1: RECV 909f/1 [0]0000a400 Try to send VDM. Message delayed 20-08-14 10:50:56.134 C1: RECV 929f/1 [0]0000ac00 20-08-14 10:50:56.155 C1: RECV 949f/1 [0]0000b400 20-08-14 10:50:56.175 C1: RECV 969f/1 [0]0000bc00 20-08-14 10:50:56.195 C1: RECV 989f/1 [0]0000c400 20-08-14 10:50:56.216 C1: RECV 9a9f/1 [0]0000cc00 20-08-14 10:50:56.242 C1: RECV 0c90/0 Try to send VDM. Signed-off-by: Sam Hurst <shurst@google.com>wq Change-Id: I5475792ee9f272fe4964e27839e55e3409a6a799 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357414
* usbc: correctly handle Get_Source_Cap as a sinkPeter Marheine2020-08-061-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tcpmc2: fix TD.PD.LL3.E2 Retransmission testJett Rink2020-08-061-5/+0
| | | | | | | | | | | | | | | | | | | | | | | We are retrying in both the TCPC hardware (4 total) and in the Protocol layer (3 total) when we do not get a GoodCRC back from the port partner. We are only suppose to retry up to nRetryCount times which is 2. This means we should be sending 3 total replies. Also correct a misinterpretation of the spec around SOP' and SOP" retries. We were not retrying those packets, but we should be retry them as the SOP. The SOP' device will not retry, but we (as the SOP) should retry packet that we are sending to them. The TCPM is not fast enough to meet the timing for tRetry (195 usec), so we need to perform the retries in the TCPC hardware layer. BRANCH=none BUG=b:150617035 TEST=Verify passing compliance test with GRL-C2 on Trembyle Change-Id: I55c4ab2f5ce8f64acf21af943862d96d9088622d Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2248960
* TCPMv2: Optionally build extended message supportAbe Levkoy2020-07-291-0/+5
| | | | | | | | | | | | | | | | | | 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>
* TCPMv2: Do not reset negotiated PD revision level during soft resetPatryk Duda2020-06-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | PD3.0 6.2.1.1.5 Specification Revision clearly states that negotiated Specification Revision level should be used until Detach, Hard Reset or Error Recovery happens. Current implementation of soft reset performs full reinitialization of PRL state machines, flags, counters including negotiated Specification Revision level. As a result when sending PD_CTRL_SOFT_RESET DUT was waiting for SinkTxOk, but it was never observed because ServoV4 was running PD2.0 stack. This issue was fixed by separating parts of SM_INIT state which shouldn't be reset during soft reset. BUG=b:158996004 BRANCH=none TEST=Flash nocturne with firmware which contains fix. Make sure ServoV4 runs PD2.0 revision. Run firmware_PDResetSoft test, make sure that hard reset doesn't occur. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I852817a63772dbc8baab74ff6b0c425228b2f49b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2246020 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpmv2: retool start/end AMSJett Rink2020-06-101-14/+0
| | | | | | | | | | | | | | | | | | | | | | | - Drop start and end ams function in favor of a flag based approach - Don't clear RX queue on TX reset. We are supposed to drop any pending TX messages (not RX messages). This should also help us to process partner messages if we get a collision - Drop prl_tx_phy_layer_reset_run and call next state directly in entry - Dropping retry_counter reset to 0 since that happens in entry method - Dropping flags reset to 0 because it is most likely dropping more flags than we want. BRANCH=none BUG=b:158248741,b:157228506,b:157661566 TEST=DUT accepts soft resets Change-Id: Ice8721a6c81452584f8d4ec474cb4f4a487b713b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2233794 Tested-by: Diana Z <dzigterman@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: clear TX_COMPLETE before starting sendingJett Rink2020-06-101-3/+0
| | | | | | | | | | | | | | | | | | We have had issue with the TX_COMPLETE flag remaining from previous TX transactions. This can incorrectly make the subsequent TX transaction code think that its TX send has completed. It is safer to always clear the TX flag before starting a new TX transition. BRANCH=none BUG=b:158248741 TEST=Verify that TX_SUCCESS does not linger from previous transactions Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I5fd7d849bdf97582d5b03b8d833de24b550d8c07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2239034 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Add dump pd command needed by PD_FAFTSam Hurst2020-04-291-0/+8
| | | | | | | | | | | | | | | | | | Add dump pd command that sets the debug level of the Policy Engine Layer and Protocol layer. BUG=b:151481791 BRANCH=none TEST=make -j buildall manual: pd dump 0 - verified PRL layer didn't print packet info and PE layer didn't print state names pd dump 1 - verified PRL layer printed packet info and PE layer printed state names Change-Id: I49430573278a4c51f52698c1528ace2c639cc30f Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2162190 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* TCPMv2: PD: Separately track each SOP and SOP' and SOP''Sam Hurst2019-11-241-2/+5
| | | | | | | | | | | | | | | | | | Tracked PD header spec. version for each port partner type. BUG=chromium:1023025 BRANCH=none TEST=make -j buildall Manual Testing: Connected PD2.0 source charger and made sure we talked PD2.0 Connected PD3.0 source charger and made sure we talked PD3.0 Connected apple 2019 PD2.0 dock with charger and made sure we downgraded from PD3.0 to PD2.0 Change-Id: I3b49d9630acf6c19101ac71334445890c78c4077 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1907430 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Revert "usbc: update CRCReceiveTimer"Sam Hurst2019-11-021-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 1092c786f7876745ec0d68dd52284d252e1abee5. Reason for revert: <Several Fluffy tests failed due to this CL> Original change's description: > usbc: update CRCReceiveTimer > > Shorten the CRCReceiveTimer and document that either the pe send or > error function will get called in response to a prl_ send message. > > BRANCH=none > BUG=none > TEST=build; > > Change-Id: Icc43886cadfdcd67c943b25aebfdfb55b2693ade > Signed-off-by: Jett Rink <jettrink@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825514 > Tested-by: Denis Brockus <dbrockus@chromium.org> > Commit-Queue: Denis Brockus <dbrockus@chromium.org> > Reviewed-by: Denis Brockus <dbrockus@chromium.org> > Reviewed-by: Edward Hill <ecgh@chromium.org> Bug: none Change-Id: I2051b6c2f3f36d5d0612f24ba08f9843f9487f66 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1894765 Reviewed-by: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com> Commit-Queue: Sean Abraham <seanabraham@chromium.org>
* pd: Add PE FRS unit test for new stackDenis Brockus2019-10-161-0/+7
| | | | | | | | | | | 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>
* usbc: update CRCReceiveTimerJett Rink2019-10-101-3/+6
| | | | | | | | | | | | | | | | | Shorten the CRCReceiveTimer and document that either the pe send or error function will get called in response to a prl_ send message. BRANCH=none BUG=none TEST=build; Change-Id: Icc43886cadfdcd67c943b25aebfdfb55b2693ade Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825514 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* pd: USB Power Delivery State Machine based on Revision 3.0 of the spec.Sam Hurst2019-09-101-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds Power Delivery to the TypeC state machine as detailed in Revision 3.0, Version 1.2 of the specification. This CL passes the PD2.0 compliance tests and has been tested on several devices. Some areas such as handling Electronically Marked Cable information, creation of PIDs, and Host commands will be addressed in later CLs. BUG=b:130895206 BRANCH=none TEST=manual Port 0 on Hatch was used to run this CL, merged with PD functionality, on the PD2.0 Compliance tester. All tests pass except for a few physical layer tests. The test report has been added to the bug. Atlas was verified to work with Apple, Amazon, StarTech, MKDGO and several other generic docks. Atlas was verified to work with Google's and Apple's CTVPD. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: Ia5e1988b0d81ec4cf9a7175e273197bd5a0865e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1737899 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usb: update state machine frameworkJett Rink2019-08-201-107/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - OBJ is renamed to context (CTX) for current and last state - State definition now includes its parent (no need for the boiler plate function that takes in a signal) - The init_state, set_state, and exe_state have been re-written to take advantages of new state machine definition. I had to add more logic to handle hierarchical states fully. - Explicitly create the USB states at the bottom of the file with all of the statics. Don't need to use macros (even though I did suggest them) - Use NULL when we do_nothing instead of calling into a function - Created a "private" enum in the C file that lists all of the states in the file, that we can use to refer to a state (it is also the index into the states array for that state). - Changed prototype of state function to return void, since we aren't really using the return value and it cleans up a lot of return 0 that aren't needed. - Add const to int port since we can and should - Moves struct definition to implementation file only to keep implementation details private. We can access data through accessor if needed. BRANCH=none BUG=none TEST=all unit tests passes Change-Id: I482a63e08f7d63022d5102b891a2fac0b0faa46f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1733744 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* type-c: USB Type-C State Machine based on Release 1.4 of the spec.Sam Hurst2019-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Implements DRP with Accessory, and Try.SRC as detailed in Release 1.4 of the USB Type-C specification. BUG=b:130895206 BRANCH=none TEST=manual Used Atlas device to verify that it could be charged from PD and none PD charges at 5V/3A. Attached USB dock and verifed access to USB Thumb drive. Performed same tests on Hatch Port 0 on Hatch was used to run this CL, merged with PD functionality, on the PD2.0 Compliance tester. All tests pass except for a few physical layer tests. The test report has been added to the bug. Change-Id: Ic4869e20e5b4c2ba6c827d92e40c70f3140f2518 Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1574667 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Sam Hurst <shurst@google.com> Commit-Queue: Sam Hurst <shurst@google.com>
* chocodile_vpdmcu: Firmware for chocodile mcuSam Hurst2019-04-081-0/+213
Implement Chocodile Charge-Through Vconn Powered firmware for mcu using new Type-C/PD State machine stack. BUG=b:115626873 BRANCH=none TEST=manual Charge-Through was tested on an Atlas running a DRP USB-C/PD state machine with CTUnattached.SNK and CTAttached.SNK states. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: I847f1bcd2fc3ce41e66edd133a10c943d5e8c819 Reviewed-on: https://chromium-review.googlesource.com/1225250 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Stefan Reinauer <reinauer@google.com>