summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: clear TC_FLAGS_PR_IN_PROGRESS if ProtocolErrorEric Yilun Lin2020-10-161-0/+14
| | | | | | | | | | | | | | | | | | | | While doing PRS_SNK_SRC on a DRP hub by unpluging the charger, if the port-partner can't hold tSrcTransition, and it might brown out at any time in PR_SWAP AMS (e.g. brown out and can't reply GoodCRC to Accept), and this will cause a ProtocolError. In that case, we should clear the TC_FLAGS_PR_IN_PROGRESS so that the TC sm could start to monitor the VBUS level and restart the PD state machine. BUG=b:169113820 TEST=unplug the charger from a DRP hub, and DUT starts to source the hub instead of staying at SNK_READY. BRANCH=none Change-Id: Iccb85a13731004a214446ce4d915fea58170ea00 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2440015 Reviewed-by: Diana Z <dzigterman@chromium.org>
* tcpmv2: handle custom VDM betterDenis Brockus2020-10-162-0/+10
| | | | | | | | | | | | | | | | | | We were receiving a custom VDM that was not one that we would understand and should have gracefully exited from this. BUG=b:158605675 BRANCH=zork TEST=USB-C to HDMI dongle with power attached Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Icf5a699709828c7354d392612a771307bd7a09e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2477235 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Config option fixes to allow type-c only supportScott Collyer2020-10-152-27/+34
| | | | | | | | | | | | | | | | | | | This CL adds config option guards where for the try.src feature. The current version of the tc state machine will not build without CONFIG_USB_PD_TRY_SRC defined. In addition, there are a few function calls that are only required if USB-PD is supported. BRANCH=None BUG=b:169812364 TEST=Build quiche without CONFIG_USB_PRL_SM, CONFIG_USB_PE_SM, and without CONFIG_USB_PD_TRY_SRC defined. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I0bba736b139463bfa213deaf88e7c9a4b3ffbab0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2247115 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org>
* TCPMv2: Avoid alt mode files from changing DPM statesAyushee2020-10-145-32/+54
| | | | | | | | | | | | | | | | | | | | | | | | USB4 mode: Added a function to check if the USB4 entry is completed Thunderbolt mode: Added 2 flags TBT_RETRY_DONE, TBT_EXIT_DONE to track the Thunderbolt mode's exit and if retry is needed and a new function to check if if the Thunderbolt mode entry is completed DisplayPort mode: Added a function to check if the DisplayPort entry is completed BUG=b:169169804 BRANCH=None TEST=1. Able to enter alternate mode on hotplug and reboot 2. Able to exit the alternate mode on chipset transition and on DPM's exit mode request. Change-Id: I09662449143ad8d94b30ae102ed5ce79db852687 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2421425 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TBT:Add support for exit mode SOP'/SOP'' on chipset transitionAyushee2020-10-146-76/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When chipset is transitioning to a new state or on sysjump, the EC re-negotiates to enter an alternate mode on booting up. This commit adds support for exiting Thunderbolt mode for SOP' and SOP'' for active cable on chipset transition and also moves all the alternate mode exit rotines to their respective files. It also delays deleting the SVID data until after the EXIT_MODE message has ACKed and avoids pd_dfp_exit_mode() from changing the alternate mode's internal states. This commit also makes sure that the mux is set to safe state before exiting the alternate mode and it is reconfigured according to the port's current data role on receiving ACK/NAK from the cable/port partner. BUG=b:151169925, b:159717794 BRANCH=none TEST=On reboot, able to exit and re-enter into DisplayPort mode, Thunderbolt mode with passive cable and thunderbolt mode with active cable. Change-Id: If1e48e9f31cd678e23fe89bd3494551b5d1a78f1 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415082 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Return valid enum value before TC initDiana Z2020-10-141-2/+9
| | | | | | | | | | | | | | | | | | | | | | | Protect ourselves against using junk TC states by defaulting to returning our state as the state count before our context is set. Otherwise, on systems where the EC sysjumps during flashing we may allow PD host commands to attempt indexing the names array with a bad value. This also removes the build-time check that every state name has a corresponding entry in the states array. BRANCH=None BUG=b:170326170 TEST=on waddledoo, detach sub-board to ensure C1 init takes a long time and run "ectool usbpd 1" while sysjumping the EC. Verify the EC doesn't crash and instead reports the state as an empty string Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I478613edd165c2de650fe80813ec05a9a03ba087 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2463752 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: check active cable SVID supportli feng2020-10-131-3/+18
| | | | | | | | | | | | | | | | | According to TBT4 PD flow, SOP' discovery SVID should support USB_VID_INTEL to enable Thunderbolt Alt mode. BUG=none BRANCH=master TEST=1. Volteer EVT connects to TBT dock with TBT passive cable, EC can enter TBT mode 2. Volteer EVT connects to TBT dock with TBT active cable which supports SVID USB_VID_INTEL, EC can enter TBT mode. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I10e16bff89175fe8425a6c7afc31141a6a5d573f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2441962 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* npcx: allow hibernate timeout when LCT is availablestabilize-13532.B-masterCaveh Jalali2020-10-131-1/+2
| | | | | | | | | | | | | | | | The npcx9 supports LCT (long countdown timers). When enabled, hibernate can wake up using the LCT module. BRANCH=none BUG=b:144427579,b:165777478 TEST=verified error message is present on volteer but not on npcx9_evb binary. Signed-off-by: Caveh Jalali <caveh@chromium.org> Change-Id: Id154153fa1a44b538bce1e3e752ea78b199befa6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2454985 Reviewed-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* npcx9: support SHA256 hardware acceleratorCHLin2020-10-132-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | There is the hardware accelerator for SHA computation inside npcx9. This CL wraps the Nuvoton SHA library APIs (which are in the ROM) to Chromium EC's SHA256_* APIs to speed up the SHA256 computation. With the help of the hardware accelerator, the hash computation runs several times faster than the software method (see b:155771688 for more detailed evaluation data.) Also, we can gain ~840 bytes of code size. BRANCH=none BUG=b:165777478 BUG=b:155771688 TEST=pass "make buildall" TEST=flash the same RW image; #define/#undef CONFIG_SHA256_HW_ACCELERATE ; verify the RW hash value is the same in the console message. TEST=with the following test CL, move test patterns in test/sha256.c to board/npcx9_evb/test_sha256.c; pass all test patterns. Signed-off-by: CHLin <CHLin56@nuvoton.com> Change-Id: I45ca609889bd73573d67d15f3e561614201e60f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2455021 Tested-by: CH Lin <chlin56@nuvoton.com> Auto-Submit: CH Lin <chlin56@nuvoton.com> Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: caveh jalali <caveh@chromium.org>
* usbc_ppc: inform the PPC of the power role of the connected deviceEric Yilun Lin2020-10-083-16/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On some of the PPC (e.g. syv682) that support manually force discharge function doesn't automatically turn off discharge FET when VBUS meets vSafe0V. The original flow is disabling discharge on pd_set_power_supply_ready and enabling discharge on pd_power_supply_reset, and since there is no automatic turning off the discharge circuit, the FET will still be on when a SNK device connected. We fix this by informing the PPC on a device is connected or disconnected so that PPC can control the FET by requests. BUG=b:160548079, b:148870148, b:163143427 TEST=make buildall TEST=TCPMv2: on asurada C0/C1(syv682) and volteer C0(sn5s330)/C1(syv682) port, and enable force discharge mode (CL:2423665), plug sink and source device and ensure Vconn and Vbus are off within tVconnOff and tVBusOff respectively. Plug a DRP hub and then plug adapter in it, and it meets tVconnOff and tVbusOff. TEST=TCPMv1: tested the same steps as above on Asurada. BRANCH=NONE Change-Id: I8ed0e18fce2d402ff24fce6bab393cc618dfac09 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2434590 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Eric Herrmann <eherrmann@chromium.org>
* TCPMv2: Select Capability REQUEST discard handlingDenis Brockus2020-10-071-1/+11
| | | | | | | | | | | | | | | | | | | The sent REQUEST message was discarded. This can be at the start of an AMS or in the middle. Handle what to do based on where we came from. 1) SE_SNK_EVALUATE_CAPABILITY: sends SoftReset 2) SE_SNK_READY: goes back to SNK Ready BUG=b:170259288 BRANCH=zork TEST=Monitor mentioned in parent bug should not Vconn Swap loop Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I8665215bb9b9d363b82d23cae90b9f3c5617b7a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2454970 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* Keyboard: Add AP wakeup to PS2 trackpoint interruptJosie Nordrum2020-10-071-0/+5
| | | | | | | | | | | | | | | | | | | | | Wake up AP for PS2 interrupt using Device Event as trigger. AP must have device event wakeup mask enabled and board must select CONFIG_DEVICE_EVENT in EC. This device event is only triggered when the chipset is suspended to avoid triggering SCIs in S0. BUG=b:160345665 BRANCH=Zork TEST=Wake from S3 by trackpoint Signed-off-by: Josie Nordrum <josienordrum@google.com> Change-Id: Ia431525ee8f572922c8f9bfe613d44e83308d9f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2430288 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org>
* Fix incomplete rename (deprecated_atomic_clear -> deprecated_atomic_clear_bits)Jack Rosenthal2020-10-061-1/+1
| | | | | | | | | | | | | | | | CL:2428943 renamed deprecated_atomic_clear to deprecated_atomic_clear_bits, but missed these two cases, as they landed thru CQ after CL:2428943 passed the dry run. BUG=b:170132568 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I6fff582b2cf8dbf77bc8a136bc7fa81af30b2cc0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2452889 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Sean Abraham <seanabraham@chromium.org>
* core: rename atomic_clear to atomic_clear_bitsDawid Niedzwiecki2020-10-0612-40/+43
| | | | | | | | | | | | | | | | | | Change the name of atomic_clear to atomic_clear_bits to make to name more clear - the function clears only selected bits, but the name may suggest that it clears the whole variable. It is done as a part of porting to Zephyr, where atomic_clear zeros the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I7b0b47959c6c54af40f61bca8d9baebaa0375970 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2428943 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add event clear to TYPEC_CONTROLDiana Z2020-10-051-0/+3
| | | | | | | | | | | | | | | | | When the AP has finished processing events, it can use TYPEC_CONTROL to clear the specific events it has completed. This also fixes an issue with the control command structure byte alignment. BRANCH=None BUG=b:148816435 TEST=on waddledoo, plug in Apple dongle and clear SOP discovery event with "ectool typecontrol" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I38d522f346bfd500b72109db46f78a9c135ce96e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432457 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Notify on SOP and SOP' discovery completeDiana Z2020-10-051-0/+21
| | | | | | | | | | | | | | | | | | | | | Notify the AP when the task has finished discovery. The AP doesn't need notification if nothing was found, but does need notification by transmit type as long as at least DiscoverIdentity was returned. BRANCH=None BUG=b:148816435 TEST=on waddledoo, verify: - events are 0 with nothing plugged in - events show SOP complete with Apple dongle - events show SOP and SOP' complete with TBT dock - events show SOP complete with Moshi (DiscoverIdentity only) - events show SOP complete with WooHub (Mode discovery will NAK) Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5fcfc1ba2bde40c70400462dcc4efc2b7b60d0ca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432456 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add events to TYPEC_STATUS host commandDiana Z2020-10-051-1/+3
| | | | | | | | | | | | | | Add retrieval of the event bits to the TYPEC_STATUS host command and ectool output. BRANCH=None BUG=b:167700356 TEST=on waddledoo, verify events show up in "ectool typecstatus" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If9f4f9b56acb6108c5f87f0d2ddf7a7d945f9403 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432455 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add framework for per-port eventsDiana Z2020-10-051-0/+31
| | | | | | | | | | | | | | | The AP would like to retrieve events on a per-port basis, so add new tracking for those events, as well as the capability for non-PD tasks to retrieve and set those events. For the moment, the code just clears events on startup and event flags will be added in subsequent CLs. BRANCH=None BUG=b:148816435 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I9c2644141b4f5277ee54b4bf2c30087b51a87d8e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432454
* TCPMv2: Add TYPEC_STATUS commandDiana Z2020-10-051-0/+38
| | | | | | | | | | | | | | | | | | | | | | | The TYPEC_STATUS command will be deprecating the informational return from the USB_PD_CONTROL host command. It brings over the enablement, role, and connection information from the older command. Cable specifics are excluded as they are redundant with the discovery return. Information about the mux state is also added for convenience. Additionally, this moves enums and defines which are a part of our overall pd_* API to the ec_commands.h file to ensure consumers have the same field values available for interpretation as the EC. BRANCH=None BUG=b:167700356 TEST=on waddledoo, plug in chargers and dongles and ensure outputs from "ectool typecstatus <port>" match "ectool usbpd <port>" and "ectool usbpdmuxinfo" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ic7afc0b282b88fdb34cb9a6feef22ad913bb4aae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432452 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* charge_ramp: Don't use SW ramp for USB-C chargersEdward Hill2020-10-031-2/+7
| | | | | | | | | | | | | | | | | Don't use SW ramp for USB-C chargers (CHARGE_SUPPLIER_PD and CHARGE_SUPPLIER_TYPEC) since the slow ramp causes issues with auto power on. This means we rely on the chargers to be able to supply the full current they advertise. BUG=b:169634979 b:163864475 b:167257846 BRANCH=zork TEST=cutoff battery, plug ac, boot to OS Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I9b7ae79ebcfdf0e8b8b136555a907eef423361ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2445462 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* Revert "TCPMv2: Set mux state on updating partner's USB comm capability"Keith Short2020-10-031-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 181f23c9863e3350cb52c6e04490fbebd60e37eb. Reason for revert: The original change causes bugs b:169346513 and b:169935734 Original change's description: > TCPMv2: Set mux state on updating partner's USB comm capability > > On updating the port partner's USB communication capability, the mux > should also be configured into USB/disconnect mode accordingly. Hence, > this CL sets the mux setting according to the partner's USB capability. > > BUG=b:157163664 > BRANCH=None > TEST=Able to update the mux state on updating the port part USB comm > capability. > > Signed-off-by: Ayushee <ayushee.shah@intel.com> > Change-Id: Ic2d27e2a0af6dad54a875a589b85f8a5d583b5b4 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2388972 > Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> > Reviewed-by: Keith Short <keithshort@chromium.org> BUG=b:169346513, b:169935734 BRANCH=none TEST=connect servoV4 to Volteer, confirm USB devices shown in kernel TEST=connect PD charger to port C1, verify charging starts Change-Id: I7bfda36a52aaa80c3faae1ab44b8b431431a2b97 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2445453 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Revert "TCPMv2: Correct setting mux state on updating partner's USB comm"Keith Short2020-10-031-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit c370d201003e44f1a4a6a483903bbbe065664ee1. Reason for revert: The original change causes bugs b:169346513 and b:169935734 Original change's description: > TCPMv2: Correct setting mux state on updating partner's USB comm > > When the USB communication capabilities are enabled and if the port > receives partner's USB communication capability again after entering > an alternate mode, mux doesn't need to be updated. Hence, only the > mux with port partner's USB communication capability if it is in > disconnect state > > BUG=b:168453520 > BRANCH=None > TEST=Able to retain mux's state after entering a mode. > > Signed-off-by: Ayushee <ayushee.shah@intel.com> > Change-Id: I26af254b341c9f0c1cdc4369a50e16f9da329faf > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2407014 > Reviewed-by: Keith Short <keithshort@chromium.org> BUG=b:169346513, b:169935734 BRANCH=none TEST=connect servoV4 to Volteer, confirm USB devices shown in kernel TEST=connect PD charger to port C1, verify charging starts Change-Id: I11f0d5d2f944047d810a445a1dbcfd2cbe88e223 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2445452 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* npcx psl: reject hibernate request with timeoutCaveh Jalali2020-10-021-2/+7
| | | | | | | | | | | | | | | | Some Nuvoton NPCX chips support PSL (power state logic) to put the chip in a very low power state. When this feature is utilized, the alarm feature is off, thus it is not possible to hibernate for a specific period of time. Reject CLI requests to do so. BRANCH=none BUG=b:144427579 TEST=verified non-zero timeout is reject on volteer Change-Id: I17537b4724f03bd8f58ee81b80e374629c8b9b88 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2442037 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add VBUS_REMOVED levelDiana Z2020-10-012-5/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | For boards which use Vbus ADCs, add a VBUS_REMOVED check level. The level for VBUS_PRESENT should be used in any locations looking for "Vbus is present" on transition, but in order to correctly detect disconnection with a load on Vbus, VBUS_REMOVED (vSinkDisconnect) is required. TODO statements have been added for places where work will be needed to support vSinkDisconnectPD in the future. For boards detecting Vbus through an external chip, the levels will likely be indistinguishable due to the chips setting a lower threshold for disconnect than for connection. Unit test code has also been added to encourage new Vbus levels to be added to the mock, and remind developers to update all locations using the vbus_level enum. BRANCH=None BUG=b:168831161 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I04014ce54ec162dd9c62f545126d921c6d880741 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2436580 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: shim in the timer moduleJack Rosenthal2020-10-011-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | This enables building timer.c in the Zephyr shim. In addition, we provide definitions for the symbols __hw_clock_source_read64 and __hw_clock_event_get defined for Zephyr to provide times to the CrOS EC. The event timer does not make sense for Zephyr code, but we need it defined to prevent link errors (timerinfo uses it). Perhaps the solution to this is to add a new config option (e.g., CONFIG_EVENT_TIMER) which can be used to selectively enable/disable the event timer in the CrOS EC. But punting this work for now and just adding a fake definition. BUG=b:167590251 BRANCH=none TEST=compile for posix-ec, run gettime and timerinfo commands Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I58990a6295625f9c34ec080360470431b46155bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427100 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Fix dereferencing a NULL pointerWai-Hong Tam2020-10-011-2/+4
| | | | | | | | | | | | | | | | | | | Some monitors or dongles may not follow the spec that sends a 'DP Status' VDM to the Chromebook. The 'DP Status' VDM is supposed to send from a DP source, not a DP sink. When the Chromebook receives this message, the dereference of a NULL pointer is triggered and EC crashes. Should ignore this assignment and leave it NULL so the Chromebook later NACK's the VDM message. BRANCH=None BUG=b:169611334 TEST=Build the image. Change-Id: I7bf80229be0c6ca20aa1eac63db762b3e4a9d683 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2437189 Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* common/panic_output: Use newly introduced functions for panic info dumpPatryk Duda2020-10-011-9/+27
| | | | | | | | | | | | | | | | This patch adds use of function that provides pointer to the beginning of panic data in panic info host command. It also adds use of panic_get_data() in panicinfo command to get pointer that can be safely dereferenced. BUG=b:165773837, b:162254118 BRANCH=none TEST=make -j buildall Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I403300f796fc2add4fae06728d7da4e43616ef2d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379847 Reviewed-by: Jett Rink <jettrink@chromium.org>
* common/system: Use beginning of panic data for calculationsPatryk Duda2020-10-011-1/+1
| | | | | | | | | | | | | | | | panic_get_data() function in some cases doesn't return the beginning of panic data. We should use get_panic_data_start() BUG=b:165773837, b:162254118 BRANCH=none TEST=Compile firmware. Flash EC RW on eve. while running RW firmware issue 'crash watchdog' command. Check if RW properly reports that reset cause was sysjump. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I2c0a7e4555b8c2e43487222d2d6c4500448ac80d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379846 Reviewed-by: Jett Rink <jettrink@chromium.org>
* charge_state_v2: Move the first battery_get_params to HOOK_INITWai-Hong Tam2020-09-301-1/+5
| | | | | | | | | | | | | | | | | | Other tasks read the params like state_of_charge at the beginning of their tasks. In the existing code, the first battery_get_params is called at the beginning of the charger task. It is not guaranteed the battery params are ready. This change moves it to the HOOK_INIT. BRANCH=None BUG=b:169453974 TEST=Cut off the battery, checked the first boot has PD-enabled, which uses the battery state_of_charge param to make the decision. Change-Id: Ie7bd31ee71fb3d1ea47a31910f0dfa7ac93cbcef Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2436760 Tested-by: Nitin Kolluru <nkolluru@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* button: presss volume button detected by adcBen Chen2020-09-291-1/+7
| | | | | | | | | | | | | | | supports volume up/dwon pressed by adc buttons config BUG=b:167319238 BRANCH=master TEST=make buildall pass Change-Id: Ide3522b4af3c92df906bafb1f944f138a822280a Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2431310 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* tree: rename atomic_* functions to deprecated_atomic_*Jack Rosenthal2020-09-2918-99/+125
| | | | | | | | | | | | | | | | We will move to an API compatible with Zephyr's API. See the bug for complete rationale and plan. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* common: body_detection: modify calculation of noise levelChing-Kang Yen2020-09-291-1/+10
| | | | | | | | | | | | | | | | | | | We used rms_noise^2 as noise level for body_detection. But, there are still some different noise level based on different devices. Add the CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR to adjust the noise_level. Default value is 120%, since the 100% of the rms_noise^2 is not enough, especially in 200Hz. BRANCH=None BUG=b:123434029 TEST=make buildall; make BOARD=ampton, re-flash the DUT, see if the body detection works Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I2a7416b0bd8d0aac51d16c3aed9d962837f52c0b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2416477 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* ocpc: Misc fixes for coming out of cutoffAseda Aboagye2020-09-281-17/+24
| | | | | | | | | | | | | | | | | | | | | This commit fixes a bug in how OCPC determined which portion of the charge curve that we are in. Upon startup, the phase is uninitialized and we get a charge_request of 0,0. The code assumed that if the battery voltage was less than the desired voltage, we'd be in the CV state. But ignoring a zero desired voltage prevented us from assuming we're in CV. BUG=b:168135339 BRANCH=None TEST=Build and flash drawcia, cutoff the battery, wait 15s, plug in a charger on C1, verify that the DUT comes out of cutoff. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Id5f36d701c2d4e1608954c898c5bc4f0010dec1d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2431695 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* ocpc: Miscellaneous fixesAseda Aboagye2020-09-281-13/+23
| | | | | | | | | | | | | | | | | | | | | | | | This commit just performs some miscellaneous fixes for OCPC. Some key fixes are: - Fix handling of full batteries with respect to CFET status - Reducing upward transitions - Restrict system resistance calculations to high current scenarios only. BUG=b:168135339 BRANCH=None TEST=Build and flash waddldee with new PID constants, drain battery, verify DUT can charge from the sub board port all the way to full, verify DUT can source out the main board port while charging from the sub board. Verify that the charging curve is fairly stable. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Id170b1c5dfe56733f4ebcf350bf96d0de59e3ec4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2411467 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* ocpc: Add visualization graphAseda Aboagye2020-09-281-3/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When tuning an OCPC system, the OCPC debug output is very useful in order to examine the behaviour of the system. However, instead of simply looking at a bunch of changing numbers on the terminal, it's easier to view a waveform of the current entering the battery. In lieu of using an oscilloscope with a current probe, this commit adds a visualization graph which shows the current entering the battery relative to the target current. Each segment on the graph represents 5% of the target current. Usage is as follows: > ocpcdebug enable/viz/all/disable `enable` will show text debug only. `viz` will show the visualization graph (output shown below). `all` will show both the graph and text debug data. `disable` will show no debug output. Here is an example of the output [2665.199505 Act Chg: 1] [2665.702271 Battery 47% (Display 47.1 %) / ??h:?? to empty] [2665.703810 charge_request(13050mV, 1800mA)] [2665.725854 OCPC: Target VSYS: 11979mV] [----------#----------] (actual)251mA (desired)1880mA [2666.317342 OCPC: Target VSYS: 12179mV] [----------|---------o] (actual)879mA (desired)1880mA [2666.908941 OCPC: Target VSYS: 12274mV] [----------|-----o----] (actual)1216mA (desired)1880mA [----------|o---------] (actual)1631mA (desired)1880mA [2668.090373 OCPC: Target VSYS: 12259mV] [----------#----------] (actual)1797mA (desired)1880mA [----------#----------] (actual)1813mA (desired)1880mA [----------#----------] (actual)1769mA (desired)1880mA [----------#----------] (actual)1779mA (desired)1880mA BUG=None BRANCH=None TEST=Build and flash waddledee, enable debug command, verify that visualization graph is shown. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Ie271524ce2ce90781b966a77f2a7ef27dc969075 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2410556 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: David Schneider <dnschneid@chromium.org>
* TCPMv2: Always disable Vconn in CC OpenDiana Z2020-09-251-2/+1
| | | | | | | | | | | | | | | CC Open will run on most inits, so don't rely on the Vconn flag to trigger its disable. BRANCH=None BUG=None TEST=on waddledee, manually sysjump with a sinking dongle plugged in and ensure Vconn is turned off during Open Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ib7bb1cff66d939631b445c042bb4a41e1043f914 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2424704 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Ensure previous Vbus is turned off on initDiana Z2020-09-251-2/+7
| | | | | | | | | | | | | | | When we boot from reset, other board components may still be sourcing out to partners. Ensure these are turned off during init time. BRANCH=None BUG=b:168931726 TEST=on waddledee, EC reset with servo attached as a sink and ensure DUT is able to start sourcing to servo Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5a5de7f510ce81307c7155659a03f401eac3a885 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2424703 Reviewed-by: Jett Rink <jettrink@chromium.org>
* fpsensor: Fix buffer check to account for overflowTom Hughes2020-09-252-4/+15
| | | | | | | | | | | BRANCH=none BUG=b:144957935 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I1b4fa0a715869ccc37e48d75316ef52c367aa64a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2417529 Reviewed-by: Craig Hesling <hesling@chromium.org>
* lid_angle: Disable peripherals in S3 in tablet modeEdward Hill2020-09-251-0/+13
| | | | | | | | | | | | | | | | | | | Add a HOOK_CHIPSET_SUSPEND to call lid_angle_peripheral_enable(0) when in tablet mode. Usually lid_angle_update() calls lid_angle_peripheral_enable() in both S0 and S3 but this stops if LID_ANGLE_UNRELIABLE, which can allow peripherals to remain enabled in S3, which then causes eg unwanted wake from keyboard in tablet mode. BUG=b:167933375 BRANCH=zork TEST=S0, tablet mode, S3, press keyboard, stays in S3 Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I6abc425993ad9eb10e97437708edd9edb45b6941 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2429211 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* common: include console_channel.inc to be relative to include/Jack Rosenthal2020-09-241-1/+1
| | | | | | | | | | | | | | "include/" is unnecessary in the front of these include paths since -Iinclude/ is already in the compiler flags. BUG=b:167590251 BRANCH=none TEST=compiles Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I9b815b9d190d3a1b16fe67c0e99199b1001648bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427087 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usb_pd: Add common function to get PD revisionli feng2020-09-232-21/+32
| | | | | | | | | | | | | | | Add common function for both TCPMv1 and TCPMv2 to get PD revision Modify TCPMv1 pd_get_vdo_ver() to get correct cable VDO version BUG=none BRANCH=none TEST=make buildall Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I7cc597a45e9581346683b7af54894bffb48d16bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2420468 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zork: Ignore input current and always rampEdward Hill2020-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | CONFIG_CHARGE_RAMP_SW is designed to stop ramping if we are not using enough current (so we are actually testing that the supplier can give the current we ramp to). But this is checked using charge_is_consuming_full_input_current(), which only tests for battery charge between 2% and 95%. This fails to accurately reflect desire for input current, because the low battery might want to charge faster, and the AP might want extra power even with full battery. For zork, change charge_is_consuming_full_input_current() to always return true. This means we will always ramp. If we are not using the full input current, and the supplier cannot deliver it when we do, then we will detect the voltage drop and re-ramp, which seems fine. BUG=b:168569046 BRANCH=zork TEST=ramp with full battery Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Ic7c9b93bdd3856c9b05bd3a13e8c2a78aa883755 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2426950 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: require init_vdm_mode ack response svid == requested svidDenis Brockus2020-09-231-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | If an INIT VDM ACK response SVID is not equal to the requested SVID then treat this as a NAK This is being seen on the Lepow monitor I was testing on. The sequence looked as follows: DUT: REQ SVID=DP MON: ACK SVID=DP DUT: REQ SVID=Nintendo MON: ACK SVID=DP BUG=b:169077500 BRANCH=none TEST=Lepow monitor should not infinite loop on INIT_VDM Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I55210588494fdc09ed8f3551569262d70ba63277 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2426122 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* host_event_commands: Return access denied for prohibited accessDaisuke Nojiri2020-09-221-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | Currently, EC_CMD_HOST_EVENT returns the same error code for non-existing masks and prohibited access to the existing masks. This patch makes the command return ACCESS_DENIED for the latter case so that the host can distinguish the two cases. ToT BIOS won't be affected because the EC's return codes are collapsed to -1 or -(request size). $ ectool hostevent set 1 0 Set isn't permitted for mask 1. BUG=b:168939843 BRANCH=None TEST=Verified on Atlas. See above. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ia346dbffd459985d5eea8a955e22822d402d5388 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2422805 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
* test: Add test_send_caps_error to usb_pe_drpEdward Hill2020-09-223-22/+67
| | | | | | | | | | | | | | | | | As requested in CL:2321869 review, make a new version of test_send_caps_error that uses the external interface of the PE layer. BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I983b145cd1e731e844363955896898a2374a0a30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2419834 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* TCPMv2: Define typeccontrol host commandAbe Levkoy2020-09-214-0/+37
| | | | | | | | | | | | | | | For now, just support exiting the entered mode, if that mode happens to be DisplayPort (getting TBT3 and USB4 to work correctly will require some more work). Support this command in ectool. BUG=b:168030639 TEST=ectool typeccontrol 0 1; observe DP Exit Mode exchange in PD trace BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ib30479cc88696115060e9ff74f6815ce074e6bf5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415069 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Move DPM requests to public APIAbe Levkoy2020-09-214-23/+22
| | | | | | | | | | | | | | | | It is safe (atomic bit ops) and will soon be necessary (new host commands) to send DPM requests from outside the PD tasks. Rename pe_dpm_request to pd_dpm_request and move the declarations into usb_pd.h to reflect this. BUG=b:168030639 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ied43e9f6973a3172b98090cc068a607257dce21b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415068 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tcpmv2: don't call tc_partner_usb_comm if in an alt-modeDenis Brockus2020-09-191-4/+7
| | | | | | | | | | | | | | | | BUG=b:168805145 BRANCH=none TEST=Ikling hub unattached power to powered with HDMI attached Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ie3bfce1d6159d93df5c646fcfa00e4b7e51eb4b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2419176 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* USB-PD: Continue mode discovery after failureDenis Brockus2020-09-191-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pd_get_next_mode was searching the svid_mode_data looking for the next entry to discover, if there are any. Failed and needs discovery were handled the same way, return that entry. So if you had a discovery entry that fails that gets returned and causes the entry to stop, over and over again This issue was found using an ikling hub with attached AC connected to Morphius the SVID discovery finds two SVIDs, DP and Nintendo. The Nintendo fails and this caused the alt-mode to not enter for the valid DP mode. The change is to continue discovery even if there is a failure discovered. If any of the modes succeeded then it will be considered success if there are no new modes to discover. This is the order of returned values: no entries -> successful. an entry that need to be discovered -> return discovery entry. everything discovered properly in the list -> successful. discovered some good and some failed -> successful. all discovered fail -> return first fail. BUG=b:168804124 BRANCH=none TEST=verify morphius monitor when attached ikling powered hub Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Id2064079614c276f3d2054c5bcb194cdb997514c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2416990 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: set object position in SVDM response headerli feng2020-09-181-0/+7
| | | | | | | | | | | | | | | | | | | | | Per PD 6.4.4 about Object Position, on receiving Enter Mode request, the responder shall set the offset of mode entered in Object Position field, and it shall be the same value as that in request; on receiving Exit Mode request, the responder shall set the offset of the mode to be exited in Object Position field, and it shall be the same value as that in request. This field shall be set to zero in the request or response(REQ, ACK, NAK or BUSY) when not required by specification of the individual command. BUG=b:148528713,b:157163664 BRANCH=none TEST=make buildall -j 4 Signed-off-by: li feng <li1.feng@intel.com> Change-Id: Icf68d003abb9f1ab9f71fb0646c5e3fb1c5f644a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2399775 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>