summaryrefslogtreecommitdiff
path: root/common/usbc/usb_pe_drp_sm.c
Commit message (Collapse)AuthorAgeFilesLines
* ish: Trim down the release branchstabilize-wristpin-14469.59.B-ishstabilize-voshyr-14637.B-ishstabilize-quickfix-14695.187.B-ishstabilize-quickfix-14695.124.B-ishstabilize-quickfix-14526.91.B-ishstabilize-14695.85.B-ishstabilize-14695.107.B-ishstabilize-14682.B-ishstabilize-14633.B-ishstabilize-14616.B-ishstabilize-14589.B-ishstabilize-14588.98.B-ishstabilize-14588.14.B-ishstabilize-14588.123.B-ishstabilize-14536.B-ishstabilize-14532.B-ishstabilize-14528.B-ishstabilize-14526.89.B-ishstabilize-14526.84.B-ishstabilize-14526.73.B-ishstabilize-14526.67.B-ishstabilize-14526.57.B-ishstabilize-14498.B-ishstabilize-14496.B-ishstabilize-14477.B-ishstabilize-14469.9.B-ishstabilize-14469.8.B-ishstabilize-14469.58.B-ishstabilize-14469.41.B-ishstabilize-14442.B-ishstabilize-14438.B-ishstabilize-14411.B-ishstabilize-14396.B-ishstabilize-14395.B-ishstabilize-14388.62.B-ishstabilize-14388.61.B-ishstabilize-14388.52.B-ishstabilize-14385.B-ishstabilize-14345.B-ishstabilize-14336.B-ishstabilize-14333.B-ishrelease-R99-14469.B-ishrelease-R98-14388.B-ishrelease-R102-14695.B-ishrelease-R101-14588.B-ishrelease-R100-14526.B-ishfirmware-cherry-14454.B-ishfirmware-brya-14505.B-ishfirmware-brya-14505.71.B-ishfactory-kukui-14374.B-ishfactory-guybrush-14600.B-ishfactory-cherry-14455.B-ishfactory-brya-14517.B-ishJack Rosenthal2021-11-051-7486/+0
| | | | | | | | | | | | | | | | | | | | | | In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* usbpd: implement new api to access PD discovery dataDeepti Deshatty2021-09-201-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | API pd_get_am_discovery() sets the lock (task access bit) to keep track of EC tasks accessing the pd port discovery data. If any of the task access bits are set,EC host task typec discovery handler will return EC_RES_BUSY to host, indicating discovery data is modified while copying port discovery data to the host. Hence the lock/task access bit should be set only when the port discovery data is modified by any tasks. Setting of lock/task access is removed from pd_get_am_discovery() and implemented new api pd_get_am_discovery_and_notify_access() for this. pd_get_am_discovery() proto type is changed to return 'constant pointer' which forces developers to use pd_get_am_discovery_and_notify_access() when they intend to access and modify discovery data. summary of changes implemented. - Remove setting of task access bit from pd_get_am_discovery(). - modify pd_get_am_discovery() prototype to return constant pointer. - implement new api pd_get_am_discovery_and_notify_access() - Replace calls to pd_get_am_discovery() with new api wherever discovery data is accessed and modified. BRANCH=none BUG=b:197466819 b:190390784 TEST=Verified 50 cold boot cycling with TBT device attached. Device detected in every cycle. Signed-off-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com> Change-Id: I5b6f1f2b91d92ddbe58f3bf994f684abee948c02 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3139858 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Separate discovery and mode initAbe Levkoy2021-09-101-9/+20
| | | | | | | | | | | | | Don't clear discovery data when resetting active modes during mode exit. BUG=b:141363146 TEST=make buildall BRANCH=firmware-volteer-13672.B-main Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I8052641bb850ce8486eb9c82641b41880cb97d65 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3123837 Reviewed-by: Diana Z <dzigterman@chromium.org>
* usbpd: support dynamic PDO selectionEric Yilun Lin2021-09-011-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support dynamic PDO selection CONFIG_USB_PD_DPS. This config controls the charging voltage and power according to the input power and battery configuration. DPS would continuously evaluate the system load and current charging voltage, and decide a new one by below: 1. If the PDO can fulfill system desired power. 2. If the PDO is efficient for the battery configuration. To detect if the system load cannot be fulfilled by the current PDO, it checks: 1. if the input current closes to the PDO current limit. 2. if the input power closes to the PDO maximum power. To detect if the system load can be fulfilled by a more efficient PDO, it checks: - if the voltage of a new PDO is closer to the battery voltage than the current PDO, and the power is able fulfill the system load. BUG=b:169532537 TEST=1. tested on asurada, the charging voltage is able to switch to different PDOs under different system loads 2. tested that the DPS is able to switch charge port (e.g. C1 12V -> C0 9V) based on the provided PDOs. BRANCH=asurada Change-Id: I7c7706b331dc0d4f8ac68569dc7ed852fc9308e3 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2897064 Tested-by: Eric Yilun Lin <yllin@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com>
* TCPM: Rename enum tcpm_sop_type and its constantsAbe Levkoy2021-08-311-127/+129
| | | | | | | | | | | | | | | 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-19/+19
| | | | | | | | | | | | | | | 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: Register Get_Source_Cap failuresDiana Z2021-07-271-6/+21
| | | | | | | | | | | | | | | | | When an attempt to gather source capabilities fails, we should avoid probing for them again by internally tracking the number of capabilities as -1. This saves us traffic on resets with partners that have no source capabilities, and also prevents looping with buggy partners who reply with an unexpected message. BRANCH=None BUG=b:191229962 TEST=on guybrush, ensure we only query a sink-only dongle once Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iea56619d7aca5df7d1b38d8f0d6a69cac4a825a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3025865 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Allow tests to clear PE data between runsDiana Z2021-07-271-4/+18
| | | | | | | | | | | | | | 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-4/+12
| | | | | | | | | | | | | | | | | 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>
* TCPMv2: Notify of disconnect on TC detachDiana Z2021-07-011-0/+3
| | | | | | | | | | | | | | | Send a notification that the port has been disconnected when the TC triggers HOOK_USB_PD_DISCONNECT. BRANCH=None BUG=b:188330043 TEST=on storo, verify that disconnect quickly registers in the UI power status menu Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I758ca918ccd199e3ca2f69aec67323065b48add7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2983992 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* SenderResponseTimer: offset with TCPC transmit success timestampudaykiran2021-06-251-2/+14
| | | | | | | | | | | | | | | | | | | | | | The SenderResponseTimer shall be used by the sender's policy engine to ensure that a message requesting a response is responded to within a bounded time. Which is 24Msec to 30 Msec. However, delays associated TCPC I2C, PE, and PRL layers make hard reset response time greater 30Msec. This CL address the delay associated with TCPC. When TCPC transmit success is reported by TCPC upon receiving the GoodCRC, time stamp is recorded. Another time stamp is recorded just before starting SenderResponseTimer and offsetting PD_T_SENDER_RESPONSE. BUG=b:182439366 BRANCH=none TEST=checked with GRL compliance tester. Noted that total response time is in the middle of the expected time of 24ms to 30ms. This fix achieved response time about 27.675ms Signed-off-by: udaykiran <udaykiran@google.com> Change-Id: Id2ddcdd90eed8b3d66ade3d16877004871a21de8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2971078 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Take over as Vconn source when Not_Supported is sentDiana Z2021-06-181-6/+79
| | | | | | | | | | | | | | | | | In PD 3.0, the Not_Supported message allows a port partner to let us know it cannot source Vconn, and therefore we may take over as Vconn source. This implements the spec state PE_VCS_Force_Vconn for that scenario. BRANCH=None BUG=b:189630178 TEST=on guybrush, connect a charger which doesn't support sourcing Vconn and observe we probe the cable Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If7e48db45def602d0989473a84cb2271c03bfe30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2965845 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Ignore PR swap requests when PR transitioningDiana Z2021-06-151-0/+21
| | | | | | | | | | | | | | | | | | | | | | | The charge manager may request a PR swap when it is no longer charging from a port that is DRP and configured as sink. This can prevent us from depleting a tablet when there's a better charger available, for example. However, when the DRP partner has already initiated a PR swap this may lead to the chromebook inadvertently becoming the sink of the connection again. Ignore PR swap requests while we're in a state where our PR role doesn't match what it's expected to be shortly in order to prevent this. BRANCH=None BUG=b:174334068 TEST=on storo, connect guybrush and enable charging alternately from both DUTs. Then, when charging from the other DUT, connect a charger and ensure that storo swaps to sourcing the other system. Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I1908f4ee726d49ca89f6f0c8f75bdfdf0fb12a47 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2964920 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Cancel SNK PR swap if we can now chargeDiana Z2021-06-091-2/+6
| | | | | | | | | | | | | | | | | | Some port partners may offer a very low initial source capbility (ex. 5V at 100mA) and then very quickly follow with full source capabilities. When this happens, cancel any queued PR swap requests since we now wish to charge from this port partner. BRANCH=None BUG=b:190506779 TEST=on guybrush, ensure Apple 3-in-1 connects without any unnecessary PR swaps Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia51efc8e17d950a0abb818b7da0f99d598affbe3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2947622 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* TCPMv2: Rename pd_can_source_from_deviceDiana Z2021-06-051-6/+6
| | | | | | | | | | | | | | Clarify the function name by changing it to "can charge from" since "source from" isn't a generally common phrase in PD terms. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Id7a40ac9d8d4c0007e8ff6cb25c2e8c2d006df0c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2923239 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Don't delay ready transition turning off VconnDiana Z2021-06-041-16/+3
| | | | | | | | | | | | | | | | | | Since Vconn is make before break, it makes no sense to delay transitioning back to ready since Vconn isn't discharging. Waiting extra time in the state translates to taking more time to process the next messages after a Vconn swap. BRANCH=None BUG=b:181087216 TEST=on storo, confirm that we don't miss replying to PR swap following a Vconn swap connected to another DUT Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I0d551d0cac34f8157c7fe2b272c2450d6da3ca17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2937108 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Re-enable SOP' transmission on interruption to Vconn swapDiana Z2021-06-011-25/+39
| | | | | | | | | | | | | | | | | | | | | If a Vconn swap is interrupted before we receive a PS_RDY from the partner, re-enable SOP' transition. Note this doesn't matter for the case of no PS_RDY received as we'll proceed to hard reset which will also reset our Vconn role. This is primarily applicable if the interruption is for an unexpected message, which interrupts the swap and leaves us the Vconn source. BRANCH=volteer BUG=b:186886218 TEST=on drobit, ensure cable entry doesn't fail after failed Vconn swap with dock Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I952c04535ae9527f07cb203c403a51182c67cba7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2881020 Tested-by: Benson Leung <bleung@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: PE: Don't set AMS flag unless custom VDM has a replyScott Collyer2021-05-271-4/+6
| | | | | | | | | | | | | | | | | | | | This CL fixes an issue related to PE_FLAGS_INTERRUPTIBLE_AMS which was being set in pe_handle_custom_vdm_request_entry whether the custom VDM request is supported or not. This would result in PE_FLAGS_INTERRUPTIBLE_AMS remaining set and ignoring of subsequent VDM messages, which in turn prevents ALT-DP entry for UFP case. BUG=b:189293176 BRANCH=quiche TEST=Verfied that with this fix, ALT-DP mode is entered consistently. Without this CL, ALT-DP mode is not entered correctly. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I7a52a6028ea656d9a1970fea0b42f582f1aaff5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2677707 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Clear pending DPMs during port discovery requestDiana Z2021-05-251-1/+3
| | | | | | | | | | | | | | | | | If there is a pending VDM send during the processing of DPM_REQUEST_PORT_DISCOVERY, then the VDM send and ACK may leave the DP module in an inconsistent state. Avoid this state by clearing any pending VDM sends at this time. BRANCH=None BUG=b:182237701 TEST=on mancomb, plug in a dock in G3 and power up to S0 repeatedly, ensuring that we can enter DP mode every time Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I2223ed431df97821a177e9a030b53f6310a1faf8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2912114 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Hard reset on PR swap interruptionDiana Z2021-05-171-0/+11
| | | | | | | | | | | | | | | | When a PR swap is interrupted, send a hard reset. Since Vbus is turning off, a soft reset wouldn't restore our Vbus and connection state for this protocol error. BRANCH=zork BUG=b:184764468 TEST=on jelboz, connect problematic dock which interrupts PR swap and ensure connection can recover successfully Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I901c5a99af3f8cfae038d447bac8e0f37fedc9c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2880811 Reviewed-by: Edward Hill <ecgh@chromium.org>
* TCPMv2: Initiate VCONN Swap when requestedstabilize-13971.B-mainAbe Levkoy2021-05-141-1/+1
| | | | | | | | | | | | | | | | | | | Do not ignore a requested VCONN Swap if VDM setup is done. Use a DPM request flag (which is always handled in the ready state) instead of the VCONN Swap PE flag (which is only handled if mode entry hasn't completed). BUG=b:187861138 TEST=make buildall BRANCH=firmware-volteer-13672.B-main Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I32ebb7c50e9abc47351398f229a2b464605f634d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2895425 Tested-by: Li1 Feng <li1.feng@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* TCPMv2: Correct PD 3.0 reply when SVDM isn't supportedDiana Z2021-05-141-1/+11
| | | | | | | | | | | | | | | In PD 3.0, a DUT must reply with Not_Supported when a SVDM isn't supported. Note that PD 2.0 is still perfectly welcome to send a NAK reply for this case. BRANCH=None BUG=b:181194535 TEST=with follow-on CL, verify TD.PD.VNDI3.E3 VDM Identity passes Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie3b554cca017494b86342df1e9149b4452c83852 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2881028 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Set CC on contract invalidation only if connectedDiana Z2021-04-301-2/+2
| | | | | | | | | | | | | | | | | | | When a contract is invalidated, it's important we advertise our current limit Rp rather than a residual collision avoidance Rp. However, we should not attempt to set CC's when we're in a disconnected state. This may cause us to set an unexpected CC selection, such as Ra if the TC layer hasn't set the first termination yet. BRANCH=None BUG=b:183182447 TEST=on guybrush, boot with i2c tracing enabled and ensure Ra is never set during init. Perform PR swaps and hard resets as source to ensure correct Rp is set. Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I8fbe06685e4b4a6493dfbf55270ce3bda8cfbdfd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2845013 Reviewed-by: Edward Hill <ecgh@chromium.org>
* usb_pe_drp: Consider CHARGE_PORT_NONE for HardRstAseda Aboagye2021-04-261-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When we arrive in the EC image without a battery and with a PD supplier, we would eventually consider sending a HardReset since we are expecting SourceCaps to be sent by the port partner. However, since we no longer maintain our contract across images and we would like for the board to not brown out, we avoid sending the HardReset and simply disable the port instead. However, this situation can occur before we decide on a charge port. Therefore, this commit simply adds another condition when deciding to skip sending the HardReset. If a battery is not present, but there's no active charge port, we must be running on AC somehow so don't send the HardReset as this port may in fact be the previous charge port. BUG=b:176214112,b:178728138 BRANCH=dedede TEST=Build and flash galith; plug in charger on C1, remove battery, sysjump between RO and RW many times, verify that SoC remains in S0. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I16054d9c1ddac780243524e23a656ba3770bb4a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2848290 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* TCPMv2: PE: Refer to vconn swap policy for sop'/sop''Scott Collyer2021-04-241-1/+2
| | | | | | | | | | | | | | | | | | | | | There is a vconn swap check in pe_attempt_discovery that is used to trigger a possible vconn role swap requeest. This check takes into account a board's specific policy (if necessary). But, a vconn role swap can also be triggered when sending a VDM message to SOP'/SOP''. In this case, board specific policy still needs to be checked. BUG=b:183026242 BRANCH=quiche TEST=tested on quiche and verified that there is no longer a continous stream of vconn swap attempts. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I5d239c78dc0d324e0c3dbb99dfc7fa093e2f6570 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827510 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: PE: Clear PRS request following acceptfactory-13929.B-mainScott Collyer2021-04-211-0/+12
| | | | | | | | | | | | | | | | | | | | | This CL adds logic to clear any pending DPM_REQUEST_PR_SWAP once we accept a PRS request from the port partner. This prevents a possible back to back swap if we want to PRS, but the port partner sends the request before PRS swap request is generated. BUG=b:182441965 BRANCH=quiche TEST=tested quiche with kohaku where quiche attaches in sink role. This case causes quiche to want to power role swap and causes the port partner to request a power role swap. Verified that only 1 power role swap occurs. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I05ee27897d5900e71257d268acd3bd37c8abb787 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2799450 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* TCPMv2: Soft reset on Vconn_Swap sequence interruptionDiana Z2021-04-141-0/+12
| | | | | | | | | | | | | | | When a non-interruptible AMS is interrupted, the unexpected message should yield a soft reset on the SOP* of the incoming message. Before sending PS_RDY, check for this condition and soft reset if necessary. BRANCH=None BUG=b:182221344 TEST=on sasuke, confirm charger can successfully connect reliably Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I6612cb5d5d74cf99155cac99894a7746462a7b9e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2823633 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Remove dual-role capability check from Attached.SNK entryDiana Z2021-04-131-16/+7
| | | | | | | | | | | | | | | | | | Currently, we'll check the partner dual role flag when entering Attached.SNK not from a power role swap. However, we have no way to know the partner dual role capabilities at that point. Set up connections as dedicated, and then allow the PE to update accordingly when source capabilities are received. BRANCH=None BUG=None TEST=on guybrush, confirm we automatically charge from a PD charger, non-PD charger, and do not automatically charge from another chromebook Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia7cdf4259c35af32a303113befe0bd2fb26cf6d7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2821365 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Update source PDO flags alwaysDiana Z2021-04-131-8/+12
| | | | | | | | | | | | | | | | | | | Always ensure we update our source PDO flags when storing partner source cap replies during PE_SNK_Evaluate_Capability. However, only propose a power role swap the first time we're storing source capabilities to prevent infinite PR swap loops between Chromebooks. BRANCH=volteer BUG=b:184971310 TEST=ensure connection with a DRP partner results in correct setting of dual role flags (dual-role for anything we don't want to automatically charge from, dedicated for anything we do want to automatically charge from). Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ida139af43fb384096b14e686cf5bd6bbfdf16aa9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2821602 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMV2: Default PD Policy ManagementSam Hurst2021-04-091-18/+13
| | | | | | | | | | | | | | | | | | | A simple implementation to manage PD Policies on honeybun devices. This is meant as an interim solution until a more robust solution is implemented BUG=b:183026242 BRANCH=none TEST=make runtests Tested on Voxel by plugging in a dock Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ib8b38754e21b8497fe28855a7f80d2962a4ae7f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2774128 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* usb_common: support parse Augmented PDOEric Yilun Lin2021-04-081-3/+4
| | | | | | | | | | | | | | | | | | Change the function signature to void pd_extract_pdo_power(uint32_t pdo, uint32_t *ma, uint32_t *max_mv, uint32_t *min_mv); Replace the original caller with an extra unused parameter, no functional changes. BUG=none TEST=`pd 0 srccaps` prints the correct PDO info BRANCH=asurada Change-Id: I9b508e1a13737fe3ed61e6086416cff0c8ffb9a9 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2810660 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* TCPMv2: UFP-D: Make sure OPOS table is cleared in discoveryScott Collyer2021-03-311-0/+3
| | | | | | | | | | | | | | | | | | This CL adds a call to reset the OPOS value in the alt_dp_mode_opos table at the beginning of discovery. This required to pass the VDMU.E5 PD2.0 deterministic compliance test. BUG=b:175660576,b:180465870 BRANCH=None TEST=verifed that VDMU.E5 PD2.0 deterministic compliance test is passing when it's run in the full suite. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I330f35aca88a54c436c84b74618a586e4daaf07b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2777691 Tested-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Increment Vconn swap counter after sendDiana Z2021-03-231-1/+3
| | | | | | | | | | | | | | | | During initial connection, Vconn swaps may be discarded without sending. Only count a Vconn swap for the purposes of the counter when the swap was successfully sent. BRANCH=Volteer BUG=b:182885623 TEST=verify two Voxels connected together are reliably able to enter TBT mode Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia76f03ee4c517d297061bda9dc9b5bfbf5990485 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2776213 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: PE: Add mechanism to request source power roleScott Collyer2021-03-201-3/+13
| | | | | | | | | | | | | | | | | | | | | This CL makes the function pd_can_source_from_device() overridable. This default implementation is used in deciding whether to request a power role swap. By making this overridable, boards have the option of implementing custom per port policy for requesting power role swaps. BUG=b:182441965 BRANCH=None TEST=verfied that on quiche when attaching as a sink that a power role swap request is generated. Previously, quiche relied on the host requesting a power role swap. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I9c5bdb77405a6075de9c5b4269213f810a20cc6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2722989 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: PRL: Don't report ERR_RCH_CHUNKED to PE for timeoutScott Collyer2021-03-191-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a new RCH error type used for the case when there was a sender response timeout waiting for the next chunk of a chunked message to be received. This particular error should not result in the PE triggering a soft reset. This new error type allows the PE function to do nothing for this error case. All other RCH error states remain the same. This change is required to pass the TD.PD.SRC3.E32 compliance test where the tester purposely stops sending after the 4th chunk and expects to be able to resend that message without an protocol error being reported. BUG=b:181333342,b:179443762 BRANCH=None TEST=Verified that quiche can now pass TD.PD.SRC3.E32 Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I0142ca8d23cd23ef7b347d5c07155cdb17f44b88 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2734158 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* TCPMv2: Don't reply to SVDMs in rev2.0 as a DFPScott Collyer2021-03-171-1/+7
| | | | | | | | | | | | | | | | | | | | When are connected to a rev2.0 port partner and in a DFP data role, the only SVDM command that is allowed is the Attention message. All other SVDM commands should be NAK'd. This CL adds a change to the svdm_response function in PE to check for this case. This change fixes TD.PD.VDMD.E4 compliance test. BUG=b:182495985 BRANCH=None TEST=Verified that TD.PD.VDMD.E4 compliance test passes on quiche Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I05bb639b81f634239b6db948ebb760c08b748c08 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2751330 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Don't enter Tx BIST mode when VBUS > VSafe5VScott Collyer2021-03-171-0/+19
| | | | | | | | | | | | | | | | | | | | | | By spec we are only allowed to enter BIST mode when VBUS is at vSafe5V. This CL adds a check in pe_bist_tx_entry to make sure that BIST test mode is only entered if VBUS is at the correct level. We compared to the expected nominal VBUS level and not the actual measured level as not all boards will have accurate enough VBUS measurements. BUG=b:180957710 BRANCH=None TEST=Verfied that quiche can pass the TDA.2.2.7 compliance test. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: Icc2e5ff6c32374c89490e5bea79af2c4517ea295 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2738397 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Fix check for svdm response w/ AttentionScott Collyer2021-03-171-22/+25
| | | | | | | | | | | | | | | | | | | | Attention messages do not require a response message. A previous CL had a check for this message in a helper function. That method was not correct because the the vdm message buffer in the PE object does not get cleared and so this buffer should only be checked in a state where the vdm buffer contents are known to be current. BUG=b:175660576,b:173027965 BRANCH=None TEST=Verified on quiche that can enter ALT-DP mode as a UFP-D and that display is extended properly via display port or hdmi connector. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: Id9908fd4bd3db574fb6f769ab0d2e1db0be5aecd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718270 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMV2: Add support for (CT) Vconn Powered DevicesSam Hurst2021-03-171-2/+17
| | | | | | | | | | | | | | | | | | | | | Add support for Charge Through Vconn Powered Devices BUG=b:165934405 BRANCH=none TEST=make runtests 1) Verified that Apple VPD audio device worked. 2) With charger plugged into Chocodile_Vpdmcu, verified that a Voxel could be charged. 3) FAILED: Plugging Chocodile_Vpdmcu into Voxel first and then plugging in charger to Chocodile_Vpdmcu, Chocodile is detected as a Debug Accessory (CC1 = Rd and CC2 = Rd) and VCONN is never applied. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I977b316dc531aa33bb6a236523c8ddbbb23014d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2748429 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Preserve selected source current in FRSDiana Z2021-03-171-4/+7
| | | | | | | | | | | | | | | | | | | | When executing a fast role swap, ensure that any 3.0 A selected current is preserved through the select_current_limit_rp in the TC layer. Additionally, use this selected current to set our current limit when first attaching as a source. If FRS is disabled on a port, restore the default Rp value for the board. BRANCH=None BUG=b:180434465 TEST=Check that a 3A FRS device loaded over 1.5 A is able to successfully complete FRS Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I6e6b2f95066a3f8972664c6ac62b450e179e408d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757096 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add support for disabling type-2 BIST modeScott Collyer2021-03-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | This CL adds a TCPCI method to disable BIST mode for the case where the TCPC does not handle the duration automatically. This is required for the ucpd driver as once type-2 BIST mode is started, the ucpd peripheral needs to be reset to stop. This CL also reduces the timer value from 60 msec to 55 msec to ensure that there is enough time for BIST to be stopped and still be in spec. BUG=b:182436876 BRANCH=None TEST=verifed on Quiche that when type-2 BIST is started then it stops when the timer in PE expires. This fixes TDA.2.1.1.1: BMC-PHY-TX-EYE Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I59ee7ac0dead09ac3a1b5783cfa3fe9db238eb7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2660803 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* TCPMv2: Start Error Recovery when errant FRS signal comes inDiana Z2021-03-091-1/+8
| | | | | | | | | | | | | | | | If the PE layer is not currently running when a FRS signal is received, generate USB Type-C Error Recovery on the port to try getting back into a known good state. BRANCH=None BUG=b:180453483 TEST=on voxel, ensure that Vbus turned is off when FRS signals after TC detach from a device Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I185df235a5e9667db73869b07d0c89afaf0d9b67 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718837 Reviewed-by: Scott Collyer <scollyer@chromium.org>
* TCPMv2: PD Timers - Allow StateMachine timer group range disablesDenis Brockus2021-03-021-4/+1
| | | | | | | | | | | | | BUG=none BRANCH=none TEST=normal USB-C operation Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I9c5bc90cc68ba424ad7632c10ba513103288b414 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2729620 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Don't Soft_reset in SNK_SRC_SOURCE_ONEric Herrmann2021-03-021-0/+1
| | | | | | | | | | | | | | | | | | | | In state PE_PRS_SNK_SRC_SOURCE_ON, we shouldn't soft reset and instead use ErrorRecovery: The Policy Engine Shall transition to the ErrorRecovery state when: - The PS_RDY Message is not sent after retries (a GoodCRC Message has not been received). A soft reset Shall Not be initiated in this case. Add an exception to the protocol error handling to not use Soft Reset. BUG=b:181054403 TEST=Check that we don't use Soft reset by running TD.PD.FRSISNK3.E6 BRANCH=None Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Change-Id: Icc85cf768b19f72aaadfe16c611f735167f4ad5e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727861 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: PE_TIMER_SINK_REQUEST should not disable on exit or re-entry of SnkReadyDenis Brockus2021-03-021-12/+5
| | | | | | | | | | | | | BUG=b:181343741 BRANCH=none TEST=Check SINK attach Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ifdbd683c9e761a3ccd3d01d648f88b0f47721e0b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2729616 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: PE_TIMER_WAIT_AND_ADD_JITTER should not restart on partner initiated ↵Denis Brockus2021-03-021-9/+8
| | | | | | | | | | | | | | | messages BUG=b:181339670 BRANCH=none TEST=verify basic USB-C operation Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ic126b9cc87e3d76ffd4fe369c9259e1c6fc2500f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2729270 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: pe_send_soft_reset_run should use pe_sender_response_runDenis Brockus2021-03-021-10/+30
| | | | | | | | | | | | | BUG=b:181337870 BRANCH=none TEST=run through new attach to get soft reset condition Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ifc8beed63cdffa87a341f8ccc37647a9203867c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2729268 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: PD Timers - Add PE SourceCap to frameworkDenis Brockus2021-03-021-13/+4
| | | | | | | | | | | | | BUG=b:178029034 BRANCH=none TEST=make runtests Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I2c311fef241d0952c11967ce76fe168b061c3283 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718387 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: PD Timers - Add DiscoverIdentity to frameworkDenis Brockus2021-03-021-24/+14
| | | | | | | | | | | | | BUG=b:178029034 BRANCH=none TEST=make runtests Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I212c098009b2fce753cf1300959b31d6a8b97542 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718386 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: PD Timers - Add PE PRSwapWait to frameworkDenis Brockus2021-03-021-10/+7
| | | | | | | | | | | | | BUG=b:178029034 BRANCH=none TEST=make runtests Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I06533a967224d06dbd85459c6eed816d6d354158 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718385 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>