summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: Add EC_CMD_TYPEC_DISCOVERYDiana Z2020-09-033-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This host command will return all discovery information for the given port and transmit type (SOP, SOP'). Each piece of information includes a count of the number of valid fields filled in to the arrays. To keep the command consolidated and easy to parse, this means there will be some number of bytes in each response which do not contain useful information. With this method, we may fit 7 SVID entries with mode information, which is less than the 16 which the EC can store, but more than most port partners present. BRANCH=None BUG=b:165264379 TEST=on waddledoo, confirm ectool shows: -no discovery information with nothing plugged in -no discovery information with a charger which doesn't reply to VDMs -SOP identity but no SVIDs with Moshi, which NAKs DiscoverSVIDs -SOP identity and all SVIDs with Apple 3-in-1 -SOP and SOP' identity and all SVIDs with TBT dock Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Idf21b23ebe4cda62781762188601b2cc35ede65d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363417 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* tcpmv2: allow early connection when waiting to allow LPMDenis Brockus2020-09-021-5/+8
| | | | | | | | | | | | | | | | | | While waiting to go into Low Power Mode the TCPC can detect a connection and we should honor that instead of waiting for the timeout and going into Auto Toggle. BUG=b:157718272 BRANCH=none TEST=FAFT_PD "dut-control usbc_pr:src20v" Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ib3a3233ebf9b05b83446d7c1163e30fdcaf42aec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2390848 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add DPM_REQUEST_GET_SRC_CAPDenis Brockus2020-09-022-5/+101
| | | | | | | | | | | | | | | | | | | | | As a SRC that runs on battery it can be handy to determine if the connected partner has unconstrained power available so we can try to PR_Swap to let them power us. This only requests the information, if it is not already available, and leaves it to other code to determine if the swap is a good idea. BUG=b:166446426 BRANCH=none TEST=connect a sink device and determine it performed the action Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: If45801a33df8b75e541989d7ee8f36ed316ffcc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381408 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Disabling DPM_REQUEST for SnkGetSnkCaps if FRS disabledDenis Brockus2020-09-021-4/+18
| | | | | | | | | | | | | | | | | | | Leaving this code in when we don't care about the single thing we are getting from it, whether the partner can do FRS, does not make a lot of sense and wastes flash space if we do not have FRS configured to be enabled in the current build. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I73568f04af5bf1df7a03b53983b8e1f443dbdae7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381407 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: allow TxSinkNG/OK to cross power roles on pr_swapsDenis Brockus2020-09-021-24/+12
| | | | | | | | | | | | | | BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I056b61cc0e6b7a56f1673728f52783c9d0cf196c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370746 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: clear Modal and VDMSetupDone in dfp_discovery_initDenis Brockus2020-09-021-4/+6
| | | | | | | | | | | | | | | | | | Clear MODAL_OPERATIONS and VDM_SETUP_DONE flags in pd_dfp_discovery_init to to make sure we do a full discovery BUG=b:165983983 BRANCH=none TEST=dock specified in bug should be able to PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Idcccf131e7a0dce25d11b740e947e53be8d69dc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2378200 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: use sender_response message frameworkDenis Brockus2020-09-021-128/+234
| | | | | | | | | | | | | | | | | | Building up the framework to handle discarded DPM requests and using it on all of the sender_response messages BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I542d4cba89a923fb16588cc675d2ea4ab7954e0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376386 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* motion_sense: use clamp functions in sending 32bit sensor valuesIkjoon Jang2020-09-021-13/+15
| | | | | | | | | | | | | | | | | | | Apply 32bit clamp functions in sending 32bit sensor values to host. Clamp functions explicitly clamp values into 16bit ec protocol regarding its sensor type. Clamp functions take its sensor type as an argument and clamp 32bit value into 0~65535 for light sensors and -32768 ~ 32767 for all other motion sensors. BUG=b:144002158 TEST=Reading illuminance values in kukui kernel BRANCH=none Signed-off-by: Ikjoon Jang <ikjn@chromium.org> Change-Id: I977114e26f28e7806c11b0a97c9edec7a84ea0dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2328951 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* tcpmv2: clear oc counter when unattched.SNKZick Wei2020-09-021-0/+8
| | | | | | | | | | | | | | | | This CL clear oc_event_cnt_tbl for both USB-C0, USB-C1 port when in unattached.SNK state. BUG=b:166536767, b:165946265 BRANCH=zork TEST=verify that oc event counter will be clear when in unattached.SNK Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: If1d6f56d32ad62e8195456ad4fa5e1286a7bac81 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2387680 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: disable receive of SOP' during VCONN swapKeith Short2020-09-021-2/+25
| | | | | | | | | | | | | | | | | | | The USB PD specification indicates that the initial VCONN source shall cease source VCONN within tVCONNSourceOff (25 ms) after receiving PS_RDY. Not all partners wait after sending PS_RDY before trying to communicate with the cable. BUG=b:163478172, b:163143427 BRANCH=none TEST=make buildall TEST=Connect 2 Volteers together and force VCONN swaps confirming the sequence completes normally. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I14720f033c5f6e9caed9c4fe3bfa11e5c046116e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381030 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* charge: CONFIG_CHARGE_RAMP_SW allows for TypeC/PD currentDenis Brockus2020-09-021-4/+0
| | | | | | | | | | | | | | | | | chg_ramp_max limited CONFIG_CHARGE_RAMP_SW to BC1.2 current. Allow this to be PD and TypeC as well. BUG=b:163864475,b:167257846 BRANCH=none TEST=ramp up to 1.5A from legacy charger Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I0aee9ecad2ccc9de1d7419c1a33507ccfda05fb5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2388080 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usb_port_power_dumb: Turn on USB ports on chipset startupWai-Hong Tam2020-09-011-3/+3
| | | | | | | | | | | | | | | It turns off USB ports on the HOOK_CHIPSET_SHUTDOWN hook. In order to pair with it, should turn on USB ports on the HOOK_CHIPSET_STARTUP hook, instead of HOOK_CHIPSET_RESUME hook. BRANCH=None BUG=b:167155164 TEST=Built a Trogdor image and tested USB-A working on the first bootup. Change-Id: I7f45a5e56bc38388fa906b430cd7dba6835ac17e Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2386495 Reviewed-by: Stephen Boyd <swboyd@chromium.org>
* usb_pe_drp: new unit test with mocksPaul Fagerburg2020-08-316-8/+288
| | | | | | | | | | | | | | | | | | | Add a new unit test for usb_pe_drp with mocks for the various subsystems that it will use. The fake_prl module is already essentially a mock for the PRL layer, so just move it into the mocks directory and make it available as mock to other tests. BUG=b:163421994 BRANCH=None TEST=`make runhosttests` succeeds Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2aea3fa0694e8d9e6bae1f47516cb4d5d2a1e714 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364050 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* eve: Move board level TCPC init to happen in pd_task initDuncan Laurie2020-08-311-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the board level TCPC run as an init hook it will frequently lead to an EC reset when we are trying to recovery a disconnected battery, potentially even a reboot loop with the most unlucky timing. If we instead call it from the pd_task before tcpc_init is called then the board init hook can stall the pd_task init until the battery is out of disconnect mode, or giving up after 2 seconds in case the battery never seems to recover. This accomplishes two goals: ensure the PD chips are not reset until the battery is out of disconnect and delay start of the pd_task (and PD negotiation) until the battery is out of disconnect state. With this change I never see an EC reset when recovering from a disconnected battery state. BUG=b:63957122 BRANCH=eve TEST=manual testing on Eve with 50+ battery disconnect and battery cutoff cycles to ensure it never triggers an unexpected EC reset. Change-Id: Ie1604e82916ea203a32cbdde98f6697e344bba4c Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/592716 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2320248 Commit-Queue: Patryk Duda <pdk@semihalf.com> Tested-by: Patryk Duda <pdk@semihalf.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* fpsensor: Run maintenance when in maintenance modeTom Hughes2020-08-312-0/+8
| | | | | | | | | | | | BRANCH=none BUG=b:76037094 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibe8649c3cf77ef4542b5fc46d7df5eee03293b56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364755 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* power_button: Add CONFIG_POWER_BUTTON_TO_PCH_CUSTOMEdward Hill2020-08-291-1/+4
| | | | | | | | | | | | | | | Allow board to provide board_pwrbtn_to_pch function to override the default behavior of gpio_set_level(GPIO_PCH_PWRBTN_L, level) as the means for asserting power button signal to PCH. BUG=b:164921478 BRANCH=zork TEST=power button timing Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I8f5ffb2759318fdc941155b60be8bf4aa7dd4771 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2378557 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* driver: add ICM-426xx driver supportJean-Baptiste Maneyrol2020-08-291-0/+1
| | | | | | | | | | | | | | | Add ICM-426xx accel/gyro driver code. BUG=chromium:1117541 BRANCH=None TEST=ectool motionsense fifo_read && tast run hardware.SensorRing Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Change-Id: I83fe48abc6aa9cde86576a777ac4272d90fac597 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317888 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org>
* TCPMv2: Send SOP'/SOP'' VDM only when the port is VCONN srcAyushee2020-08-282-1/+77
| | | | | | | | | | | | | | | | | | | | | | According to USB PD spec, section 2.5.4, only VCONN source can communicate with the cable plug. This CL checks if the port is the VCONN before sending SOP'/SOP'' messages. If there is a VCONN source failure, port retries swapping the VCONN times before marking the VDM as failed/naked. The CL also enables falling back to DP mode in case enter mode thunderbolt fails. BUG=b:148528713 BRANCH=None TEST=Tested on volteer, the port sends SOP'/SOP'' VDMs to the cable only if it's the VCONN source Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I5880104a7a42b3e7de9e472affd41e937d36f9a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368066 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: set VDM response buffer and lengthli feng2020-08-281-13/+30
| | | | | | | | | | | | | | | | | | | Pass tx_emsg[port].buf to VDM response implementation functions Convert data objects count to bytes VDM header in VDM response message should not use USB_VID_GOOGLE as SVID to respond to all requests. Save SVID from received request and compose response VDM header with this SVID. BUG=b:148528713,b:157163664 BRANCH=none TEST=Connect volteer to Gatkex DFP port, with CL:2370045, check VDM response messages from Volteer have correct contents. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I7403af1449abfa4ebf6b43ded457e3654396aadb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368067 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: handle un- and supported auto toggle TCPCRuibin Chang2020-08-281-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | This CL changes for both unsupported and supported auto toggle TCPC on a board: 1.board level enable CONFIG_USB_PD_TCPC_LOW_POWER: Exit LPM state for unsupported auto toggle TCPC port, when drp state is TOGGLE_ON in S0. 2.board level enable CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE: Don't transit to TC_DRP_AUTO_TOGGLE state for unsupported auto toggle TCPC port. BUG=none BRANCH=none TEST=on board drawcia, check unsupported auto toggle TCPC port: 1.connect with adapter/dongle, pd state to SNK/SRC_Ready during G3 -> S0. 2.shut down to G3, connect with adapter and pd state to SNK_Ready. Signed-off-by: Ruibin Chang <ruibin.chang@ite.com.tw> Change-Id: Ic6afc84df1564b2cb19a9032bba0752091cbf7a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2362371 Tested-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Ruibin Chang <Ruibin.Chang@ite.com.tw>
* Charger: Add chgnum parameter to OTG set functionsDiana Z2020-08-273-11/+11
| | | | | | | | | | | | | | | | Add the charger number as an input for setting OTG output current and enabling it, both in the charger driver and in charge_set_output_current_limit(). Also add a clarifying note about the intent of CHARGER_SOLO. BRANCH=None BUG=b:147440290 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I7656c19a87d8216f5efc72dcffa6d638064d3e2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376469 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* OCPC: Assume port == chgnum when checking OTGDiana Z2020-08-271-0/+3
| | | | | | | | | | | | | | | Since OCPC has one charger chip per port, it can be assumed in the charger_is_sourcing_otg_power() function that the port will be the same as the charger number with this config enabled. BRANCH=None BUG=b:147440290 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iff5130e9ac7c268d38fe75eb3eb1c9ea5864abd4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376468 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* system_is_locked: Use static variable to track stateDuncan Laurie2020-08-271-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_SYSTEM_UNLOCKED is not defined the function to check if flash is write protected (flash_get_protect()) can take up to 7ms to execute, and this function is called up to 18 times when booting from RO. Use a static variable to track the status so we do not spend so long executing this one function. Without this change I would regularly see a PD hard reset when booting without a battery and the system would fail to boot. BUG=b:63957122 BRANCH=eve TEST=manual testing to reliably boot without a battery on Eve Change-Id: I806a215b5745b41ce0d99aeb6853ebfecb0cb7d1 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/582542 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2320002 Tested-by: Patryk Duda <pdk@semihalf.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Patryk Duda <pdk@semihalf.com>
* hack: temporarily work around TX_COMPLETE failureJett Rink2020-08-271-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After we removed the retry logic in the PRL layer, we uncovered an issue that was being masked. On Delbin, the state machine is not receiving that the PD messages (namely Request) is being sent successfully. We get neither success or failure within 100ms. We still need to figure out and fix this the root cause. This change just assumes that any sent PD traffic is successful after 100ms (instead of a failure) for Delbin boards only. There is an upcoming build for Delbin that we will have power on issues if we don't add some kind of power work around. This patch will not allow the USB PD stack on Delbin to work properly in all scenarios; this patch only aims to ensure that we can get power to the device to test other non-PD functionality. This CL should be reverted within a two week time frame. BRANCH=none BUG=b:164154200 TEST=Delbin can power on Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: If6dce35dfd78ee3a70e6216a7b6bf62d3ded5646 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376477 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Anson Tseng <ansontseng@google.com> Tested-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com>
* CBI: Validate data size of input from hostDaisuke Nojiri2020-08-271-0/+4
| | | | | | | | | | | | | | | | | | | | Currently, the size of input data is not verified. This can cause read overflow in cbi_set_data. This patch makes the host command handler validate the input data size. BUG=chromium:1114458 BRANCH=none TEST=cros_fuzz --board=amd64-generic reproduce \ --fuzzer ec_host_command_fuzzer \ --testcase ...ec_host_command_fuzzer-5111452783935488 \ --package chromeos-ec --build-type asan Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ia3e03cd6bb857e0fa594de9d8cc66d8788d6dcd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2378203 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Charger: Call discharge on AC for all chargersDiana Z2020-08-271-7/+9
| | | | | | | | | | | | | | | This change adds a loop to the common charger driver to set discharge on AC for all chargers, since it's unlikely a caller of this API would only want this feature enabled for a single port. BRANCH=None BUG=b:164256610 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ib23a93259a630016cb0f1384a6fc2b19b2baafb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2375725 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: re-enable GetSnkCap call for allDenis Brockus2020-08-271-67/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | The problem was a discarded SendSrcCap message that happened around the same time as the GetSnkCap. GetSnkCap timedout and did what it was supposed to do but the SendSrcCap locked up waiting for the message to transfer before it started the timer to allow it to time out. Never would happen. Built in a framework to track the current DPM request to make discard redirections easier to determine. Also good for re-queuing DPM requests that are discarded. BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I8854ac745d4489125c84b7e617d5fa1a94e70e51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370747 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Modal Operations should clear in dfp_discovery_initDenis Brockus2020-08-261-0/+2
| | | | | | | | | | | | | BUG=b:165983983 BRANCH=none TEST=dock specified in bug should be able to PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ifaccba2d741ed066e6bafc95c7e604b8f8dcfb17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2373322 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* ocpc: Check CFET status before changing VSYSAseda Aboagye2020-08-261-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | If the CFET is disabled, then the charging feedback loop is broken and any further adjustments of VSYS will have no effect on the charging current. Therefore, the system should not try to make any VSYS adjustments while this is occurring. This commit causes the the OCPC loop to check if the CFET is disabled before deciding to adjust VSYS or not. BUG=b:160918663 BRANCH=None TEST=Build and flash waddledee, charge DUT thru sub board until battery toggles the CFET, wait until the toggling ceases, verify that VSYS was not changed during that time. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I7c0e5dce277118600b8f3120a6637938645db6ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370044 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* battery_fuel_gauge: Add check for CFET statusAseda Aboagye2020-08-261-14/+54
| | | | | | | | | | | | | | | | | | | This commit adds a function that allows the system to check the if the charge FET (CFET) is disabled or not. BUG=b:160918663 BRANCH=None TEST=Build and flash waddledee; cutoff battery, revive system, verify that "found batt in disconnect" statements are still found. TEST=Add other code, verify that CFET status is able to be retrieved. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I899070e50a38499708a367bba6b5f502b0232672 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368071 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
* usb_mux: move usb_mux_set_safe_mode()Keith Short2020-08-243-19/+15
| | | | | | | | | | | | | | Move usb_mux_set_safe_mode() definition into usb_common.c so it's available to the test framework. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I789a470468ae441e366afbf94ce3c29db526dfd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370409 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Don't interrupt RX/TX Extended Chunked Msg sequenceSam Hurst2020-08-222-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delay sending a new message during the reception or transmitting of Chunked messages. BRANCH=none BUG=b:161836223 TEST=make -j buildall manual: Transmitted an extended message and verified that the sequence was not interrupted by attempting to send a VDM message. Without patch Chunked message request that was interrupted. 20-08-14 10:46:13.473 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:46:13.494 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:46:13.516 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:46:13.535 C1: RECV 909f/1 [0]0000a400 Try to send VDM. MSG_TYPE is corrupted, was 0x1f, now 0x0f 20-08-14 10:46:13.563 C1: RECV 928f/1 [0]0000ac00 20-08-14 10:46:13.591 C1: RECV 948f/1 [0]0000b400 20-08-14 10:46:13.618 C1: RECV 968f/1 [0]0000bc00 20-08-14 10:46:13.645 C1: RECV 988f/1 [0]0000c400 20-08-14 10:46:13.674 C1: RECV 9a8f/1 [0]0000cc00 With patch. Chunked message request was not interrupted. 20-08-14 10:50:56.052 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:50:56.075 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:50:56.093 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:50:56.114 C1: RECV 909f/1 [0]0000a400 Try to send VDM. Message delayed 20-08-14 10:50:56.134 C1: RECV 929f/1 [0]0000ac00 20-08-14 10:50:56.155 C1: RECV 949f/1 [0]0000b400 20-08-14 10:50:56.175 C1: RECV 969f/1 [0]0000bc00 20-08-14 10:50:56.195 C1: RECV 989f/1 [0]0000c400 20-08-14 10:50:56.216 C1: RECV 9a9f/1 [0]0000cc00 20-08-14 10:50:56.242 C1: RECV 0c90/0 Try to send VDM. Signed-off-by: Sam Hurst <shurst@google.com>wq Change-Id: I5475792ee9f272fe4964e27839e55e3409a6a799 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357414
* usbc: remove PD_EVENT_SM in favor of task_wakeJett Rink2020-08-213-14/+13
| | | | | | | | | | | | | | | | We have used both methods of waking up the PD tasks to process the next state: PD_EVENT_SM and TASK_EVENT_WAKE. They effectively do the same thing and it is more straightforward to only have one way to wake the task up with the sole purpose of re-evaluating the current state. BRANCH=none BUG=none TEST=No regressions on GRL testing. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I0fa79b82223e6b97eede4130480156949d79f365 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363466 Reviewed-by: Edward Hill <ecgh@chromium.org>
* gpio: add a gpio_or_ioex_get_level function to match the setterPeter Marheine2020-08-211-0/+8
| | | | | | | | | | | | | | Code that wants to work with either regular or IO expander GPIOs may also wish to read the current value; this function permits it. BUG=b:159051013,b:165622386 TEST=buildall BRANCH=None Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I677617621ae4964f568ad87512b372ce8a9830a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2366455 Reviewed-by: Edward Hill <ecgh@chromium.org>
* TCPMv2: SRC->SNK PR Swap enable AutoDischarge after VbusDenis Brockus2020-08-211-15/+37
| | | | | | | | | | | | | | | | | | | A debounce was added to allow for the TCPC to get a valid Vbus but AutoDischargeDisconnect was enabled as soon as we set for the debounce. Since Vbus had a good chance of not being valid, we would get a FAULT from the TCPC indicating an Auto Discharge Disconnect failure. BUG=b:165797061 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I897d682e405d7f2fcda4b4a36a3c1b333e8f7913 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2365253 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: PR_Swap SRC->SNK should send PS_RDY in current AMSDenis Brockus2020-08-211-6/+16
| | | | | | | | | | | | | | | | | | The SRC->SNK PR_Swap is currently starting a new AMS for the SNK PS_RDY and this causes the partner to disconnect from the bus instead of continuing with the swap. BUG=b:165794652 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Id953a9b6f78057777617d06f518eb17b061b6f92 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2365057 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Do not send GetSnkCap if FRS is not enabledDenis Brockus2020-08-211-1/+10
| | | | | | | | | | | | | | | GetSnkCap is only needed for FastRoleSwap BUG=none BRANCH=none TEST=PR_Swap DUT-DUT testing Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I51973dfbfbfe855d1027c3b1cec35a2ba06a7b65 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2367283 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usbc: wake task on every state transitionJett Rink2020-08-193-1/+11
| | | | | | | | | | | | | | | | | | Whenever we change state, we should continue to wake the USB statemachine task up until is settles into a steady state were it is waiting/polling on a timer or event. BRANCH=none BUG=b:163152687 TEST=Ran GRL PD3.0 test on Trembyle and did not see any regressions. It did make a few tests pass that were failing before due to timing issues. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Idc3c1ae8d92a0f6a5cd4b82f9db6d7138d143f77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2356954 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* cleanup: update formatting for clarityJett Rink2020-08-191-11/+10
| | | | | | | | | | | | | | | Make it clear that there are multiple function calls happening instead of a single statement with multiple parameters. BRANCH=none BUG=none TEST=builds. No actual code change Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I1c01a40794e0c2dc08be205ac953f42bdc9298be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363465 Commit-Queue: Edward Hill <ecgh@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* TCPM common: Store number of Identity VDOsDiana Z2020-08-191-0/+1
| | | | | | | | | | | | | | 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>
* common: gyro_cal: Implement gyroscope calibrationYuval Peress2020-08-184-18/+1012
| | | | | | | | | | | | | | Implement the calibration code for the gyroscope which is ported over from AOSP's https://android.googlesource.com/device/google/contexthub/+/refs/heads/master/firmware/os/algos/calibration/gyroscope/ BUG=b:138303429,b:137204366,chromium:1023858 TEST=Added unit tests BRANCH=None Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ic1ab2efb66565cda0a96c9c06722136fb184df77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244934 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Revert "system: Clear AP_IDLE when waking up from hibernation by AC"Daisuke Nojiri2020-08-181-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 4aacf83506fd959d1341e29b664f6e4fe97824cb. Reason for revert: See chromium:1073960 Original change's description: > system: Clear AP_IDLE when waking up from hibernation by AC > > 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 Bug: b:157077589 Bug: chromium:1073960 Change-Id: Id92d0d3657a622338581cb111d3925cbc11bf168 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363080 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
* TCPMv2: Debounce VBUS on SRC to SNK swapKeith Short2020-08-181-2/+21
| | | | | | | | | | | | | | | | | Copying TCPMv1 behavior, debounce VBUS at the completion of a SRC to SNK swap to allow the TCPC/PPC to update the VBUS state following receipt of the PS_RDY message from the partner. BUG=b:162347811 BRANCH=none TEST=make buildall TEST=Force power role swaps and observe no false disconnects. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ia0644cde64d14044b7e291bf582b68ac4278af0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363411 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* config: Require battery >5% to enable PD Try.SRCWai-Hong Tam2020-08-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Align the CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC to the value of BATTERY_LEVEL_CRITICAL, which is 5%. The BATTERY_LEVEL_CRITICAL is 5% that means EC will send battery- critical host event when the battery level <= 5%. CrOS PD policies state that the system doesn't source power to any external USB devices when AP is shutdown. So the current CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC 1% default has no point. When the battery level is <= 5%, AP should be shutdown soon and the system should not be a source, so should not enable Try.SRC. Also change the comparison from soc >= CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC to soc > CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC as the battery critical check is soc <= BATTERY_LEVEL_CRITICAL. BRANCH=None BUG=b:165057418 TEST=Plugging a PD charger to a board with the battery level very low, the system boots up (was failed), Change-Id: If6b11feacd62fd003e13b1756eb5c33d2f9bbce4 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2360543 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* task: Change mutex_lock() assertEdward Hill2020-08-151-4/+0
| | | | | | | | | | | | | | | | | | | Instead of asserting that task_start() has not been called, just return without doing any locking. This avoids the need to fix every caller of mutex_lock() to check task_start_called(). BUG=b:164461158 BRANCH=none TEST=Esc+F3+Power enters recovery, does not assert. Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Ic157d7e7041185a67f257f0f5710fd02e45cd77f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357496 Reviewed-by: Wai-Hong Tam <waihong@google.com> Tested-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com>
* fingerprint: Stopgap to repair public buildsCraig Hesling2020-08-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This repairs building bloonchipper and dartmonkey builds when private lib is unavailable. There are two issues this remedies: 1) Redefinition of sensor info macros, like FP_SENSOR_RES_X 2) Undefined reference to fp_sensor_maintenance when building bloonchipper/dartmonkey non-private image. All of these issues stem from the way we handle code when HAVE_FP_PRIVATE_DRIVER is set or faked by a test. This is a fundamental issues that needs some thought and refactoring. BRANCH=none BUG=b:164174822,b:163109916, b:163411883 TEST=# With private time make buildall -j TEST=# Without private time make buildall -j TEST=# With private libs # Cherry-pick https://crrev.com/c/2357870 first, then # this patch. ./util/compare_build.sh -b all -o # This confirms that the all output binaries with private-lib # did not change at all Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: If71e3376fb7a904b77f2fc9fc56c8e0daf54db3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357430 Reviewed-by: Andrew de los Reyes <adlr@chromium.org> Reviewed-by: YH Lin <yueherngl@chromium.org>
* System: Set stay-in-RO reset flag for sysjump and host commandDiana Z2020-08-141-3/+14
| | | | | | | | | | | | | | | | | | With EFS2, the EC can jump itself straight from RO to RW without AP intervention. However, sometimes the AP or a developer may want the EC to remain on RO to perform operations there. In these cases, set the reset flag to say in RO. BRANCH=None BUG=b:161887378 TEST=on waddledee, run "sysjump ro/rw" while the AP is on and confirm the AP remains on. Run "flashrom -p ec -w /tmp/ec.bin" and confirm the operation completes successfully. Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I036bd04514858a55e4e52abfc05eb67896436505 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354742 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* sysrq: Ignore H1_EC_RECOVERY_BTN_ODLDaisuke Nojiri2020-08-141-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On Puff, there are two signals from the recovery button. One is from the button and the other is from H1. The signal from H1 is masked by the power button and it looks asserted only after the power button is released. This makes the EC start the warm reset timer. If the user doesn't release the recovery button (as instructed) to enter the recovery mode for four seconds, the AP resets and entry to the recovery mode fails. This patch makes the EC ignore H1's signal as sysrq signal. BUG=b:163443447 BRANCH=Puff TEST=Recovery mode can be entered by keeping recovery button pressed on Duffy. TEST=Recovery button triggers sysrq. TEST=Holding recovery button for 4 seconds triggers AP reset. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I8631d5dc0da8c95eed1d740b0683aa5de7848335 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2353890 Reviewed-by: Andrew McRae <amcrae@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
* cleanup/usbc: organize all super states togetherJett Rink2020-08-131-27/+30
| | | | | | | | | | | | | | Like other state machine declarations, put all of the super states together to make it more clear when reading states. BRANCH=none BUG=none TEST=build and unit tests Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I1bb776434911d3acdb34abc64e7e8fa5f87154de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354193 Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: add GEN_NOT_SUPPORTED macro for unsupported statesJett Rink2020-08-133-61/+35
| | | | | | | | | | | | | | | | | | | To enabled use of the IS_ENABLE macro we need to define some of the usb state machine states as extern variables that will never be linked. This allows the compiler to know about a state but will still fail the linking phase if the config option is not defined properly. This is just adding a convenience macro for this paradigm, not creating the paradigm itself. BRANCH=none BUG=none TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Ia19b5babd43d536f043745314481475cf25f6e01 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2353369 Reviewed-by: Edward Hill <ecgh@chromium.org>