summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* usb_prl: new unit test with mocksPaul Fagerburg2020-06-235-0/+202
| | | | | | | | | | | | | | | | | Now that the old usb_prl unit test is under usb_prl_old, add a new unit test for usb_prl with mocks for the various subsystems that it will use. BUG=b:158608129 BRANCH=None TEST=`TEST_LIST_HOST="usb_prl_old usb_prl" make runhosttests` Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ie1bf9a4494cd933473caa4ceb594eddd97c277c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2252662 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* usb_pd_tcpc: Don't process tcpc_run() when port is not availablePatryk Duda2020-06-231-0/+4
| | | | | | | | | | | | | | | | | Function tcpc_run() is responsible for receiving, transmitting messages but also for sampling CC lines. Running this for inexistent ports doesn't make any sense. BUG=b:154602760 BRANCH=none TEST=make buildall -j Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I8fe11719e35a1c99f307ebb9d581c3531d79177a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250683 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Do not call ppc_init() on unavailable USB-C portsPatryk Duda2020-06-231-1/+2
| | | | | | | | | | | | | | | | | | Do not try to initialize PPC on USB-C ports which are not available in board BUG=b:154602760 BRANCH=none TEST=make buildall -j TEST=Flash casta board. Make sure that EC RW doesn't report PPC init failures on port 1 Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ifc931055f1e90b9dc4ae8593d6d8ffa9880ca3f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250682 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Do not initialize port which is not availablePatryk Duda2020-06-221-0/+9
| | | | | | | | | | | | | | | | If port doesn't exist there is no reason to initialize anything. Go directly to Disabled state and set flags to disable PE and PRL state machines too. BUG=b:154602760 BRANCH=none TEST=Flash casta. EC RW should report port 1 transition to Disabled state Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I4d90324842363a5b714ee2e2953edffb30c6009f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250680 Reviewed-by: Diana Z <dzigterman@chromium.org>
* Avoid deadlock when calling pd_set_suspend()Patryk Duda2020-06-221-0/+8
| | | | | | | | | | | | | | | | | | Calling pd_set_suspend() from PD task we are going to suspend results in deadlock, because pd_set_suspend() waits until it reaches Disabled state. This fix adds early return after setting appropriate flags when task we are going to disable is running task BUG=none BRANCH=none TEST=make buildall -j Change-Id: I295677908db8a24215b010e47dbb56e586bbb041 Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250679 Reviewed-by: Diana Z <dzigterman@chromium.org>
* common/charge_state_v2: Use CONFIG_USB_PD_PREFER_MV to guard functionsNicolas Boichat2020-06-221-1/+2
| | | | | | | | | | | | | | | | Guarding them for TEST_BUILD is not correct, as the functions may still be needed for board tests. Without this, make BOARD=kukui tests fails. BRANCH=none BUG=b:159571683 TEST=make BOARD=krane -j tests Change-Id: Ib1be0ac55c15e610ff6cd13d746442c5b0e645ad Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2256630 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* TCPMv2: Consolidate debug steady states into attached statesDiana Z2020-06-191-410/+99
| | | | | | | | | | | | | | | | | | | | | | | | | Nearly all of the behavior needed in the debug accessory steady states is also covered in Attached.SRC and Attached.SNK. Consolidate those states in order to save flash space and ensure we don't have untested code paths sitting around the TC (saves an average of 883 bytes of flash). This change is mostly functionally equivalent, except it: - removes super states from debug states so swap controls setting Rd/Rp - checks trySrc overrides when leaving attached.snk BRANCH=None BUG=b:158466320 TEST=on waddledoo, verify: -Suzy-Q connection goes into debug sink, sets bbram flag for debug -servo_v4 connection goes into debug source, sets bbram flag for debug -data role swap with v4 succeeds -power role swap with v4 succeeds Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I2ea135b186db23dc970d77b7753131193b6c7571 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244019 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Rename discovery flagsAbe Levkoy2020-06-191-20/+16
| | | | | | | | | | | | | | | | | | PE_FLAGS_DISCOVER_PORT_IDENTITY_DONE has been used to indicate that DisplayPort configuration is done for some time. PE_FLAGS_DISCOVER_PORT_CONTINUE is now only used to resume non-discovery VDM requests. Maybe the way they are used should change. For now, rename them to reflect their current use; this should make subsequent changes easier to understand. BUG=b:155890173,b:158813138 TEST=make buildall BRANCH=none Change-Id: Icbb6a44412b1b901ed160da58d4fbe016348bc2b Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250921 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Add pathway to enable FRS from PPC driverEric Herrmann2020-06-183-3/+30
| | | | | | | | | | | | | | | 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: Consolidate code in SOP' Discover IdentityAbe Levkoy2020-06-181-100/+61
| | | | | | | | | | | | | | | | Remove code from pe_vdm_identity_request_cbl_run that is common to all discovery VDM requests. Save 191 bytes of flash on average (volteer RO: 192 bytes; RW: 164). BUG=b:158572770 TEST=Observe SOP' identity discovery for 2 cables BRANCH=none Change-Id: Ib949c42bb1cf99a28aa8c187e9a627390338904b Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250542 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Consolidate code in SOP Discover IdentityAbe Levkoy2020-06-181-73/+32
| | | | | | | | | | | | | | | | Remove code from pe_init_port_vdm_identity_request_run that is common to all discovery VDM requests. Save 212 bytes of flash on average (volteer RO: 192; volteer RW: 168). BUG=b:158572770 TEST=Observe SOP identity discovery for various devices BRANCH=none Change-Id: Icdfb2dc29112c3a6aa4073c36820794bd80627ab Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2246277 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Don't reset power supply on entries of CC_RD and CC_OPENWai-Hong Tam2020-06-181-21/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The power supply is given on the entries of the states Attached.SNK and UnorientedDebugAccessory.SRC. The power supply is reset on the exits of the states Attached.SNK and UnorientedDebugAccessory.SRC. In the entries of the super states CC_RD and CC_OPEN, resetting the power supply is unnecessary. This causes a side effort that wakes AP up right after entering S3, since it is a power change event. For the case that VBUS is sourced before reboot, call the tc_src_power_off(port) on init. Also skips the check of attached source states in tc_src_power_off(). This change also replaces the pd_set_power_supply_ready(port) to the tc_src_power_on(port). It helps readability as it is paired to the tc_src_power_off(port). BRANCH=None BUG=b:158701496 TEST=Tested sinking power from a 20V charger, sourcing power to a Type-C hub. Made AP transition to S3 and S5 and back for the above cases. Also tested power role swap. Change-Id: I97364aa7145f3c139aa5e99f916226bd3a05370f Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2243751 Reviewed-by: Jett Rink <jettrink@chromium.org>
* PB: Clear AP_IDLE for recovery bootDaisuke Nojiri2020-06-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, if CONFIG_POWER_BUTTON_INIT_IDLE is defined, EC_RESET_FLAG_AP_IDLE is set when the system enters S5. This is for restoring the power state after power loss or blackout. This can cause a recovery boot to be blocked depending on the timing that the hardware resets the EC. This patch makes EC clear AP_IDLE flag when a manual recovery request is detected so that AP can be unconditionally booted in the recovery mode. BUG=b:158802935, b:37536389 BRANCH=none TEST=Shutdown DUT. Press power + recovery. DUT enters recovery mode. TEST=Shutdown DUT. Replug AC. DUT stays off. TEST=Boot DUT to OS. Replug AC. DUT boots back to OS. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Iec1fd51cb0fa49e088f3b2489c5e94c8a4777a9b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242664 Reviewed-by: Andrew McRae <amcrae@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* TCPMv2: Consolidate common code for VDM statesAbe Levkoy2020-06-171-102/+92
| | | | | | | | | | | | | | | | | Move common run code for VDM states to pe_discovery_vdm_request_run_common. Reduces flash size by an average of 337 bytes. volteer RO reduced by 320 bytes. volteer RW reduced by 304 bytes. BUG=b:158572770 TEST=Normal discovery traffic on Volteer, observed via Twinkie BRANCH=none Change-Id: I3082b9a81983e406f5f98d4c0e0f27ee66dce14e Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2248250 Reviewed-by: Diana Z <dzigterman@chromium.org>
* usb_pd: TCPMv1: Enable VCONN swap at explicit contractAyushee2020-06-161-18/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to Section 2.6.2 of both USB-PD Spec Revision 2.0, Version 1.3 & USB-PD Spec Revision 3.0, Version 2.0, at explicit contract, The Sink can initiate or receive a request for an exchange of VCONN Source and The Sink when it is the VCONN Source can communicate with a Cable Plug using SOP’ or SOP’’ Communication. PD_FLAGS_CHECK_VCONN_STATE flag enables the DUT to request for a VCONN swap at explicit contract. Earlier, when UFP requested for a power role swap, PD_FLAGS_CHECK_VCONN_STATE flag wasn't being enabled and hence, DUT was not entering Thunderbolt/USB4 alternate mode. Enabling the PD_FLAGS_CHECK_VCONN_STATE flag in PD_STATE_SNK_REQUESTED and in PD_STATE_SRC_POWERED allows DUT to request for VCONN swap at explicit contract. BUG=b:158455025 BRANCH=None TEST=Able to enter into Thunderbolt/USB4 when UFP requests for a power role swap. Change-Id: I68f2e2de3186ea367ace497b47930e30976c9e6b Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244022 Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* TCPMv2: Notify transmit engines of incoming messages more oftenDiana Z2020-06-161-12/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | By spec, we should be running PRL_TX discard on every incoming message, and also running TCH_Message_Received when incoming messages come during TCH runs. However, there are some tricky points following spec closely here since our systems use TCPCs, which can cause message receipt and transmission confirmation to often appear simultaneous. This change discards as often as we can without disrupting incoming transmissions. BRANCH=None BUG=b:155229288,b:158248741,b:158613480 TEST=on waddledoo, confirm: - moshi no longer gets stuck replying to DR swap - PRL_Tx discards when incoming message comes from Starteck dock No regressions running PD 3.0 or PD 2.0 with: - PD 2.0 charger (tested Apple 87W) - PD 2.0 dual role partners (tested Apple 3-in-1, Acer dock) - PD 3.0 charger (tested 45W Chicony) - PD 3.0 dual role partners (tested Starteck TBT dock, Moshi, HooToo) Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iec56635755b0d5dbaf9de80b29c3d81c34689e68 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2241178 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tc_acc_drp_trysrc: Fix charge behavior with servo_v4Sue2020-06-161-0/+3
| | | | | | | | | | | | | | | | | Can not charge after re-plugging adapter in servo_v4. Check EC log and find out that it didn't disable AutoDischargeDisconnect before tcpci handle fault detected while exiting UnorientedDbg.SRC. BUG=b:157402568 BRANCH=none TEST=can charge after re-plug adapter in servo_v4 on Ezkinil Change-Id: I5c3f95d1327080fdedf996331aef1048d020dd56 Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2245576 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Use correct init function after exit.Andrew McRae2020-06-161-1/+1
| | | | | | | | | | | | | | | | | All of the previously discovered state must be cleared after an EXIT_MODE command is sent and acked. Otherwise there will be an attempt to re-enter the mode. BUG=b:158813138 TEST=Confirm type-C monitor works. BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: Ib01018521e11b7b32d04fff580da9089b68cdabf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2245586 Reviewed-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org>
* TCPMv2: Comment the init order of PPC chipsWai-Hong Tam2020-06-161-1/+9
| | | | | | | | | | | | | | | | Copy the comment from TCPMv1 to explain the init order of PPC chips. As the tc_state_init() also sets the PPC power path, this comment helps people not mis-think it is a use-before-init problem. BRANCH=None BUG=None TEST=Built a board successfully. Change-Id: I94565ec7863de96756d46858628ae25bd9d31669 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2243770 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Check for mode discovery complete before switchingAndrew McRae2020-06-161-1/+8
| | | | | | | | | | | | | | | | | | | | If port discovery is run multiple times, because of power state changes to the AP, DP alt modes are not detected because dpm_attempt_mode_entry is run after discovery is initialised, but before discovery completes, and so no modes are detected, and no attempt is made thereafter. Also correct an unsigned compare against 0. BUG=b:158813138 TEST=Confirm that type-C monitors now work BRANCH=none Change-Id: Idef39ad97d6af2952474e8edcebd409f8324fa80 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2245580 Reviewed-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org>
* TCPMv2: Fix the sending of CMD_EXIT_MODEAndrew McRae2020-06-162-1/+13
| | | | | | | | | | | | | | | | | Fix the request to send CMD_EXIT_MODE, which needs to set the right state in order for the message to be sent. Also handle the receipt of an ACK for CMD_EXIT_MODE. BUG=b:158813138 TEST=Confirm that DP mode is exited. BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: Id9b58616771e729d8ae6543f973669be7649dc45 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2245584 Reviewed-by: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org>
* common: online_calibration: Add support for magnetometerYuval Peress2020-06-142-9/+38
| | | | | | | | | | | | Add support for magnetometers in online calibration. BRANCH=None BUG=b:138303797,chromium:1023858 TEST=Added new unit test Change-Id: I3a6dafb2f5fab9b11ac8bd3b53ae4976002d18cd Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2095519
* system: Add system_is_manual_recovery APIDaisuke Nojiri2020-06-133-14/+9
| | | | | | | | | | | | | | | | This patch moves is_manual_recovery from common/vboot to common/system.c to make it available as a common API. There is no functionality change. BUG=none BRANCH=none TEST=EFS2 detects manual recovery. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I3e6acd979feb78ff69b78780f1095fee855b4945 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242663 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* PB: Clear AP_IDLE for EC_REBOOT_HIBERNATE_CLEAR_AP_OFFDaisuke Nojiri2020-06-131-2/+2
| | | | | | | | | | | | | | | | This patch fixes the EC_REBOOT_HIBERNATE_CLEAR_AP_OFF command to match the change made by CL:2213730. There is no functionality change. BUG=b:37536389 BRANCH=none TEST=Verify ectool hibernate-clear-ap-off works. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I70ec3a38b0ceaca8a79c6e2c6df127fb145496e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242662 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* PB: Make CONFIG_POWER_BUTTON_INIT_IDLE commonDaisuke Nojiri2020-06-131-0/+31
| | | | | | | | | | | | | | | | | Currently CONFIG_POWER_BUTTON_INIT_IDLE is available only for NPCX chips. This patch moves the code to common/power_button.c. There is no functionality change. BUG=b:37536389 BRANCH=none TEST=Verify no functionality change on Puff. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib4b1182900acea21e5210a2f9a699da18fe55611 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242661 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* tc_drp_acc_trysrc: Set ICL after HardReset by SNKAseda Aboagye2020-06-121-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we send a HardReset to a non-PD port partner, there was an issue where we were not setting the correct Type-C input current limit. This was because the Type-C current limits were only advertised upon entry to the Attached.SNK or DebugAccessory.SNK states. When a sink initiated HardReset occurs, we would clear out our available charge leaving the only suppliers to update being VBUS. This would cause the DUT to set an input current limit of just 500mA even if the source advertises more. This commit fixes this issue by notifying charge manager of the Type-C current advertisements following a sink initiated HardReset. BUG=b:158849098 BRANCH=hatch? TEST=Build and flash waddledoo, plug in a non-PD charger, verify that the input current limit is set correctly to the Type-C resistor advertisement. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Ie2c39ffd55dcda52931c19a0ccc57567c488b1cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2243320 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* extpower: Add helper function extpower_handle_updateFurquan Shaikh2020-06-123-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds a helper function extpower_handle_update() that performs all the necessary actions that need to be done on external power state change: 1. Call hook_notify with AC_CHANGE 2. Update memmap_batt_flags to update EC_BATT_FLAG_AC_PRESENT 3. Set host event for EC_HOST_EVENT_AC_CONNECTED or EC_HOST_EVENT_AC_DISCONNECTED. Step#2 above is important because it ensures that the memory map flag is correctly updated when host reads it. Before this change, it was observed that EC_BATT_FLAG_AC_PRESENT is updated only when static/dynamic battery information gets updated. This could result in host reading the wrong AC state if battery information did not update before host acts on the host event bit getting set for AC connect/disconnect. BUG=b:157752693 BRANCH=None TEST=Verified on trembyle that EC ASL routines read the correct state of AC present flag on receiving host event. Signed-off-by: Furquan Shaikh <furquan@google.com> Change-Id: I077de1135320654f571e5cf87ced6f08cbf23876 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242353 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Auto-Submit: Furquan Shaikh <furquan@chromium.org>
* TCPMv2 PE: Fix incorrect response to Not SupportedAbe Levkoy2020-06-111-1/+1
| | | | | | | | | | | | | | | Mark modes discovery for an SVID as failed in response to a Not Supported response from a partner. Don't mark SVIDs discovery (which already succeeded) as failed. BUG=none TEST=make buildall BRANCH=none Change-Id: Id218a9108acf2adae8d4c932958ba9b2b299f3eb Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2238537 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2 PE: Remove partner_type fieldAbe Levkoy2020-06-111-9/+8
| | | | | | | | | | | | | It is redundant with tx_type and essentially unused at this point. BUG=b:158572770 TEST=make buildall BRANCH=none Change-Id: I1818acd93dacf14b657003209256010d5477c76f Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2238536 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2 PE: Remove PE_DO_PORT_DISCOVERYAbe Levkoy2020-06-111-156/+0
| | | | | | | | | | | | | | | | | | Remove state, functions, and fields. Previous changes removed usage of this state, so this is a non-functional change. BUG=b:158572770 BUG=b:155890183 BUG=b:155890456 BUG=b:155891305 BUG=b:152419850 TEST=make buildall BRANCH=none Change-Id: I6db07fb8b77126f8c214d07f899cf510fca8aa8a Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2238535 Reviewed-by: Diana Z <dzigterman@chromium.org>
* pe_vdm_request_run: Refactor NAK/BUSY handlingAbe Levkoy2020-06-111-8/+4
| | | | | | | | | | | | | Eliminate a redundant layer of checks. BUG=none TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Iae5da3a6bb5efddafab03d752e7079a67543cf46 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2234803 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Support mode entry for SOP' and SOP''Abe Levkoy2020-06-1110-100/+168
| | | | | | | | | | | | | | | | | | | | | | 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>
* throttle_ap: Turn on fans during PROCHOT eventsKeith Short2020-06-111-2/+11
| | | | | | | | | | | | | | | | | For platforms the monitor the PROCHOT signal as an input to the EC, turn on the fans at 100% duty cycle while PROCHOT is active. BUG=b:157916121 BRANCH=none TEST=make buildall TEST=On Volteer, force EC_PROCHOT_IN signal high, verify fan turns on. Verify fan reverts to automatic mode once PROCHOT clears. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Iba24daef4211d4b0d51833a569b78a9e40c71271 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2237917 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* system: Clear AP_IDLE when waking up from hibernation by ACDaisuke Nojiri2020-06-111-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, AP_IDLE is set when EC is left idle in G3. This makes the AP stay off after EC wakes up from hibernation (for any wake-up source). This makes a board require another power button press to boot the system from hibernation. This change makes RO clear AP_IDLE unless AC is present. When AC is present, EC doesn't hibernate. So, AC presence infers the EC woke up from hibernation by AC. That is, if the system wakes up by a power button press, AP_IDLE is cleared and AP will be turned on (unless it's overwritten by AP_OFF). Tested as follows on Trembyle: 1. Put DUT in hibernation. 2. Wake up DUT and observe: a. When waking up by power button, AP is turned on. b. When waking up by lid open, AP is turned on. c. When waking up by AC, AP is left idle. BUG=b:157077589, chromium:1073960 BRANCH=none TEST=See above. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ie5020bbe50ad489f4e3010820681cc57ff51b941 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2236589
* tcpmv2: cache analog and collision Rp in CLDenis Brockus2020-06-116-33/+149
| | | | | | | | | | | | | | | | 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>
* cleanup: comment update from CL:2233794Jett Rink2020-06-101-2/+2
| | | | | | | | | | | BRANCH=none BUG=none TEST=build Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: If012f7d746193cfc013155def10bbc7c30c8971f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2240193 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: process TCH before and after prl_txJett Rink2020-06-101-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to process the TX chunking state machine both before and after the prl_tx state machine. Processing before allows us to send outgoing chunked messages on this iteration. Processing after allows us to send the TX_COMPLETE status to the PE layer on the same iteration the PRL gets its notification. Without this change, if the TCPC fires its alert saying we finished the TX and we also receive a message (in response to that TX), then we would get a RX message/event before the TX_COMPLETE notification was sent in the PE layer. BRANCH=none BUG=b:158248741 TEST=Verify the RX and TX messages are happening in the same statemachine cycle instead of getting the RX event first. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I6fd2ece2326f8dc3cee85c94baae09466d673e87 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2239035 Tested-by: Diana Z <dzigterman@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: retool start/end AMSJett Rink2020-06-103-103/+91
| | | | | | | | | | | | | | | | | | | | | | | - Drop start and end ams function in favor of a flag based approach - Don't clear RX queue on TX reset. We are supposed to drop any pending TX messages (not RX messages). This should also help us to process partner messages if we get a collision - Drop prl_tx_phy_layer_reset_run and call next state directly in entry - Dropping retry_counter reset to 0 since that happens in entry method - Dropping flags reset to 0 because it is most likely dropping more flags than we want. BRANCH=none BUG=b:158248741,b:157228506,b:157661566 TEST=DUT accepts soft resets Change-Id: Ice8721a6c81452584f8d4ec474cb4f4a487b713b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2233794 Tested-by: Diana Z <dzigterman@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: clear TX_COMPLETE before starting sendingJett Rink2020-06-101-68/+75
| | | | | | | | | | | | | | | | | | We have had issue with the TX_COMPLETE flag remaining from previous TX transactions. This can incorrectly make the subsequent TX transaction code think that its TX send has completed. It is safer to always clear the TX flag before starting a new TX transition. BRANCH=none BUG=b:158248741 TEST=Verify that TX_SUCCESS does not linger from previous transactions Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I5fd7d849bdf97582d5b03b8d833de24b550d8c07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2239034 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Register a port as not PD capable on detachDiana Z2020-06-101-0/+2
| | | | | | | | | | | | | | | | | | Currently, the PE will set the PD capable sleep mask indicator when a connection starts but never clears this, preventing deep sleep if there has ever been a PD partner plugged in. This clears the indicator from the TC on detach. BRANCH=None BUG=b:157887329 TEST=on waddledoo, verify sleepmask bit for PD is no longer set on partner unplug Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If2d2fc08adb5787268705ee457e226c70336ff44 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2237369 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* dp-hpd: abstract HPD gpio pinEric Yilun Lin2020-06-101-7/+19
| | | | | | | | | | | | | | | 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-105-69/+357
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tcpmv2: Reset hard_reset_counter on TC attach exitDenis Brockus2020-06-091-0/+12
| | | | | | | | | | | | | | | | | | | Clear the PE hard_reset_counter when we are in the TC unattached state to make sure any new attach will have retries. BUG=b:155941384 BRANCH=none TEST=5V charger test Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Id92ca8fb41e782c124fd89dfdba6da5705ea12a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2236587 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* usb_pd_protocol: Invalidate last message id in SRC_SWAP_STANDBY statePatryk Duda2020-06-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In SRC_SWAP_STANDBY state when PD_CTRL_PS_RDY message is received, message id counter is cleared, but last message id remain the same. Situation where last message before power swap had message id equal to 0, and first message after power swap had message id equal to 0, was reported as message duplication and as result hard reset was triggered. From ServoV4 perspective: C1 RECV 0e6a/0 <-- Received PR_SWAP with msg_id 7 C1 CTRL[3]>1 <-- Accept it C1 st27 SRC_SWAP_SNK_DISABLE C1 st28 SRC_SWAP_SRC_DISABLE C1 st29 SRC_SWAP_STANDBY C1 CTRL[6]>1 <-- Send PS_RDY C1 RECV 0166/0 <-- Received PS_RDY with msg_id 0 due to msg_id overflow C1 st5 SNK_DISCOVERY C1 Repeat msg_id 0 <-- DUT sent capabilities with msg_id 0 C1 HARD RST RX <-- DUT sent hard reset due to timeout BUG=none BRANCH=none TEST=Flash nocturne with EC compiled with TCPMv2/PD3.0 support. Flash ServoV4 with this fix. Run firmware_PDConnect, test should pass. During test check if ServoV4 is not receiving hard reset requests. TEST=Flash nocturne with EC compiled with TCPMv2/PD3.0 support. Flash ServoV4 with this fix. Run 'fakedisconnect 100 10000' in ServoV4 console. Run 'pd 0 swap power' in DUT console. During power swap no hard reset states should be entered. Change-Id: I902d153a4f427c6a7239f8ff8b70efc9418da31a Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2231365 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_pd: Cleanup: Add functions to process Disc IdentityAyushee2020-06-091-65/+73
| | | | | | | | | | | | | | | | Add separate functions process_am_discover_ident_sop() and process_am_discover_ident_sop_prime() to process the Discover Identity command. BUG=b:148528713 BRANCH=none TEST=make buildall -j Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Id074b2fc5c9aae02b51b110c9959656cacb36ee7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2185615 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* usb_pd: Cleanup: Cable flagsAyushee2020-06-093-129/+75
| | | | | | | | | | | | | | | | | | | | | | 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>
* common: Restrict gpioset console command for FPMCUYicheng Li2020-06-091-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | Generally, we don't want people to be able to modify GPIOs in production. The main EC already disables the whole console input in production. For the FPMCU, the host command version of gpioset is already restricted. This change restricts the console command version on FPMCU, without changing other boards' behavior. BRANCH=none BUG=b:154655729 TEST=make -j buildall TEST=(change bloonchipper board's USART settings to be the same as nucleo-f412zg's) make -j BOARD=bloonchipper flash the resulting firmware to a nucleo-f412zg device gpioset USER_PRES_L 0 ==> Success syslock ==> Check sysinfo, shows locked gpioset USER_PRES_L 0 ==> Access Denied Change-Id: I9ab893b5742926732148e7c363d8aa7dcd7466f2 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2172056 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* TCPMv2: Call into PD Vbus checkDiana Z2020-06-091-1/+1
| | | | | | | | | | | | | | | | Since not all boards detect Vbus through their TCPC, call into the PD Vbus check function when checking Vbus during a power role swap. BRANCH=None BUG=None TEST=on kindred (with PPC Vbus detection), verify power role swap completes without crashing the EC Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I9e2ae4180f18833fd71acb9661283fafbd80d25a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2236624 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv1: Add CONFIG_USB_PD_TCPMV1_DEBUG optionKeith Short2020-06-091-5/+6
| | | | | | | | | | | | | | | | | | | | Several legacy boards are consistently running out of flash space. Add CONFIG_USB_PD_TCPMV1_DEBUG option which can be disabled on a board to save about 900 bytes of flash space in the RO and RW images. BUG=none BRANCH=none TEST=make buildall TEST=Verify Volteer board runs with CONFIG_USB_PD_TCPMV1_DEBUG disabled and the PD debug level set to 1. Also run the "pd <port> state" command and verify no side effects. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I29bb70b7d347d8c6d5797c01ed892329d90aa671 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2236629 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* EFS2: Verify and jump when system shuts down in RODaisuke Nojiri2020-06-092-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when the system shuts down in RO, EC resets with AP_OFF flag. This was for allowing the EC to jump to RW and get ready for the next normal boot after a system shuts down from the recovery mode (chromium:1045209). This behavior causes the reboot from the recovery mode to be stopped (b:154778457). This patch makes RO jump to RW instead of resetting with AP_IDLE flag. After sysjump, the AP can continue to sequence up or down. BUG=b:154778457, chromium:1045209, b:156694627, b:157077589 BRANCH=none TEST=test_that suite:faft_bios passes. TEST=Press power button in recovery screen on Zork, Puff, Volteer. System stays in S5 after sysjump. TEST=firmware_CorruptBothFwSigAB passes on Zork, Puff, Volteer. TEST=Hibernate EC on Zork, Puff, Volteer. Press power button once. System boots. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: If08f3bb7f89c2407e4c5207ade820085f65ea9ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2213359 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>