summaryrefslogtreecommitdiff
path: root/include/usb_pd.h
Commit message (Collapse)AuthorAgeFilesLines
...
* TCPMv2: Use a common function to check if the battery is capableWai-Hong Tam2020-10-171-2/+11
| | | | | | | | | | | | | | | | | Move the battery checks to a common function, which is used to enable Try.SRC and enable PD comm for CONFIG_SYSTEM_LOCKED. BRANCH=None BUG=b:169453974 TEST=On a board with battery which takes longer time to enable its discharge FET, cut off the battery and booted the board. Checked on startup the Try.SRC was disabled and the PD comm was disabled. When the battery discharge FET became active, PD comm was enabled. Change-Id: I236d5f8a462ece056b4adedd0b6e6ef1e402966c Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2461942 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Add framework for per-port eventsDiana Z2020-10-051-0/+20
| | | | | | | | | | | | | | | The AP would like to retrieve events on a per-port basis, so add new tracking for those events, as well as the capability for non-PD tasks to retrieve and set those events. For the moment, the code just clears events on startup and event flags will be added in subsequent CLs. BRANCH=None BUG=b:148816435 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I9c2644141b4f5277ee54b4bf2c30087b51a87d8e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432454
* TCPMv2: Add TYPEC_STATUS commandDiana Z2020-10-051-26/+0
| | | | | | | | | | | | | | | | | | | | | | | The TYPEC_STATUS command will be deprecating the informational return from the USB_PD_CONTROL host command. It brings over the enablement, role, and connection information from the older command. Cable specifics are excluded as they are redundant with the discovery return. Information about the mux state is also added for convenience. Additionally, this moves enums and defines which are a part of our overall pd_* API to the ec_commands.h file to ensure consumers have the same field values available for interpretation as the EC. BRANCH=None BUG=b:167700356 TEST=on waddledoo, plug in chargers and dongles and ensure outputs from "ectool typecstatus <port>" match "ectool usbpd <port>" and "ectool usbpdmuxinfo" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ic7afc0b282b88fdb34cb9a6feef22ad913bb4aae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432452 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add VBUS_REMOVED levelDiana Z2020-10-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | For boards which use Vbus ADCs, add a VBUS_REMOVED check level. The level for VBUS_PRESENT should be used in any locations looking for "Vbus is present" on transition, but in order to correctly detect disconnection with a load on Vbus, VBUS_REMOVED (vSinkDisconnect) is required. TODO statements have been added for places where work will be needed to support vSinkDisconnectPD in the future. For boards detecting Vbus through an external chip, the levels will likely be indistinguishable due to the chips setting a lower threshold for disconnect than for connection. Unit test code has also been added to encourage new Vbus levels to be added to the mock, and remind developers to update all locations using the vbus_level enum. BRANCH=None BUG=b:168831161 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I04014ce54ec162dd9c62f545126d921c6d880741 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2436580 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usb_pd: Add common function to get PD revisionli feng2020-09-231-2/+14
| | | | | | | | | | | | | | | 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: Define typeccontrol host commandAbe Levkoy2020-09-211-0/+1
| | | | | | | | | | | | | | | 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-211-0/+38
| | | | | | | | | | | | | | | | 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>
* USB-PD: Continue mode discovery after failureDenis Brockus2020-09-191-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pd_get_next_mode was searching the svid_mode_data looking for the next entry to discover, if there are any. Failed and needs discovery were handled the same way, return that entry. So if you had a discovery entry that fails that gets returned and causes the entry to stop, over and over again This issue was found using an ikling hub with attached AC connected to Morphius the SVID discovery finds two SVIDs, DP and Nintendo. The Nintendo fails and this caused the alt-mode to not enter for the valid DP mode. The change is to continue discovery even if there is a failure discovered. If any of the modes succeeded then it will be considered success if there are no new modes to discover. This is the order of returned values: no entries -> successful. an entry that need to be discovered -> return discovery entry. everything discovered properly in the list -> successful. discovered some good and some failed -> successful. all discovered fail -> return first fail. BUG=b:168804124 BRANCH=none TEST=verify morphius monitor when attached ikling powered hub Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Id2064079614c276f3d2054c5bcb194cdb997514c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2416990 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: Retry PR Swap if partner sends Wait responseKeith Short2020-09-181-0/+1
| | | | | | | | | | | | | | | | | | | | | 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>
* PD: Add voltage levels from PD specDiana Z2020-09-151-0/+4
| | | | | | | | | | | | | | This includes some of the voltage levels defined in the PD specification for central reference, similar to the timers. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ib33611e5814393337043c114d1120c8c67c77576 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2406341 Reviewed-by: Jett Rink <jettrink@chromium.org>
* USB-C: Make Vbus check overridableDiana Z2020-09-151-1/+4
| | | | | | | | | | | | | | Boards may have capacity to detect vSafe0V outside the TCPCI driver. Make the Vbus level check overridable so boards may define their own. BRANCH=None BUG=b:167666781,b:160996247 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I7b8c582a3efdf1d338fc335b9798edc85b5f62a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2406340 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Obtain correct dual role state when going suspendPatryk Duda2020-09-111-0/+8
| | | | | | | | | | | | | | | | | | | | | 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: Add EC_CMD_TYPEC_DISCOVERYDiana Z2020-09-031-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* TCPM: Correct VDO structuresDiana Z2020-09-021-0/+2
| | | | | | | | | | | | | | | | | When defined bit fields for a unit8_t cross byte boundaries, this can cause unexpected packing. In this case, all of the VDO unions were actually of size 8, rather than size 4. This change alters the fields to be defined in a uint32_t, and adds build asserts to ensure the unions remain the correct size. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia3d585820dcb3e825c02f8732791b53fbdff96af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379992 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: set VDM response buffer and lengthli feng2020-08-281-0/+8
| | | | | | | | | | | | | | | | | | | 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>
* usb_mux: move usb_mux_set_safe_mode()Keith Short2020-08-241-7/+0
| | | | | | | | | | | | | | 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>
* usbc: remove PD_EVENT_SM in favor of task_wakeJett Rink2020-08-211-5/+3
| | | | | | | | | | | | | | | | 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>
* tcpc: Add TCPC reset as a low power eventKeith Short2020-08-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Some TCPCs do not immediately generate an CC_STATUS interrupt when waking from low power mode on a device connect. Add PD_EVENT_TCPC_RESET as a low power event to the type C state machine exits TC_LOW_POWER_MODE. The low power exit delay ensures the type C state machine gives the TCPC an opportunity to internally debounce the CC lines and report a CC_STATUS interrupt. BUG=b:165850054 BRANCH=none TEST=make buildall TEST=Verfiy connection of SRC and SNK devices on Volteer. Tested against TUSB422, PS8815, and RT1715 TCPCs. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I21f691d750ef569c02e8d00f528a4f2e6d3064be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2369369 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* usbc: wake task on every state transitionJett Rink2020-08-191-6/+3
| | | | | | | | | | | | | | | | | | 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>
* TCPM common: Store number of Identity VDOsDiana Z2020-08-191-0/+2
| | | | | | | | | | | | | | Store the number of valid identity VDOs that were received for use later. BRANCH=None BUG=b:165264379 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I54f991c862c4b6589edff2476a79b5c3a8b69b4b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363416 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* ec: change usage of dummySam Hurst2020-08-051-1/+1
| | | | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the term "dummy" with inclusive alternatives. BUG=b:162781382 BRANCH=None TEST=make -j buildall `grep -ir dummy *` The only results are in "private/nordic_keyboard/sdk8.0.0" which is not our code. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I6a42183d998e4db4bb61625f962867fda10722e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335737 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* TCPMv2: Use named constants for extended messagesAbe Levkoy2020-07-291-1/+3
| | | | | | | | | | | | | | These correspond to MaxExtendedMsgLen and MaxExtendedMsgChunkLen (PD 3.0, rev 2.0, ss 6.13). BUG=b:160374787 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I3640df18724c3c04e9f644ca59a6542563d723f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316135 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Optionally build extended message supportAbe Levkoy2020-07-291-43/+46
| | | | | | | | | | | | | | | | | | If CONFIG_USB_PD_EXTENDED_MESSAGES is defined, support sending and receiving extended messages. If it is not, remove the chunking state machines from the PRL and modify the PE to respond with Not Supported as appropriate. BUG=b:160374787,b:158572770 TEST=Attach various devices; observe PD traffic TEST=make run-usb_prl_noextended; make run-usb_pe_drp_noextended BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I862020155927b5613d599274708e60678c49c43c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304263 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec: change usage of whitelist/blacklistPaul Fagerburg2020-07-281-1/+1
| | | | | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "whitelist", "blacklist", and similar with inclusive alternatives. BUG=b:162262297 BRANCH=None TEST=`grep -Eirl "(white|black)[ _\-]*list" .` The only results are in "private/nordic_keyboard/sdk8.0.0" which is not our code. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ie5210b98e1096c22d0e9284c101a42820bd3d79d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321549 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* TCPM: Move dfp_discover_modes into usb_pd_policy.cAbe Levkoy2020-07-251-9/+0
| | | | | | | | | | | | | It is now only used by TCPMv1. BUG=b:152417597 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ifcb7023afabea16486d90336994c6cd93a96d69b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317903 Reviewed-by: Diana Z <dzigterman@chromium.org>
* chip/it8320, it81202: Implement fast role swap functionRuibin Chang2020-07-231-0/+7
| | | | | | | | | | | | | | | | | | Implement fast role swap function from initial SNK to new SRC for chip it8320 and it81202. BUG=none BRANCH=none TEST=1.When we detect FRS cc low signal, we can output properly GPIO signal. 2.FRS false-positives test: PD traffic(ex.power nego, data and power swap, soft and hard reset) on the CC line after FRS is enabled. Change-Id: I3a7bc6a684e57fb19e50c41305751b2fca1ffe2d Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1786462 Reviewed-by: Diana Z <dzigterman@chromium.org>
* USB PD: Move board FRS configuration out of TCPCIEric Herrmann2020-07-171-0/+9
| | | | | | | | | | | | | | | | | Board FRS configuration is more board-specific than TCPC-specific. Move the board FRS configuration from TCPCI to usb_common. Implementing the board-level frs configuration is optional for each project. BUG=b:148144711 TEST=Can build volteer image with CONFIG_USB_PD_TCPC set BRANCH=none Change-Id: I43d13ec0b23f71273807f58db35e7dd333089efa Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290838 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1, TCPMv2: add pd event for receiving hard resetRuibin Chang2020-07-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When we receive hard reset message, we call pd_execute_hard_reset() and set task to hard reset state, but the waked up pd_task() may have chance setting to other state. So I add a pd event for receiving hard reset, then waked up pd_task() set the state to hard reset. TCPMv1: When we are in SNK_HRAD_RESET_RECOVER state, we enable rx. At this time If port partner sends source capability, HW auto responds GoodCRC, but in SNK_HRAD_RESET_RECOVER state the handle_data_request() can't process source capability then break the case. So partner sender response timeout and tx hard reset. So I move the enable_rx() to SNK_DISCOVERY state that we are able to handle source capability. BRANCH=None BUG=b:159394180 TEST=On board reef_it8320, and it81202_pdevb: 1.TCPMv1: Rx Hard reset -> done Vbus cycle, and keep cc connection, When we're SRC and SNK. 2.TCPMv2: Rx Hard reset -> done Vbus cycle, and keep cc connection, When we're SRC and SNK. Change-Id: Ia4944883f4ee0420183cb4d1ec62743c49386ea3 Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1389992 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* tcpmv1: Debounce low power mode exitKeith Short2020-07-141-2/+3
| | | | | | | | | | | | | | | | | | Adds a 25ms delay when exiting low power mode. Some TCPCs are slow to update the CC_STATUS register when exiting low power mode when a non-PD charger is connected. BUG=b:155364505 BRANCH=none TEST=make buildall TEST=connect 15W non-PD charger to Volteer C1 port running TCPMv1. Verify charging starts. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ia9579029caa0db0886bcc1a49e8b194173b8ca7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2267681 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* tcpmv2: perform partner reset on startup, remove BBRAMJett Rink2020-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | - Reset the port partner by applying CC Open on both CC lines - Reuse the existing error recovery state to apply CC values - Extend error recovery timer to 240 msec to account for us being able to source Vconn - Since we always reset on startup, we don't need to store previous contracts in BBRAM. BRANCH=none BUG=b:159495742,b:158802939 TEST=see that we apply CC Open upon reset TEST=see that we do not get a fault on Trembyle went setting CC open TEST=apple 3-1 dongle with display port and power on Puff will come back with power and display after a `reboot` EC command (which will trigger the ErrorRecovery brownout path) Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Iaac09d62e4a31557492cebb354d3a34371c1e9bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2271002 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* usbc: ensure we are suspending USB-C ports on shutdownJett Rink2020-07-091-10/+10
| | | | | | | | | | | | | | | | | | | | | | After CL:2208221, the check for the PD_CMD task no longer trigger, so we end up not calling suspend on our TCPC ports. We want to continue to suspend, which will apply CC open in TCPMv2 for a cooperative shutdown Also, correct override keyword usage for board_get_usb_pd_port_count since I had to touch those definitions to make IS_ENABLE work BRANCH=none BUG=b:160243292 TEST=See that software sync reboot, applies CC open (and browns out system) Change-Id: I00bf08c7d347441d77834e2c5122a09ca2316280 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276318 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usb_pd: Move 'is_vdo_present()' and 'is_usb4_vdo()' to TCPMv1Ayushee2020-07-061-21/+0
| | | | | | | | | | | | BUG=b:156749387 BRANCH=None TEST=make buildall -j Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I8ecffd3084de472ec3d145c3ff69df1ca2d89a56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2278562 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpm: allow returning a status from set_frs_enablePeter Marheine2020-07-011-1/+2
| | | | | | | | | | | | | | | | | | | | | The old declaration with void is incompatible with the use of tcpci_tcpc_fast_role_swap_enable in the one driver that currently implements that function, causing build failure when CONFIG_USB_PC_FRS_TCPC is enabled and using the nct38xx TCPC driver. Because the underlying function may fail, walk up the stack and make all users capable of failure as well (however the top level user currently ignores the result). BUG=b:146393213 BRANCH=None TEST=make buildall Change-Id: Ib8cabf4a435731ed804a3cc4696dfea97eef3c98 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276124 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usb_pd: Remove pd_cable dependent Thunderbolt code from common codeAyushee2020-06-261-55/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Separated the common functions needed to check for port/cable's Thunderbolt mode compatibility back into TCPMv1. 2. Refactored the common Thunderbolt mode functions using pd_cable structure for mode information by adding a. Generic function that returns the Discover Mode response of specified SVID. b. Thunderbolt specific functiion that returns Discover Mode response of Intel SVID. 3. Removed the redundant pd_cable structure from DRP state machine policy engine. BUG=b:158294748 b:150611251 BRANCH=None TEST=1. Able to enter into Thunderbolt mode on TCPMv1 Change-Id: I30c8f1a007228408e08520502db00601ca3a2521 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2249020 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* usb_pd: Remove pd_cable usage from common codeAyushee2020-06-251-30/+11
| | | | | | | | | | | | | | | | | | | Previously, the Discovery Identity SOP' response for TCPMv1/2 was being stored in pd_discovery and in pd_cable. This commit removes the storage of Discover Identity SOP' response from the pd_cable structure. BUG=b:158294748 b:159504972 BRANCH=None TEST=1. Able to get the cable characteristics 2. Able to enter into Thunderbolt mode on TCPMv1 3. Able to enter into USB4 mode on TCPMv1 Change-Id: I1e5112f9aa158c41abb6226a3819f1612ed906bd Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2247211 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMV2: Add support for sending Alert MessagesSam Hurst2020-06-251-0/+10
| | | | | | | | | | | | | Add support for sending Alert OVC and OVP messages BRANCH=none BUG=b:117854867 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ia436c8869880897ea9af0c2c2b0d6e9288831a8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2229285 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Add pathway to enable FRS from PPC driverEric Herrmann2020-06-181-0/+8
| | | | | | | | | | | | | | | Some PPCs have integrated CC line detection to trigger FRS faster, but this needs to be enabled from the USBC policy engine only after the sink capabilities have been exchanged. BUG=b:148144711 TEST=make buildall BRANCH=none Change-Id: Iaa64f64845c5ffdd32fa66a3eb6f6251abb7c157 Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2056493 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Support mode entry for SOP' and SOP''Abe Levkoy2020-06-111-10/+36
| | | | | | | | | | | | | | | | | | | | | | Add a transmit type parameter to functions involved in mode entry; also add such a parameter to various functions calling those functions. For DisplayPort-specific definitions or calls, specify SOP; we do not currently support DisplayPort mode for cable plugs. For TCPMv1-specific code, specify SOP. TCPMv1 generally assumes that the discovery/mode structures are 1-dimensional, as they were previously, and changing that is outside the scope of this CL. BUG=b:155890173 TEST=Enter DP mode on Volteer with TCPMv2 TEST=Enter DP mode on Volteer with TCPMv1 TEST=Enter TBT mode on Volteer with TCPMV1 BRANCH=none Change-Id: I8afc75b3f3be8939c4645058ac4a31f24c88fb9e Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2229279 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* tcpmv2: cache analog and collision Rp in CLDenis Brockus2020-06-111-0/+33
| | | | | | | | | | | | | | | | Adding update_cc mechanism to keep correct Rp set BUG=b:158291622 BRANCH=none TEST=check Rp value over attach, hard reset and pr-swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I369c71e637cbb6a8fc37b434194ce39cc9bf5417 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2232830 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* dp-hpd: abstract HPD gpio pinEric Yilun Lin2020-06-101-0/+16
| | | | | | | | | | | | | | | The HPD GPIO active level and naming may vary across boards. This CL abstract the layer for board customization by adding config CONFIG_USB_PD_DP_HPD_GPIO_CUSTOM. BRANCH=master BUG=b:154565980, b:150341271 TEST=ensure HPD works on asurada. Change-Id: I237c10722f13e5f31144e142f63e2694a23fe899 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2167128 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* TCPMv2: Separate DPM and DP from PEAbe Levkoy2020-06-101-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | Create separate modules representing DisplayPort (which decides whether and how we can set up the DP alt mode) and the Device Policy Manager (which decides whether we should). The end goal is to have essentially all code with DP-specific decisions or information in the DP module and all code with DPM-specific decisions or information in the DPM module. This will allow the PE to map as directly as practical to its behaviors defined in the PD spec. Essentially detach PE_DO_PORT_DISCOVERY from the rest of the PE state machine in preparation for deleting it. This change paves the way for 1) Allowing the AP to drive mode entry and 2) Allowing new alt modes to be supported via largely self-contained modules. BUG=b:155890173 TEST=Attach DP dongle; observe discovery and DP setup via Twinkie BRANCH=none Change-Id: Ie63a2e62d1ac6178722477dc53244898a04ef92f Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2203842 Reviewed-by: Diana Z <dzigterman@chromium.org>
* usb_pd: Cleanup: Cable flagsAyushee2020-06-091-34/+7
| | | | | | | | | | | | | | | | | | | | | | Instead of using CABLE_FLAGS_SOP_PRIME_ENABLE and CABLE_FLAGS_SOP_PRIME_PRIME_ENABLE cable flags, add the type of message to be transmitted directly in the message header. BUG=b:148528713 BRANCH=none TEST=1. make buildall -j 2. Able to enter DP mode with Type-C dock and Type-C to DP connector. 3. Able to enter Thunderbolt-Compatible mode with thunderbolt dock with both Active and Passive cables. 4. Able to Enter USB4 mode with USB4 device with thunderbolt Gen2 cable. Change-Id: Ib0cac818200e7ab8f73cace85ffee65203019709 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2159592 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* usb_pd: Move USB4 functions to common fileAyushee2020-06-051-0/+10
| | | | | | | | | | | | | | | | | Added a check for CONFIG_USB_PD_ALT_MODE_DFP in pd_send_enter_usb() and added separate configs for USB4 DRD and USB3.2 DRD BUG=b:148528713 BRANCH=none TEST=Able to enter USB4 mode with following passive cables - a. Rev 3 USB3.2 Gen 1, USB3.2 Gen 2 and USB4 Gen 3 b. Rev 2 USB3.1 Gen1/Gen2 Change-Id: I80c9b7569429bc54db08d78b5a6eee16780d6fe1 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051631 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* usb_pd: USB4: Limit the cable speedAyushee2020-06-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | | Added 'get_usb4_cable_speed()' to return USB4 speed as per the port, the speed supported by DUT's port or cable speed whichever is lowest. Added configuring the cable speed in cros_ec_usb_pd_control according to the mux setting. Removed 'set_max_usb4_cable_speed()' to retain cable's actual VDO response. BUG=b:157671582 BRANCH=none TEST=1. Able to set USB4/USB3.2 Gen2 cable speed when DFP isn't gen 3 capable. 2. Able to limit cable speed according to the port, if the cable speed is higher. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I21bba7e5a2aa8ca54f304ef8418320f319f020b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2220826 Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: TBT: Refactor limiting the cable speedAyushee2020-06-051-8/+9
| | | | | | | | | | | | | | | | | | | | Refactored 'get_tbt_cable_speed()' to return thunderbolt-compatible speed as per the speed supported by DUT's port or cable speed whichever is lowest. Also removed 'usb_pd_limit_cable_speed()' to retain cables's actual VDO response. BUG=b:157671582 BRANCH=none TEST=Able to limit thunderbolt cable speed, if the cable speed is higher than the speed supported by DUT's port. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I77d3efddb425daa7bd12e9ed21be7088074285bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2227088 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* BB retimer: Correct setting USB4 cable speedAyushee2020-05-291-0/+23
| | | | | | | | | | | | | | | | For DFP, TBT/USB4_cable_speed_support is set according to a. Discover mode SOP' response for Thunderbolt-compat mode and b. Discover ID SOP' response for USB4 mode. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=make buildall -j Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Ic031489878dab701177936ea8e2f50d434dba25b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2152287 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/TCPMv2: Add PD version commandSam Hurst2020-05-271-0/+12
| | | | | | | | | | | | | | | | | | Add PD version command so FAFT_PD can query the stack to determine which suite of tests to run. BUG=b:151483159 BRANCH=none TEST=make -j buildall Manual tests: Built both stack and verified command in console For TCPMv1: pd version > 1 For TCPMv2: pd version > 2 Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ice032f44afd19bb4f08c30be561a7c5fa31c2211 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2213123 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* BB retimer: For USB/DP/USB4, set 'Re-timer_Driver' bit based on SOP' VDO2Ayushee2020-05-271-0/+9
| | | | | | | | | | | | | | | For DFP, if the mux state is either USB/DP/USB4, then the re-timer_Driver bit is set according to the SOP' VDO2 response. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=Able to set Re-timer_Driver bit with a Gen3 Active cable Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Idb1134600617161137c6f500790b6c0c3b836200 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2152286 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Set pd msg revision to PD2.0 when REV30 is not enabledSam Hurst2020-05-211-3/+3
| | | | | | | | | | | | | | | | | Correctly set pd message revision to PD2.0 when CONFIG_USB_PD_REV30 is not defined. BUG=b:155879504 BRANCH=none TEST=make -j buildall Manual tests: Using TotalPhase, I verified that the msg rev was correct. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: If7dbc601b3a13d927d09652ffa164bf22f978f96 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2212678 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* BB retimer: Add 'USB3_Speed' bitAyushee2020-05-211-0/+11
| | | | | | | | | | | | | | | | | USB3_Speed bit is set to 1 if USB3 Gen1/Gen2 is supported. Hence, added functions to return cable rev 2.0 speed and cable rev 3.0 speed. Ref: Burnside Bridge spec Table 13: Connection state register BUG=b:152544514 BRANCH=None TEST=Tested on volteer, with a Type-C dock, able to get USB3 Gen1/2 speed by checking "lsusb -t" on CPU console. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Idd7d7de3446e82ac81025cda36ee8a7e1f274138 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2139279 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>