summaryrefslogtreecommitdiff
path: root/common/usbc/usb_pe_drp_sm.c
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: Add jittery holdoff timer before sending initial messages in ↵Sam Hurst2019-12-141-124/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PE_SNK/SRC_RDY In order to prevent collisions for PD 2.0 mode, we added a jittery holdoff timer which would pseudorandomly wait a time period before initiating messages of our own from the SNK/SRC ready states BUG=chromium:1022218 BRANCH=none TEST=make -j buildall manual tests: Connected Apple 2019 AV Multiport dock with Apple 2019 61W PSU Connected Kensington SD2000P dock Observed no packet processing collisions between port partners Using total phase, verified that as a source, a PD2.0 message was not sent before a 400+ ms delay while in the SRC_READY state. And as a sink, a PD2.0 message was not sent before 200+ ms delay while in the SNK_READY state. Apple 2019 A2119 HBR3 HDMI dongle Nektek 90w USB-C charger This collides with 0xf * 12ms Connect and observe for SRC_CAP interrupting VDM probes. Change-Id: I338b891baae754c2eaac106e33bc48bc12865d27 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1907558 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_pd: Rename "Externally powered" to "Unconstrained Power"Benson Leung2019-12-121-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was changed in PD 2.0 years ago (via ECN authored by our own David Schneider), but our codebase still refers to BIT 27 of the Fixed PDO as "Externally powered" instead of "Unconstrained Power". This will search and replace all instances of "Externally powered" when it refers to BIT 27, as well as function names, other internal representations of that property, strings, and comments. seds: s/PD_FLAGS_PARTNER_EXTPOWER/PD_FLAGS_PARTNER_UNCONSTR/g s/partner_extpower/partner_unconstrained/g s/externally powered/unconstrained/g Some others too. Signed-off-by: Benson Leung <bleung@chromium.org> BUG=chromium:1030990 TEST=Codebase builds clean. No functional change, except for the property shows up in ectool as "Unconstrained power" now. Change-Id: I5ececa03f29eb31057be3d0ad5311117093bc6da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1956147 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Benson Leung <bleung@google.com> Tested-by: Benson Leung <bleung@google.com>
* TCPMv2: Fixed PR swap request from charge managerSam Hurst2019-12-101-2/+7
| | | | | | | | | | | | | | | | | | | The PR swap request from the charge manager was locking up the TC state machine. The pd_request_power_swap function was changed so that it sends the request to the policy engine instead of initiating it directly. BUG=chromium:1027247 BRANCH=none TEST=make -j buildall Tested with apple dongle "A2119 2019 HBR3" known to reproduce this problem. Change-Id: Ic59036056434ed525a839cd781cff93e3b5bfc53 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1928795 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Fixed the pointer problem with decoding SRC_CAP PDOSam Hurst2019-12-091-1/+1
| | | | | | | | | | | | | | | | | | A pointer to the PDO was getting incorrectly incremented, causing an unknown value to be sent to the pe_update_pdo_flags function. BUG=chromium:1027252 BRANCH=none TEST=make -j buildall Plugged in an apple dock and verified that the PDO was being correctly decoded. Change-Id: I06f11aad0043f63ef43f75beccf48241f739ae46 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1928794 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* TCPMv2: Handle unexpected msgs received during Port DiscoverySam Hurst2019-12-091-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During a port discovery, unexpected messages such as SRC_CAPs and Not_Supported are handled by the Src.Attached or Snk.Attached state and the port discovery process is terminated. BUG=chromium:1027252 BRANCH=none TEST=make -j buildall Manual Test: Used an Anker charger to verify that Not Supported messages are handle correctly during a Port Discovery. Total Phase output: Source:DFP, Source_Cap Sink:UFP, GoodCRC Sink:UFP, Request Source:DFP, GoodCRC Source:DFP, Accept Sink:UFP, GoodCRC Source:DFP, PS_RDY Sink:UFP, GoodCRC Sink:UFP, VDM:DiscIdentity Source:DFP, GoodCRC Source:DFP, Not_Supported Sink:UFP, GoodCRC Change-Id: I48db149c0c59affe6aad49b8b1bcfb6dc3656142 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1928793 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Don't use SinkTXOK/NG in middle of partner-initiated PD3.0 AMSSam Hurst2019-12-071-25/+35
| | | | | | | | | | | | | | | | | | Don't send ACCEPT message (to PR_SWAP AMS initiated by partner) after lowering Rp to SnkTXNG. BUG=chromium:1023064 BRANCH=none TEST=make -j buildall manual tests: Connected several docks with charger and verified PR_SWAP. Also works with the CM dock that triggered this bug. Change-Id: Iab5474174cf8313c24bae8a7869565005504af25 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1912161 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Keep message transmission and reception synchronizedSam Hurst2019-11-241-30/+86
| | | | | | | | | | | | | | | | | | | | | If a message is expected after a transmit, hold off on checking for that until the sender response timer is set. BUG=chromium:1022715 BRANCH=none TEST=make -j buildall manual tests: Connect StarTech CDP2DP USB-C to DP dongle Observe REQUEST send less than 1ms after SRC_CAP Look for ACCEPT message sent by PE and PD Change-Id: I1d155ead698ac39172c604cc3f656631565855d5 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1907807 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: PD: Separately track each SOP and SOP' and SOP''Sam Hurst2019-11-241-60/+147
| | | | | | | | | | | | | | | | | | Tracked PD header spec. version for each port partner type. BUG=chromium:1023025 BRANCH=none TEST=make -j buildall Manual Testing: Connected PD2.0 source charger and made sure we talked PD2.0 Connected PD3.0 source charger and made sure we talked PD3.0 Connected apple 2019 PD2.0 dock with charger and made sure we downgraded from PD3.0 to PD2.0 Change-Id: I3b49d9630acf6c19101ac71334445890c78c4077 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1907430 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: ServoV4 is not recognized appropriatelySam Hurst2019-11-221-2/+14
| | | | | | | | | | | | | | | | | | Configure the port as a SNK with PD in DebugAccessory.SNK state BUG=chromium:1020752 BRANCH=none TEST=make -j buildall Manual Test: 1: Connect Servo v4 with NeckTek charger pluged in DUT power port The DUT negotiates to 20V, and starts charging. Change-Id: Id44d566024b5016965f996435d11befdc1c53e98 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1906993 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpmv2: Make battery handling optional.Andrew McRae2019-11-211-0/+8
| | | | | | | | | | | | | | | | Some systems like puff do not have a battery, so conditionally compile the battery handling portion of the Type C PD module. BRANCH=none BUG=b:144390300 TEST=EC buildall runtests Change-Id: I72fc41d64820d450161273902eaf99476bf0dfce Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1916763 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org>
* Add a board specific helper to return USB PD port countKarthikeyan Ramasubramanian2019-11-091-3/+6
| | | | | | | | | | | | | | | | | | | | | Certain SKUs of certain boards have less number of USB PD ports than configured in CONFIG_USB_PD_PORT_MAX_COUNT. Hence define an overrideable board specific helper to return the number of USB PD ports. This helps to avoid initiating a PD firmware update in SKUs where there are less number of USB PD ports. Also update charge manager to ensure that absent/ invalid PD ports are skipped during port initialization and management. BUG=b:140816510, b:143196487 BRANCH=octopus TEST=make -j buildall; Boot to ChromeOS in bobba(2A + 2C config) and garg(2A + 1C + 1HDMI config). Change-Id: Ie345cef470ad878ec443ddf4797e5d17cfe1f61e Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879338 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org>
* pd: Clarify flag commentsDenis Brockus2019-11-081-22/+36
| | | | | | | | | | | BRANCH=none BUG=b:141563840 TEST=make -j buildall Change-Id: Iaff605f5d93ccce26aec4d9e33be78017c7b9231 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1906194 Reviewed-by: Jett Rink <jettrink@chromium.org>
* pd: Clear PE_FLAGS_PS_TRANSITION_TIMEOUTDenis Brockus2019-11-081-1/+1
| | | | | | | | | | | | | | | | The flag was being checked for being set and then if it was set it was being set again. The pattern everywhere in this situation is to clear the flag and not set it again. Looks like a typo that was not caught BUG=none BRANCH=none TEST=make buildall -j Change-Id: I18f52343e0583cd0eecc509b01337ab60804130d Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1906193 Reviewed-by: Jett Rink <jettrink@chromium.org>
* pd: Remove EMarker Cable ProbeSam Hurst2019-11-081-164/+17
| | | | | | | | | | | | | | | The current PD3.0 EMarker cable probe functionality is unstable. Remove and add back as a feature after the PD3.0 code base is stable. BRANCH=none BUG=b:144093713 TEST=make -j buildall Used total phase to verify that the cable was not probed. Change-Id: I2906a16c96faff9d8107ef19286acdbe60869180 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1904157 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: fix vbus discharge path for GPIOJett Rink2019-11-071-15/+24
| | | | | | | | | | | | | Code on Tot assumes that port count was the port to discharge instead of port parameter BRANCH=none BUG=none TEST=verified with unit test (in this CL) Change-Id: I17658a0c555f9cea56fa4ec1652e0faf62e3d6cc Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1896125
* pd: Comment all flagsSam Hurst2019-11-071-25/+38
| | | | | | | | | | | | | | | | All of the flags in all layer needs comments of what the flags means and a potential usage. all TC_FLAGS_*, PR_FLAGS_* and PRL_FLAGS_* BRANCH=none BUG=b:141563840 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I520daa841a61e36a8a6b394e0f96b198b16ad561 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1904148 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org>
* Rename CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNTKarthikeyan Ramasubramanian2019-11-011-10/+10
| | | | | | | | | | | | | | | | | Certain SKUs of certain boards have lesser number of USB PD ports than defined by CONFIG_USB_PD_PORT_COUNT. Hence rename CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNT. BUG=b:140816510, b:143196487 BRANCH=octopus TEST=make -j buildall; Boot to ChromeOS Change-Id: I7c33b27150730a1a3b5813b7b4a72fd24ab73c6a Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879337 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* usbc: Get current DP pin mode and CC stateAyushee2019-11-011-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | To configure Intel virtual mux and burnside bridge retimer, current DP pin mode, cc state and the type of the cable is required. Hence, implemented a board level function that returns the current DP pin mode and added a function that returns the type of cable inaccordance to the cable vdo response. Also added a new version to USB_PD_CONTROL host command, to return the DP mode, cc_state and the cable type BUG=b:141971044 BRANCH=None TEST=Verifed with ectool usbpd command on CPU console, able to get correct CC state, pin mode and cable type Pin mode: USB:0x0 (No DP) DP cable:0x4 (Mode:C) USBC dock:0x8 (Mode:D) Change-Id: If87ae6b77e5fa2ceaa22319dfa2d2c802460edfa Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1835030 Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: fix an unit in log message.Pi-Hsun Shih2019-10-291-1/+1
| | | | | | | | | | | | | | From USB PD spec, the voltages encoded in PDO is in 50mV units, not 50V units. BUG=None TEST=None BRANCH=none Change-Id: I20ea308c954fc407b313dd3923ab0112b520108c Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1880777 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* pd3.0: change soft reset path for explicit contract or notDenis Brockus2019-10-221-5/+17
| | | | | | | | | | | | | | | | | | | | | Changes for PD 3.0 spec version 2.0 State machine for Source Port Soft Reset and Protocol Error, new section 8.3.3.4.1 changed entry requirements to go to state PE_SRC_Send_Soft_Reset and PE_SRC_Ready. State machine for Sink Port Soft Reset and Protocol Error, new section 8.3.3.4.2 changed entry requirements to go to state PE_SNK_Send_Soft_Reset and PE_SNK_Ready. BUG=b:141468157 BRANCH=none TEST=make buildall -j Change-Id: Ibda109fa15c0bcab34472498920bef06806e0880 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1863710 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: Add missing IS_ENABLED(CONFIG_CHARGE_MANAGER) checksEdward Hill2019-10-181-4/+3
| | | | | | | | | | | | | | | Remove the need for stubs of charge_manager_set_ceil() by adding a few missing IS_ENABLED(CONFIG_CHARGE_MANAGER) checks. BUG=none BRANCH=none TEST=buildall Change-Id: Ia70434b05107747eb773ae30ee1de5b4bd8cbcea Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1869401 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* pd: Add PE FRS unit test for new stackDenis Brockus2019-10-161-2/+27
| | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: I55453ddf1d1da0fdee902a33e14357716fb12c4a Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1859826 Reviewed-by: Jett Rink <jettrink@chromium.org>
* pd: fix timer issue on pe_prs_snk_src_source_on_runDenis Brockus2019-10-161-9/+8
| | | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: I12fbeb0a85d45bce8173c0c3831f663f5b618cc8 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1862621 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: make pe_init() staticEdward Hill2019-10-151-1/+1
| | | | | | | | | | | | | | pe_init() is called via pe_run(), so make it static. BRANCH=none BUG=none TEST=build Change-Id: I56928369e50a2022fc7e2aee2f68f09ebe7c06b6 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1850191 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: rename exe_state to run_stateEdward Hill2019-10-151-1/+1
| | | | | | | | | | | | | | | | | Just a simple rename. run_state() seems more readable to me, and "run" is used in many of the related functions and comments. exe_state used to be called sm_run_state_machine before the great refactoring of CL:1733744. BRANCH=none BUG=none TEST=build Change-Id: I5fe9e5b98042d7a5b9b9e9bde48ebecbda420458 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1848970 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: remove evt_timeout from struct type_cEdward Hill2019-10-151-7/+0
| | | | | | | | | | | | | | | | Simplify the pd_task loop timeout by making it a fixed 5 milliseconds. If there is nothing to do then it shouldn't take long to realize this. This allows removal of evt_timeout, tc_set_timeout, tc_get_timeout. BRANCH=none BUG=none TEST=usbc unit tests (make -j runhosttests) Change-Id: I067309b191e5118fbe9e89a92a650fa837fb75fa Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1857216 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: use future time for disabling timerJett Rink2019-10-141-112/+93
| | | | | | | | | | | | | | | | If we use -1 instead of 0 for disabling timers, then we don't need to check for the 0 value when evaluating the timer. BRANCH=none BUG=none TEST=builds Change-Id: Ie1e68579728d23d645d1f17f31210fc275c38e36 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837999 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usbc: fix pe_src_discovery return issueJett Rink2019-10-141-3/+5
| | | | | | | | | | | | | | | | We were returning early within pe_src_discovery state and not giving other conditions a chance to evaluate and transition states. BRANCH=none BUG=none TEST=builds Change-Id: If438479b5a8bf2a703760f84a85c48bc7db72507 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837998 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: go to hard reset after noResponseTimerJett Rink2019-10-141-3/+4
| | | | | | | | | | | | | | | | | We should transition to the hard reset state after the noResponseTimer expires without getting a single PD response from a port partner until we reach the hard reset count. BRANCH=none BUG=none TEST=builds Change-Id: Iaee53369dec863ed8220b9f4ffed5f252cf08c4d Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837997 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* pd: FRS enable/disable and interrupt handlingDenis Brockus2019-10-071-19/+189
| | | | | | | | | | | BUG=b:138599955 BRANCH=none TEST=make buildall -j Change-Id: I0c639aae18e8c2c2d1b457e2e209f8484a834f6b Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825507 Reviewed-by: Edward Hill <ecgh@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* pd: Add Fast role swap to the PE state machineDenis Brockus2019-09-231-30/+145
| | | | | | | | | | | | | | Optimized code to use PRS path when possible in FRS execution. Added super state for shared path to default PRS path for debug. Unit tests will be created after the state machine changes are completed. BUG=b:138599955 BRANCH=none TEST=make buildall -j Change-Id: Ic9098dba6b86f161df9e6636194476aac5ecba56 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1809385
* pd: pd_send_vdm function causes an assert when called from non pd taskSam Hurst2019-09-161-3/+0
| | | | | | | | | | | | | | | | pd_send_vdm is an API function that can be called from any task but it generates an assert if called outside the pd task. BUG=b:140939776 BRANCH=none TEST=manual Change-Id: Id5c61542ba3b6422fb08dc8de88694b120fb9043 Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1801854 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* pd: USB Power Delivery State Machine based on Revision 3.0 of the spec.Sam Hurst2019-09-101-0/+4883
Adds Power Delivery to the TypeC state machine as detailed in Revision 3.0, Version 1.2 of the specification. This CL passes the PD2.0 compliance tests and has been tested on several devices. Some areas such as handling Electronically Marked Cable information, creation of PIDs, and Host commands will be addressed in later CLs. BUG=b:130895206 BRANCH=none TEST=manual Port 0 on Hatch was used to run this CL, merged with PD functionality, on the PD2.0 Compliance tester. All tests pass except for a few physical layer tests. The test report has been added to the bug. Atlas was verified to work with Apple, Amazon, StarTech, MKDGO and several other generic docks. Atlas was verified to work with Google's and Apple's CTVPD. Signed-off-by: Sam Hurst <shurst@chromium.org> Change-Id: Ia5e1988b0d81ec4cf9a7175e273197bd5a0865e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1737899 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>