summaryrefslogtreecommitdiff
path: root/common/usbc
Commit message (Collapse)AuthorAgeFilesLines
* tree: rename atomic_* functions to deprecated_atomic_*Jack Rosenthal2020-09-293-43/+62
| | | | | | | | | | | | | | | | We will move to an API compatible with Zephyr's API. See the bug for complete rationale and plan. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Always disable Vconn in CC OpenDiana Z2020-09-251-2/+1
| | | | | | | | | | | | | | | CC Open will run on most inits, so don't rely on the Vconn flag to trigger its disable. BRANCH=None BUG=None TEST=on waddledee, manually sysjump with a sinking dongle plugged in and ensure Vconn is turned off during Open Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ib7bb1cff66d939631b445c042bb4a41e1043f914 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2424704 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Ensure previous Vbus is turned off on initDiana Z2020-09-251-2/+7
| | | | | | | | | | | | | | | When we boot from reset, other board components may still be sourcing out to partners. Ensure these are turned off during init time. BRANCH=None BUG=b:168931726 TEST=on waddledee, EC reset with servo attached as a sink and ensure DUT is able to start sourcing to servo Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5a5de7f510ce81307c7155659a03f401eac3a885 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2424703 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usb_pd: Add common function to get PD revisionli feng2020-09-231-0/+5
| | | | | | | | | | | | | | | Add common function for both TCPMv1 and TCPMv2 to get PD revision Modify TCPMv1 pd_get_vdo_ver() to get correct cable VDO version BUG=none BRANCH=none TEST=make buildall Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I7cc597a45e9581346683b7af54894bffb48d16bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2420468 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* tcpmv2: require init_vdm_mode ack response svid == requested svidDenis Brockus2020-09-231-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | If an INIT VDM ACK response SVID is not equal to the requested SVID then treat this as a NAK This is being seen on the Lepow monitor I was testing on. The sequence looked as follows: DUT: REQ SVID=DP MON: ACK SVID=DP DUT: REQ SVID=Nintendo MON: ACK SVID=DP BUG=b:169077500 BRANCH=none TEST=Lepow monitor should not infinite loop on INIT_VDM Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I55210588494fdc09ed8f3551569262d70ba63277 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2426122 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* test: Add test_send_caps_error to usb_pe_drpEdward Hill2020-09-221-1/+1
| | | | | | | | | | | | | | | | | 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>
* TCPMv2: Define typeccontrol host commandAbe Levkoy2020-09-213-0/+29
| | | | | | | | | | | | | | | For now, just support exiting the entered mode, if that mode happens to be DisplayPort (getting TBT3 and USB4 to work correctly will require some more work). Support this command in ectool. BUG=b:168030639 TEST=ectool typeccontrol 0 1; observe DP Exit Mode exchange in PD trace BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ib30479cc88696115060e9ff74f6815ce074e6bf5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415069 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Move DPM requests to public APIAbe Levkoy2020-09-214-23/+22
| | | | | | | | | | | | | | | | It is safe (atomic bit ops) and will soon be necessary (new host commands) to send DPM requests from outside the PD tasks. Rename pe_dpm_request to pd_dpm_request and move the declarations into usb_pd.h to reflect this. BUG=b:168030639 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ied43e9f6973a3172b98090cc068a607257dce21b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415068 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpmv2: don't call tc_partner_usb_comm if in an alt-modeDenis Brockus2020-09-191-4/+7
| | | | | | | | | | | | | | | | BUG=b:168805145 BRANCH=none TEST=Ikling hub unattached power to powered with HDMI attached Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ie3bfce1d6159d93df5c646fcfa00e4b7e51eb4b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2419176 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: set object position in SVDM response headerli feng2020-09-181-0/+7
| | | | | | | | | | | | | | | | | | | | | Per PD 6.4.4 about Object Position, on receiving Enter Mode request, the responder shall set the offset of mode entered in Object Position field, and it shall be the same value as that in request; on receiving Exit Mode request, the responder shall set the offset of the mode to be exited in Object Position field, and it shall be the same value as that in request. This field shall be set to zero in the request or response(REQ, ACK, NAK or BUSY) when not required by specification of the individual command. BUG=b:148528713,b:157163664 BRANCH=none TEST=make buildall -j 4 Signed-off-by: li feng <li1.feng@intel.com> Change-Id: Icf68d003abb9f1ab9f71fb0646c5e3fb1c5f644a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2399775 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* tcpmv2: Retry PR Swap if partner sends Wait responseKeith Short2020-09-181-9/+62
| | | | | | | | | | | | | | | | | | | | | For the SRC to SNK PR Swap, if the partner responds with Wait, retry the PR swap request up to 5 times, delaying tPRSwapWait (100ms) between retries. This change removes the PE_FLAGS_WAITING_DR_SWAP flag. The flag was only set, never checked, and never cleared by any code in the PE. BUG=b:168808976 BRANCH=none TEST=make buildall TEST=Connect Gatkex creek board, verify PR swap from SRC to SNK after receiving Wait message. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I4854ab03bd771feee33fa1ae71aa9407f2d4f109 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2417148 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* tcpmv2: Handle discarded messages during EnterUSBKeith Short2020-09-181-10/+16
| | | | | | | | | | | | | | | | | Pending EnterUSB messages were not handling message discards. This resulted in the EnterUSB message never transmitting if the port partner sent a message while the EnterUSB message was queued. BUG=b:168453520 BRANCH=none TEST=make buildall TEST=Connect Volteer to Gatkex board. Verify entry into USB4. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ica45c098be3b8819aec3c8d3eeb5a8069f44dcb8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415081 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Correct setting mux state on updating partner's USB commAyushee2020-09-181-3/+6
| | | | | | | | | | | | | | | | | When the USB communication capabilities are enabled and if the port receives partner's USB communication capability again after entering an alternate mode, mux doesn't need to be updated. Hence, only the mux with port partner's USB communication capability if it is in disconnect state BUG=b:168453520 BRANCH=None TEST=Able to retain mux's state after entering a mode. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I26af254b341c9f0c1cdc4369a50e16f9da329faf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2407014 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Print PRL states on higher levelDiana Z2020-09-141-6/+6
| | | | | | | | | | | | | | | | | This change moves the PRL state prints up to debug level 3. This way, debug level 2 can be used to easily just see incoming packets without the state prints cluttering the EC console. BRANCH=None BUG=None TEST=on drawlat, set "pd dump 2" and confirm responses are printed but PRL states are not Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I8dc96c3d60176597cb0b9fab29e031a9d7e84147 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2406335 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* tcpmv2: Fix PD_EVENT_SEND_HARD_RESETEdward Hill2020-09-111-0/+3
| | | | | | | | | | | | | | PD_EVENT_SEND_HARD_RESET was not connected up to anything. BUG=b:166536767 BRANCH=zork TEST=hard reset on OC Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I2d6fd660ce5b8b9208ae74cb9a128aae3ba2b51f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402138 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Improve timing in Attached.SRCAbe Levkoy2020-09-111-40/+28
| | | | | | | | | | | | | | | | Don't wait an extra 15 ms to debounce CC after detecting CC open. Don't wait to react to CC open until PD is enabled. BUG=b:163143427 TEST=Attach volteer C1 to volteer C1; observe unstable Attach.SRC, but PE doesn't start BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ibd4bd4948fefd5f931dcdc98b1716744c46682b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2392563 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* tcpmv2: SRC->SNK PR_Swap if partner has unconstrained powerDenis Brockus2020-09-111-4/+8
| | | | | | | | | | | | | | | BUG=b:165983983 BRANCH=none TEST=connect bug mentioned dock make sure we are SNK Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I60b0b8fb9b4d9dd2a232f053a40f0c4f33b57bc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402339 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: Enable AutoDischarge on SRC->SNK PrSwap only if VbusDenis Brockus2020-09-111-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | AutoDischargeDisconnect should not be re-enabled during SRC->SNK PR_Swap if Vbus is not present. This would happen only as an error condition with the connected partner becoming unattached during the swap. Also, when we are SNK, we should disable/re-enable AutoDischargeDisconnect when we hard reset because we are shutting off sinking and Vbus will drop to Safe0V BUG=b:168128121 BRANCH=none TEST=PR_Swaps with bug mentioned dock Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I891857967559ecea0a7990626ef8fc3c6835797a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402338 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Set mux state on updating partner's USB comm capabilityAyushee2020-09-111-0/+6
| | | | | | | | | | | | | | | | | On updating the port partner's USB communication capability, the mux should also be configured into USB/disconnect mode accordingly. Hence, this CL sets the mux setting according to the partner's USB capability. BUG=b:157163664 BRANCH=None TEST=Able to update the mux state on updating the port part USB comm capability. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Ic2d27e2a0af6dad54a875a589b85f8a5d583b5b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2388972 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Block enabling PD in RO for non-EFS2 and dead-batteryWai-Hong Tam2020-09-111-2/+17
| | | | | | | | | | | | | | | | | If enable PD in RO on a non-EFS2 device, a hard reset will be issued when sysjump to RW that makes the device brownout on the dead-battery case. For this special case, disable PD in RO as a workaround. BRANCH=None BUG=b:166307654,b:168134171 TEST=Tested on Pompom, without battery attached. EC warm reset and sysjump to RW won't cause the board power-lost. EC warm reset may be brownout but the next boot is fine. Change-Id: Ie6e7687aa8e160012f9bbd725e0fbcbacae94cf2 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402150 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Obtain correct dual role state when going suspendPatryk Duda2020-09-111-3/+3
| | | | | | | | | | | | | | | | | | | | | Some boards (eg. eve) don't source VBUS in S3 state. In this case DRP state should be set to force sink instead of toggle off. This CL introduces pd_get_drp_state_in_suspend() function and uses it to obtain correct DRP state when entering suspend. Default implementation of pd_get_drp_state_in_suspend() returns PD_DRP_TOGGLE_OFF, so this commit introduces no functional changes. BUG=b:162254118 BRANCH=none TEST=No functional changes in this CL make -j buildall Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Iacf8fcdbad027563015f593653d3ed8a49752131 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2395558 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpmv2: Increase SOP' Discovery Identity timeoutKeith Short2020-09-091-8/+28
| | | | | | | | | | | | | | | | | | | | Increase the tDiscoveryIdentity timer outside of an explicit contract so that SOP' Discover Identity commands are only sent at the same rate as Source Cap messages. This allows operation with captive cable devices that power the SOP' responder from VBUS instead of VCONN. BUG=b:166650426 BRANCH=none TEST=make buildall TEST=Verify TBT entry with the TBT loopback device. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I862a0284f36fe8aa2fb78eeaa3ac9db2764da32f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2399036 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add board_tcpc_init() call during initializationPatryk Duda2020-09-091-0/+5
| | | | | | | | | | | | | | | | | | | | Some platforms (eg. eve) need to call board_tcpc_init() from PD task. This patch makes board_tcpc_init() to be called if CONFIG_USB_PD_TCPC_BOARD_INIT is defined. For more information please refer to commit: bd018841f6f2856c949dcf9b6dd462872cd18d7f BUG=b:162254118, b:63957122 BRANCH=none TEST=Compile firmware with TCPMv2 support, flash on eve, check if charging works. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ib680cddc6c693bd02031100d38bb5edfebad57fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2395560 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* cleanup: Move High-priority interrupt task to a separate fileVijay Hiremath2020-09-091-99/+1
| | | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: I63a964721a5471d6a00894cb0cb94e9656c10893 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2389325 Reviewed-by: Poornima Tom <poornima.tom@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* cleanup:Consolidate multi PD INTR task config to single configPoornima Tom2020-09-041-3/+2
| | | | | | | | | | | | | | | | | | | For a multi Type-C board DUTs, use a common config CONFIG_HAS_TASK_PD_INT for all the PD_INT tasks defined. Also,it must be ensured that PDCMD task and PD_INT tasks are not used togethor. BUG=none BRANCH=none TEST=make buildall -j Also, adding PDCMD and PD_INT tasks in ec.tasklists successfully threw error message:"Should not use PDCMD task with PD INT tasks" Signed-off-by: Poornima Tom <poornima.tom@intel.com> Change-Id: I1c5f3dd6b46bc355bca8b93f8f1d356db54c0faa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2387686 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tcpmv2: Fix SOP' DiscoverIdent retries.Keith Short2020-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | The PE DRP state machine was sending retries of SOP' DiscoverIdent without any delay. This sets the delay between SOP' DiscoverIdent to tDiscoverIdentity (45 ms). The EC uses this delay regardless of the explicitly contract state. BUG=b:166650426 BRANCH=none TEST=make buildall TEST=Connect SNK device without emarker cable. Observe retries are spaced by at least 45ms. TEST=Connect emarker cable and verify cable identity is discovered. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I05134052fe3576e1dd94d8aa0963a67dce080027 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2391822 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* TCPMv2: Add EC_CMD_TYPEC_DISCOVERYDiana Z2020-09-033-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This host command will return all discovery information for the given port and transmit type (SOP, SOP'). Each piece of information includes a count of the number of valid fields filled in to the arrays. To keep the command consolidated and easy to parse, this means there will be some number of bytes in each response which do not contain useful information. With this method, we may fit 7 SVID entries with mode information, which is less than the 16 which the EC can store, but more than most port partners present. BRANCH=None BUG=b:165264379 TEST=on waddledoo, confirm ectool shows: -no discovery information with nothing plugged in -no discovery information with a charger which doesn't reply to VDMs -SOP identity but no SVIDs with Moshi, which NAKs DiscoverSVIDs -SOP identity and all SVIDs with Apple 3-in-1 -SOP and SOP' identity and all SVIDs with TBT dock Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Idf21b23ebe4cda62781762188601b2cc35ede65d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363417 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* tcpmv2: allow early connection when waiting to allow LPMDenis Brockus2020-09-021-5/+8
| | | | | | | | | | | | | | | | | | While waiting to go into Low Power Mode the TCPC can detect a connection and we should honor that instead of waiting for the timeout and going into Auto Toggle. BUG=b:157718272 BRANCH=none TEST=FAFT_PD "dut-control usbc_pr:src20v" Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ib3a3233ebf9b05b83446d7c1163e30fdcaf42aec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2390848 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add DPM_REQUEST_GET_SRC_CAPDenis Brockus2020-09-022-5/+101
| | | | | | | | | | | | | | | | | | | | | As a SRC that runs on battery it can be handy to determine if the connected partner has unconstrained power available so we can try to PR_Swap to let them power us. This only requests the information, if it is not already available, and leaves it to other code to determine if the swap is a good idea. BUG=b:166446426 BRANCH=none TEST=connect a sink device and determine it performed the action Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: If45801a33df8b75e541989d7ee8f36ed316ffcc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381408 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Disabling DPM_REQUEST for SnkGetSnkCaps if FRS disabledDenis Brockus2020-09-021-4/+18
| | | | | | | | | | | | | | | | | | | Leaving this code in when we don't care about the single thing we are getting from it, whether the partner can do FRS, does not make a lot of sense and wastes flash space if we do not have FRS configured to be enabled in the current build. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I73568f04af5bf1df7a03b53983b8e1f443dbdae7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381407 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: allow TxSinkNG/OK to cross power roles on pr_swapsDenis Brockus2020-09-021-24/+12
| | | | | | | | | | | | | | BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I056b61cc0e6b7a56f1673728f52783c9d0cf196c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370746 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: clear Modal and VDMSetupDone in dfp_discovery_initDenis Brockus2020-09-021-4/+6
| | | | | | | | | | | | | | | | | | Clear MODAL_OPERATIONS and VDM_SETUP_DONE flags in pd_dfp_discovery_init to to make sure we do a full discovery BUG=b:165983983 BRANCH=none TEST=dock specified in bug should be able to PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Idcccf131e7a0dce25d11b740e947e53be8d69dc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2378200 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: use sender_response message frameworkDenis Brockus2020-09-021-128/+234
| | | | | | | | | | | | | | | | | | Building up the framework to handle discarded DPM requests and using it on all of the sender_response messages BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I542d4cba89a923fb16588cc675d2ea4ab7954e0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376386 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: clear oc counter when unattched.SNKZick Wei2020-09-021-0/+8
| | | | | | | | | | | | | | | | This CL clear oc_event_cnt_tbl for both USB-C0, USB-C1 port when in unattached.SNK state. BUG=b:166536767, b:165946265 BRANCH=zork TEST=verify that oc event counter will be clear when in unattached.SNK Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: If1d6f56d32ad62e8195456ad4fa5e1286a7bac81 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2387680 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: disable receive of SOP' during VCONN swapKeith Short2020-09-021-2/+25
| | | | | | | | | | | | | | | | | | | The USB PD specification indicates that the initial VCONN source shall cease source VCONN within tVCONNSourceOff (25 ms) after receiving PS_RDY. Not all partners wait after sending PS_RDY before trying to communicate with the cable. BUG=b:163478172, b:163143427 BRANCH=none TEST=make buildall TEST=Connect 2 Volteers together and force VCONN swaps confirming the sequence completes normally. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I14720f033c5f6e9caed9c4fe3bfa11e5c046116e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381030 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Send SOP'/SOP'' VDM only when the port is VCONN srcAyushee2020-08-282-1/+77
| | | | | | | | | | | | | | | | | | | | | | According to USB PD spec, section 2.5.4, only VCONN source can communicate with the cable plug. This CL checks if the port is the VCONN before sending SOP'/SOP'' messages. If there is a VCONN source failure, port retries swapping the VCONN times before marking the VDM as failed/naked. The CL also enables falling back to DP mode in case enter mode thunderbolt fails. BUG=b:148528713 BRANCH=None TEST=Tested on volteer, the port sends SOP'/SOP'' VDMs to the cable only if it's the VCONN source Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I5880104a7a42b3e7de9e472affd41e937d36f9a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368066 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: set VDM response buffer and lengthli feng2020-08-281-13/+30
| | | | | | | | | | | | | | | | | | | Pass tx_emsg[port].buf to VDM response implementation functions Convert data objects count to bytes VDM header in VDM response message should not use USB_VID_GOOGLE as SVID to respond to all requests. Save SVID from received request and compose response VDM header with this SVID. BUG=b:148528713,b:157163664 BRANCH=none TEST=Connect volteer to Gatkex DFP port, with CL:2370045, check VDM response messages from Volteer have correct contents. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I7403af1449abfa4ebf6b43ded457e3654396aadb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368067 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* hack: temporarily work around TX_COMPLETE failureJett Rink2020-08-271-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After we removed the retry logic in the PRL layer, we uncovered an issue that was being masked. On Delbin, the state machine is not receiving that the PD messages (namely Request) is being sent successfully. We get neither success or failure within 100ms. We still need to figure out and fix this the root cause. This change just assumes that any sent PD traffic is successful after 100ms (instead of a failure) for Delbin boards only. There is an upcoming build for Delbin that we will have power on issues if we don't add some kind of power work around. This patch will not allow the USB PD stack on Delbin to work properly in all scenarios; this patch only aims to ensure that we can get power to the device to test other non-PD functionality. This CL should be reverted within a two week time frame. BRANCH=none BUG=b:164154200 TEST=Delbin can power on Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: If6dce35dfd78ee3a70e6216a7b6bf62d3ded5646 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376477 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Anson Tseng <ansontseng@google.com> Tested-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com>
* TCPMv2: re-enable GetSnkCap call for allDenis Brockus2020-08-271-67/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | The problem was a discarded SendSrcCap message that happened around the same time as the GetSnkCap. GetSnkCap timedout and did what it was supposed to do but the SendSrcCap locked up waiting for the message to transfer before it started the timer to allow it to time out. Never would happen. Built in a framework to track the current DPM request to make discard redirections easier to determine. Also good for re-queuing DPM requests that are discarded. BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I8854ac745d4489125c84b7e617d5fa1a94e70e51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370747 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Modal Operations should clear in dfp_discovery_initDenis Brockus2020-08-261-0/+2
| | | | | | | | | | | | | BUG=b:165983983 BRANCH=none TEST=dock specified in bug should be able to PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ifaccba2d741ed066e6bafc95c7e604b8f8dcfb17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2373322 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usb_mux: move usb_mux_set_safe_mode()Keith Short2020-08-241-0/+1
| | | | | | | | | | | | | | Move usb_mux_set_safe_mode() definition into usb_common.c so it's available to the test framework. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I789a470468ae441e366afbf94ce3c29db526dfd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370409 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Don't interrupt RX/TX Extended Chunked Msg sequenceSam Hurst2020-08-222-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: remove PD_EVENT_SM in favor of task_wakeJett Rink2020-08-213-14/+13
| | | | | | | | | | | | | | | | We have used both methods of waking up the PD tasks to process the next state: PD_EVENT_SM and TASK_EVENT_WAKE. They effectively do the same thing and it is more straightforward to only have one way to wake the task up with the sole purpose of re-evaluating the current state. BRANCH=none BUG=none TEST=No regressions on GRL testing. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I0fa79b82223e6b97eede4130480156949d79f365 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363466 Reviewed-by: Edward Hill <ecgh@chromium.org>
* TCPMv2: SRC->SNK PR Swap enable AutoDischarge after VbusDenis Brockus2020-08-211-15/+37
| | | | | | | | | | | | | | | | | | | A debounce was added to allow for the TCPC to get a valid Vbus but AutoDischargeDisconnect was enabled as soon as we set for the debounce. Since Vbus had a good chance of not being valid, we would get a FAULT from the TCPC indicating an Auto Discharge Disconnect failure. BUG=b:165797061 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I897d682e405d7f2fcda4b4a36a3c1b333e8f7913 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2365253 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: PR_Swap SRC->SNK should send PS_RDY in current AMSDenis Brockus2020-08-211-6/+16
| | | | | | | | | | | | | | | | | | The SRC->SNK PR_Swap is currently starting a new AMS for the SNK PS_RDY and this causes the partner to disconnect from the bus instead of continuing with the swap. BUG=b:165794652 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Id953a9b6f78057777617d06f518eb17b061b6f92 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2365057 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Do not send GetSnkCap if FRS is not enabledDenis Brockus2020-08-211-1/+10
| | | | | | | | | | | | | | | GetSnkCap is only needed for FastRoleSwap BUG=none BRANCH=none TEST=PR_Swap DUT-DUT testing Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I51973dfbfbfe855d1027c3b1cec35a2ba06a7b65 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2367283 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usbc: wake task on every state transitionJett Rink2020-08-192-0/+10
| | | | | | | | | | | | | | | | | | Whenever we change state, we should continue to wake the USB statemachine task up until is settles into a steady state were it is waiting/polling on a timer or event. BRANCH=none BUG=b:163152687 TEST=Ran GRL PD3.0 test on Trembyle and did not see any regressions. It did make a few tests pass that were failing before due to timing issues. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Idc3c1ae8d92a0f6a5cd4b82f9db6d7138d143f77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2356954 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* cleanup: update formatting for clarityJett Rink2020-08-191-11/+10
| | | | | | | | | | | | | | | Make it clear that there are multiple function calls happening instead of a single statement with multiple parameters. BRANCH=none BUG=none TEST=builds. No actual code change Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I1c01a40794e0c2dc08be205ac953f42bdc9298be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363465 Commit-Queue: Edward Hill <ecgh@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* TCPMv2: Debounce VBUS on SRC to SNK swapKeith Short2020-08-181-2/+21
| | | | | | | | | | | | | | | | | Copying TCPMv1 behavior, debounce VBUS at the completion of a SRC to SNK swap to allow the TCPC/PPC to update the VBUS state following receipt of the PS_RDY message from the partner. BUG=b:162347811 BRANCH=none TEST=make buildall TEST=Force power role swaps and observe no false disconnects. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ia0644cde64d14044b7e291bf582b68ac4278af0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363411 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* cleanup/usbc: organize all super states togetherJett Rink2020-08-131-27/+30
| | | | | | | | | | | | | | Like other state machine declarations, put all of the super states together to make it more clear when reading states. BRANCH=none BUG=none TEST=build and unit tests Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I1bb776434911d3acdb34abc64e7e8fa5f87154de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354193 Reviewed-by: Edward Hill <ecgh@chromium.org>