summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: Rename pd_can_source_from_deviceDiana Z2021-06-051-6/+6
| | | | | | | | | | | | | | Clarify the function name by changing it to "can charge from" since "source from" isn't a generally common phrase in PD terms. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Id7a40ac9d8d4c0007e8ff6cb25c2e8c2d006df0c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2923239 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* COIL: espi: replace VW_SLAVE_BTLD_STATUS_DONE with ↵Caveh Jalali2021-06-041-1/+1
| | | | | | | | | | | | | | | | | VW_PERIPHERAL_BTLD_STATUS_DONE This replaces VW_SLAVE_BTLD_STATUS_DONE with VW_PERIPHERAL_BTLD_STATUS_DONE. BRANCH=none BUG=b:163885307 TEST=buildall, compare_build.sh pass Change-Id: I0b8c71fa7e590dc89357e22aafce0b67717af183 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2938041 Reviewed-by: Harry Cutts <hcutts@chromium.org> Commit-Queue: Harry Cutts <hcutts@chromium.org>
* TCPMv2: Don't delay ready transition turning off VconnDiana Z2021-06-041-16/+3
| | | | | | | | | | | | | | | | | | Since Vconn is make before break, it makes no sense to delay transitioning back to ready since Vconn isn't discharging. Waiting extra time in the state translates to taking more time to process the next messages after a Vconn swap. BRANCH=None BUG=b:181087216 TEST=on storo, confirm that we don't miss replying to PR swap following a Vconn swap connected to another DUT Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I0d551d0cac34f8157c7fe2b272c2450d6da3ca17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2937108 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* chgstv2: Call board_check_extpower on AC changeAseda Aboagye2021-06-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Some boards don't have an interrupt which indicate that extpower is present or not. In some cases, the EC may miss an edge if the call comes to early to check whether AC is ok. However, the charger task periodically polls this state. This commit has the charger task call `board_check_extpower` when it notices that the AC presence has changed. This can ultimately end up triggering the HOOK_AC_CHANGE hook. BUG=b:189911786 BRANCH=dedede TEST=Build and flash boten, plug in charger, suspend DUT, unplug DUT, verify that DUT wakes up even after the first call to check AC OK occurs. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Id0b60289cfb14509fd781942afbcedfa9e127a8a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2937738 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* tcpmv2: Don't enable USB mode until PD state resolvedKeith Short2021-06-034-1/+32
| | | | | | | | | | | | | | | | | | | | | | Don't enable USB superspeed signals until the PD capability is known. This fixes an issue where platforms that enable the virtual USB mux violate the tSenderResponse timeout when the attached SRC sends the Source Capabilities message. BUG=b:187796705 BRANCH=none TEST=Volteer - connect PD charger, obsserve no hard reset TEST=Connect non-PD USB device, verify USB mode is enabled TEST=Connect USB+DP monitor, verify DP mode entry and USB mode enabled TEST=Connect USB4 dock, verify USB4 entry TEST=faft_pd test suite passes on Voxel Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I4be08874178d1e225cf41939b9626a81b0da0524 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2895424 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: caveh jalali <caveh@chromium.org>
* PD console: add cflush around long console printsBoris Mittelberg2021-06-031-0/+5
| | | | | | | | | | | | | | | | | `pd state` and `pd dualrole` command outputs are non-atomic and even have function calls in the middle of lines. This caused the output to be mixed with non-related prints, and FAFT is sometimes failing to parse the needed lines. Wrapping those commands with `cflush` reduces output corruption. BRANCH=none BUG=b:188881690 TEST=running FAFT PD Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I0750df0b1ce0bb52b96718769626ca8e2e1b55c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2932456 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* charge_state_v2: clear charger current after adapter outqinwentao2021-06-031-0/+7
| | | | | | | | | | | | | | | | | | For RAA48900 chip, charge current will affect the Type-C output,so we shall clear charger current after adapter out. BUG=b:187967523 BRANCH=dedede TEST=make BOARD=storo pass Signed-off-by: qinwentao <wangganxiang@huaqin.corp-partner.google.com> Change-Id: I66ff83144ef6f40e5772079b9fe5e6d157728796 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2921971 Reviewed-by: Mike Lee <mike5@huaqin.corp-partner.google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Mike Lee <mike5@huaqin.corp-partner.google.com> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* battery_fuel_gauge: Check length of device stringAseda Aboagye2021-06-031-1/+4
| | | | | | | | | | | | | | | | | | | | | In the common battery fuel gauge framework, the boards may specify strings for the expected battery packs to be used at runtime. Some specified battery strings may be shorter than what is provided by the fuel gauge as the later portion of the string can vary according to lot code and/or manufacture date. This commit simply checks up to the length of the string provided by the board in order to find a match. BUG=b:183875170 BRANCH=dedede TEST=Build and flash a dedede device, verify that the battery can be found. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Ib1c4690ca2b676e6e019015c4dec1d57899479b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2934659 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* COIL: spi_nor: Rename spi_master to spi_controllerCaveh Jalali2021-06-031-18/+20
| | | | | | | | | | | | | | | This renames the spi_master struct member of spi_nor_device_t to spi_controller. BRANCH=none BUG=b:163885307 TEST=make buildall passes; "compare_build.sh -b all" shows no difference Change-Id: I446de6e60fa1e4dfa1266dca04d851fbfb6c250b Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2932467 Reviewed-by: Harry Cutts <hcutts@chromium.org>
* zephyr: Don't reinitialize gpios on a warm rebootSam Hurst2021-06-031-11/+16
| | | | | | | | | | | | | | Don't reinitialize gpios on a warm reboot BRANCH=none BUG=b:187337449,b:186458444 TEST=Verified that the system booted properly Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ie11bdde9fa0124c0bf21cdc9baa3a98a85bbdad2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2904549 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* Remove CONFIG_BATTERY_DEAD_UNTIL_VALUEDaisuke Nojiri2021-06-011-4/+0
| | | | | | | | | | BUG=none BRANCH=none TEST=buildall Change-Id: Iebf0817c1b605d74348c9b20c01df74bd69468d2 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929338
* TCPMv2: Re-enable SOP' transmission on interruption to Vconn swapDiana Z2021-06-011-25/+39
| | | | | | | | | | | | | | | | | | | | | If a Vconn swap is interrupted before we receive a PS_RDY from the partner, re-enable SOP' transition. Note this doesn't matter for the case of no PS_RDY received as we'll proceed to hard reset which will also reset our Vconn role. This is primarily applicable if the interruption is for an unexpected message, which interrupts the swap and leaves us the Vconn source. BRANCH=volteer BUG=b:186886218 TEST=on drobit, ensure cable entry doesn't fail after failed Vconn swap with dock Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I952c04535ae9527f07cb203c403a51182c67cba7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2881020 Tested-by: Benson Leung <bleung@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Exit Attached.SRC on open even during swapDiana Z2021-05-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | If a port doesn't clear the PR swap in progress flag while switching from a source to a sink, the port can end up permanently stuck in Attached.SRC even when the port partner is unplugged. This removes the check to the PR swap in progress flag when Open is detected on the CC lines. This follows the type-c spec's exit conditions, and we would not expect to see CC open during a PR swap since the source sets Rd before the new source will set Rp. BRANCH=None BUG=b:158613480 TEST=on mancomb, unplugging after failed PR swap with dock allows port to go unattached again. Normal PR swap process is able to complete with dock plus servo_v4 and Apple 3-in-1 Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Idc4c193597c6b4a791d18e38bc5111d0342e512c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2256465 Reviewed-by: Scott Collyer <scollyer@chromium.org>
* base_state: implement basestate host commandTing Shen2021-05-271-3/+17
| | | | | | | | | | | | | | | | | | | | | This CL introduces an unified method to force base attach/detach, to deprecate the hard-coded gpio pin name table in hammerd/hammertests/common.py. Also modifies base_force_state to use the same parameter type as host command. BUG=b:188625010 TEST=manually, run `ectool basestate attach|detach|reset` on coachz BRANCH=trogdor,kukui Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I5235661727cbbd15015c49d588ec70605e4a33e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2910472 Reviewed-by: Wai-Hong Tam <waihong@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* TCPMv2: PE: Don't set AMS flag unless custom VDM has a replyScott Collyer2021-05-271-4/+6
| | | | | | | | | | | | | | | | | | | | This CL fixes an issue related to PE_FLAGS_INTERRUPTIBLE_AMS which was being set in pe_handle_custom_vdm_request_entry whether the custom VDM request is supported or not. This would result in PE_FLAGS_INTERRUPTIBLE_AMS remaining set and ignoring of subsequent VDM messages, which in turn prevents ALT-DP entry for UFP case. BUG=b:189293176 BRANCH=quiche TEST=Verfied that with this fix, ALT-DP mode is entered consistently. Without this CL, ALT-DP mode is not entered correctly. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I7a52a6028ea656d9a1970fea0b42f582f1aaff5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2677707 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Enable logging of CCD line stateudaykiran2021-05-271-0/+17
| | | | | | | | | | | | | | This CL logs the CCD line state of CCD_MODE_ODL upon DP-Altmode entry. BUG=b:170895220 BRANCH=none TEST=make buildall -j and verify that images build successfully. Signed-off-by: udaykiran <udaykiran@google.com> Change-Id: Iabee1a16e2497fd4ada2c2c06b65bef9d5ab1593 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2915756 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_common: Assert CCD_MODE when DTS connectedRob Barnes2021-05-262-2/+47
| | | | | | | | | | | | | | | | | | Drive CCD_MODE_ODL from EC when EC sees DTS connected to CCD port. This will fix some cases where the Cr50 is not able to detect that a CCD debug cable has been connected. BUG=b:175056327 TEST=Connect/disconnect SuzyQ cable, see assert/unassert in log Check gpioget on CR50 and ec, confirm CCD_MODE_ODL is correct Connect/disconnect charger, do not see assert/unassert in log Repeat with ServoV4 BRANCH=None Change-Id: I411e75a47f2e1303ddbd9caa63a9417630c99b46 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2659282 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Clear pending DPMs during port discovery requestDiana Z2021-05-251-1/+3
| | | | | | | | | | | | | | | | | If there is a pending VDM send during the processing of DPM_REQUEST_PORT_DISCOVERY, then the VDM send and ACK may leave the DP module in an inconsistent state. Avoid this state by clearing any pending VDM sends at this time. BRANCH=None BUG=b:182237701 TEST=on mancomb, plug in a dock in G3 and power up to S0 repeatedly, ensuring that we can enter DP mode every time Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I2223ed431df97821a177e9a030b53f6310a1faf8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2912114 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* usb_port_power_dumb: allow board to customize hooksTing Shen2021-05-251-1/+3
| | | | | | | | | | | | | | | | | | | | On Asurada, some Sandisk stickers would enter fault status (down-train to USB2 or not detected) if Vbus is applied before xhci initialization. The defauilt S3 hooks does not work in this case. This CL adds a config option to allow board to control the timing to enable/disable port power. BUG=b:187149602 TEST=manually test with CL:2909972 BRANCH=asurada Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I2ac4689182f22f4fa81d34bff8b5797e5fe222d2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2914482 Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* USBC: Disallow Try.SRC when not togglingDiana Z2021-05-211-2/+2
| | | | | | | | | | | | | | | | | | Chromeboxes may Try.SRC when a dedicated charger is present. However, they should not Try.SRC at a time when they are note dual-role toggling. This likely represents a time when they are unable to source Vbus and should therefore not attempt to become the source. BRANCH=None BUG=b:188710940 TEST=on mancomb, power on with the BJ charger and then connect a dock in G3. Observe we do not attempt to source the dock sans Vbus Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia9062f8f833d678b5b3c9daf576dc6ad2f2a8c74 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2912113 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Seed the charge manger in Attached.SRCstabilize-13983.B-mainWai-Hong Tam2021-05-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | When EC reboots, the TCPMv2 stack initializes the Type-C supplier in either staying in Unattached.SNK (debounced that nothing is attached to the connector) or transition to Attached.SNK (exclude the PRS case), in order to seed the charge manager. However, if the state transits to Attached.SRC from Unattached.SNK via Try.SRC. The charge manger has never been seeded. It happens when a DRP (like a Type-C hub) is attached during reboot. It may then transit to Attached.SNK through a Power-Role-Swap. However, the PRS case is excluded to seed the charge manger. This CL initializes the Type-C supplier to 0 in the Attached.SRC state. It seeds the charge manger. So all cases (Unattached.SNK, Attached.SNK, Attached.SRC) are covered. BRANCH=None BUG=b:188532782 TEST=Attach a powered Type-C hub; reboot EC; the charge manger is seeded; the charge port is selected; the power sink path is enabled. Change-Id: I8fbfc1c4ffc5c9a9a8a49fcc36d67da93d01c403 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2904562 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* charge_manager: Check extpower after charge portAseda Aboagye2021-05-191-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Some platforms don't have an extpower interrupt and therefore use the `board_check_extpower` function to determine if extpower is actually present. Any time the EC changes its charge port selection, we should re-evaluate the extpower as it likely has now changed. This commit simply does the above. Note that the default implementation of `board_check_extpower` doesn't actually do anything, so this should be a no-op for most boards. BUG=b:187965740 BRANCH=dedede TEST=Build and flash drawcia, verify that "AC on" prints are only printed when we decide to charge from a port and not just when VBUS is present Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Ib758b480a1e6f59f0f10caa1328b795726927f0b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2904546 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* dedede: Rework `extpower_is_present()`Aseda Aboagye2021-05-192-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The dedede boards erroneously assumed that if VBUS was present, then "extpower" was present. "extpower" is generally connected to the ACOK signal for the battery charger IC. It indicates that the voltage present at the switching node is valid for bucking or boosting. For our Type-C systems, this needs to be at least 4V. However, just because VBUS is present doesn't mean that the voltage is present at the switching node. The FETs on the selected charge port needs to be enabled first. This commit simply changes the logic to check the battery charger ICs' ACOK status to reflect whether extpower is present. BUG=b:187965740 BRANCH=dedede TEST=Build and flash drawcia and madoo, verify that "AC on" prints are emitted when the charge port is selected and not just when VBUS appears on the port. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: If5a4a10d502f2f08ccf1d3228e42f48fa6d45909 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2901254 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* driver: add ICM-42607 driver supportJuHyun Kim2021-05-181-0/+1
| | | | | | | | | | | | | | | | | Add ICM-42607 accel/gyro driver code. BUG=chromium:1198171 BRANCH=None TEST=ectool motionsense && CROS-EC IIO drivers Signed-off-by: JuHyun Kim <jkim@invensense.com> Change-Id: If2cff2bd20ac69ca40bc56af50dcabbd4f5910d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2822268 Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org>
* zephyr: Remove CONFIG_VBOOT_HASH_RELOAD_WATCHDOGMichał Barnaś2021-05-181-18/+0
| | | | | | | | | | | | | | | | | | This reverts commit 0e5fa530e2f1eba6e16188be65ac39974a151a17. After commit 97e22d467 it is no longer needed to reload watchdog during hash calculation. BUG=b:182499153 BRANCH=none TEST=Flash EC and verify that hash calculation is correctly done without rebooting by watchdog. Reading watchdog value shows that there is enough remaining time. Change-Id: Ia7bb6452a6ac42cda88d8b5e1203876cd0465b31 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2897239 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* Mock: Add hard reset to PRL mockDiana Z2021-05-171-1/+5
| | | | | | | | | | | | | | Add the ability to detect hard reset send through the PRL mock. Note that a hard reset is a transmit type, not a control or data message. BRANCH=None BUG=b:184764468 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iac4e52a66b8282e8a0e341e65c4f437c6154fe77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2897127 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* TCPMv2: Hard reset on PR swap interruptionDiana Z2021-05-171-0/+11
| | | | | | | | | | | | | | | | When a PR swap is interrupted, send a hard reset. Since Vbus is turning off, a soft reset wouldn't restore our Vbus and connection state for this protocol error. BRANCH=zork BUG=b:184764468 TEST=on jelboz, connect problematic dock which interrupts PR swap and ensure connection can recover successfully Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I901c5a99af3f8cfae038d447bac8e0f37fedc9c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2880811 Reviewed-by: Edward Hill <ecgh@chromium.org>
* kblight: Don't leave kblight enable state undeterminedRob Barnes2021-05-171-0/+2
| | | | | | | | | | | | | | | Keyboard backlight enabled state is undetermined after initialization. Set kblight enabled state to off on initialization. BUG=b:187757151 TEST=Guybrush kblight enable GPIO is deasserted on reboot BRANCH=None Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: Ia62c9f84c5593ac393808fac4f0373e831ccd5fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2888226 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* Port80: handle 4-byte Port80 codes properlyJun Lin2021-05-171-9/+8
| | | | | | | | | | | | | | | | | | | | | | | In this CL, there are the following changes: 1. call hook_call_deferred to dump Port80 codes in any case. 2. inhibit Port80 code which is greater than 0x100 from being sent to host (i.e. written to last_boot variable) BRANCH=none BUG=b:184872297 TEST=build the image with "#define CONFIG_PORT80_4_BYTE"; connect npcx9_evb to the eSPI host emulator; the host sends a PUT_IOWR_SHORT transaction to IO address 0x80 with 4 bytes of code "0xEEE20400"; the EC console shows: Port 80 writes: eee20400 <--new Signed-off-by: Jun Lin <CHLin56@nuvoton.com> Change-Id: I4bcc75cc74c2ad75a51bb25af5d1a13e8b36dca6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2894324 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: CH Lin <chlin56@nuvoton.com> Tested-by: CH Lin <chlin56@nuvoton.com>
* kblight: Set kb backlight enable gpiostabilize-13974.B-mainRob Barnes2021-05-141-0/+4
| | | | | | | | | | | | | | Set the keyboard backlight enable gpio on enable/disable. This will improve power usage on some boards. BUG=b:187757151 TEST=Set backlight to 0, 50, 0 and observe the enable gpio is 0, 1, 0 BRANCH=None Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: Ie03e98d939d05aea861c7b885a45b7e0c476db59 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2887550 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* TCPMv2: Initiate VCONN Swap when requestedstabilize-13971.B-mainAbe Levkoy2021-05-141-1/+1
| | | | | | | | | | | | | | | | | | | Do not ignore a requested VCONN Swap if VDM setup is done. Use a DPM request flag (which is always handled in the ready state) instead of the VCONN Swap PE flag (which is only handled if mode entry hasn't completed). BUG=b:187861138 TEST=make buildall BRANCH=firmware-volteer-13672.B-main Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I32ebb7c50e9abc47351398f229a2b464605f634d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2895425 Tested-by: Li1 Feng <li1.feng@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* TCPMv2: Correct PD 3.0 reply when SVDM isn't supportedDiana Z2021-05-141-1/+11
| | | | | | | | | | | | | | | In PD 3.0, a DUT must reply with Not_Supported when a SVDM isn't supported. Note that PD 2.0 is still perfectly welcome to send a NAK reply for this case. BRANCH=None BUG=b:181194535 TEST=with follow-on CL, verify TD.PD.VNDI3.E3 VDM Identity passes Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie3b554cca017494b86342df1e9149b4452c83852 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2881028 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: i2c: remove scl and sda referencesYuval Peress2021-05-141-0/+2
| | | | | | | | | | | | | | | The SDA and SCL components of the struct i2c_port_t are only used in and for the i2c_wedge.c logic. This isn't needed in Zephyr. Remove the values and functions that use them from the Zephyr build. BRANCH=none BUG=b:188179405 TEST=build volteer and trogdor Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I71a26fbd9bc51def744ef1f16a540728482c5a2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2896235 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* mkbp: Move key simulation to input devicesBoris Mittelberg2021-05-102-65/+68
| | | | | | | | | | | | | | | | | | Today some platforms include MKBP_KEYBOARD because they use side buttons, switches or other events that share the same driver with MKBP keyboard. Those platforms don't enable KEYSCAN task. The CL is moving key emulation functionality to MKBP input devices, to make a clear separation between the real keyboard usage and emulation/buttons/switches/etc. All boards that were selecting `CONFIG_KEYBOARD_PROTOCOL_MKBP` without KEYSCAN task are now updated to select `CONFIG_MKBP_INPUT_DEVICES` BUG=b:170966461 BRANCH=main,firmware-dedede-13606.B,firmware-volteer-13672.B-main TEST=None Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I515140ebf6e175f4b29991329f92266ffca232a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2824044
* mkbp: EC buttons and switches via MKBPBoris Mittelberg2021-05-106-166/+195
| | | | | | | | | | | | | | Allowing EC buttons and switches to be signaled via MKBP protocol, using CONFIG_MKBP_INPUT_DEVICES. Default behaviour is unchanged. BUG=b:170966461 BRANCH=main,firmware-dedede-13606.B,firmware-volteer-13672.B-main TEST=None Signed-off-by: Boris Mittelberg <bmbm@google.com> Cq-Depend: chromium:2824044 Change-Id: Ib96f98ecb3717a8ee8963be69fb7d7eb72e6d132 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2796382
* PCHG: Enable device event on suspend completeDaisuke Nojiri2021-05-102-0/+14
| | | | | | | | | | | | | | | | | | | | | | Currently, PCHG can send a device event any time. When a signal is sent to the host while it's attempting to suspend, suspend is delayed by 10 seconds. A solution is to make Powerd disable a corresponding PCHG event (i.e. EC_DEVICE_EVENT_WLC) when it's notifying an upcoming suspend to other processes. This patch makes PCHG re-enable EC_DEVICE_EVENT_WLC after suspend is complete. BUG=b:182973695, b:173235954 BRANCH=trogdor TEST=Verify CoachZ suspends without a delay. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I10d7fcf234a7e0e05ce5d77b8e930a0cf0748331 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2863564 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Storo: Use display SoC to control charge LEDDaisuke Nojiri2021-05-101-2/+11
| | | | | | | | | | | | | | | | | | | | Currently, Storo uses the state of charge provided from the battery. This isn't the same as the SoC shown on the screen because Powerd compensates it based on the full factor and the low battery shutdown threshold. This change makes Storo use the display SoC for the charge LED module so that the charge LED and the display SoC synchronously work. BUG=b:181506409 BRANCH=dedede TEST=Storo's LED turns from amber to white when the display soc reaches 95% (internally 94.6%). Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I42c505c9fbd39f82de2318f0d7ff8589eeca4d8c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2876165 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* util: Add explicit castsTom Hughes2021-05-061-1/+1
| | | | | | | | | | | | | | When compiling with C++, the implicit casting that is performed in C is disallowed. Add casts in preparation for C++ compatibility. BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I5c25440819428db65225c772c1c5115a735db58a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864519 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: lid angle calculation: Exclude any measurement over 1.1gGwendal Grignou2021-05-061-1/+1
| | | | | | | | | | | | | | | | | When a given axis is reporting 1.1g or over, it means the device is moving. The constant representing the limit was not set properly. BUG=b:187338766 TEST=unittests. BRANCH=none Signed-off-by: Gwendal Grignou <gwendal@google.com> Change-Id: I36e38b5d7957ecaccc2c4e088d9aa506af6a2315 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2875484 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org>
* common: motionsense fifo: Reset the initialized bits after commitYuval Peress2021-05-041-0/+6
| | | | | | | | | | | | | | | | | | | | | Previously once we had one sample from a sensor, we considered the fifo initialized. Meaning we would use our computed next timestamp to spread the timestamps. This was causing issues with some devices that ended up causing the timestamps to run ahead. Reset next_timestamp_initialized back to 0 after each commit. This will allow repeated timestamps but only if a driver stages/commits the same timestamp twice. Staging the same timestamp with only a single commit will still work as before (which is the expected path). BRANCH=none BUG=b:168335284 TEST=make run-motion_sense_fifo Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib7c566f69d7c1e4e898050b67105555dd05376e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2871055 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* Port80: allow to accept 4-byte Port80 codeJun Lin2021-05-041-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | The original Port80 implementation assumes that the Port80 code is only 2-byte wide and is less than 0x100. In the recent AMD chipset (CEZANNE), AP will send a 4-byte Port80 code via a single PUT_IOWR_SHORT eSPI transaction in PSP. This CL adds a config option to allow the Port80 to print 4-byte code when the config is defined. BRANCH=none BUG=b:184872297 TEST=build the image with "#define CONFIG_PORT80_4_BYTE"; connect npcx9_evb to the eSPI host emulator; the host sends a PUT_IOWR_SHORT transaction to IO address 0x80 with 4 bytes of code "0xEEE20400"; the EC console shows: Port 80 writes: eee20400 <--new Signed-off-by: Jun Lin <CHLin56@nuvoton.com> Change-Id: I3b93d9fc41e1875bb628a15c58231005e9555cfd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2858296 Tested-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Raul E Rangel <rrangel@chromium.org> Commit-Queue: CH Lin <chlin56@nuvoton.com>
* vboot: convert watchdog reload check to plain #ifdefYuval Peress2021-05-021-6/+7
| | | | | | | | | | | | | | | | When not defining CONFIG_WATCHDOG or in Zephyr builds setting CONFIG_WATCHDOG=n the build would fail here because CONFIG_WATCHDOG_PERIOD_MS was not defined. This is avoided by using #ifdef instead of IS_ENABLED BRANCH=none BUG=none TEST=built lazor with and without zephyr Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I9f390bf32840fc98d38612cc1fcf00d779f902ee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2859466 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Use board specific MF preference for DP AttentionScott Collyer2021-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Both DP Status and DP Attention messages contain a MF bit which allows the UFP-D to signal to the DPF-D its multi-function preference. Chromeos host machines only act on this bit in the DP Status message. However, other host machines may also use this bit in the DP Attention message. This CL adds a call to a board specific policy function so that the MF bit can be set correctly in both the DP Status and DP Attention message. BUG=b:186632734 BRANCH=quiche TEST=ODM partner verifed that with this bit set in both DP Status and DP Attention, the host machine will select pin configuraiton D. Previously, the host machine was selecting pin configuration C. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I0242d2a5ad056ec210d7364b606528e4a54858c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2856290 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* Battery: Add command to export display SoCDaisuke Nojiri2021-05-011-13/+44
| | | | | | | | | | | | | | | | | | | | | | Currently, CrOS EC passes the battery remaining capacity (mAh) and the full capacity (mAh) through ACPI to the AP so that the host can calculate the battery SoC. The host further manipulates the SoC to get the display SoC, which is used to determine user visible behaviors. To get consistent behaviors in all power states, this change enables the EC to send the display SoC to the host via EC_CMD_DISPLAY_SOC command. The Powerd's part is I5bd1371f2569d21d55df1b50a3d709b98bbf0325. BUG=b:174433637, b:181506409, b:80270446, b:109954565 BRANCH=dedede, trogdor, nami, hatch TEST=Storo, CoachZ Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Idc6992625d992a73be141987d02ed220508d3b74 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2853142 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* retimer: check power for firmware upgradeli feng2021-05-011-12/+26
| | | | | | | | | | | | | | | | | | | | | | | Before retimer firmware update, check power, if battery is not present, or battery level is low (<5%), not allow PD suspend/performing retimer firmware update process. BUG=b:185320314 BRANCH=none TEST=On Voxel DVT, AC only, no battery, boot up system and confirm NDA PD port is not suspended, and retimer firmware update is not performed. DA port has correct device functions. TEST=On Voxel DVT, battery is low (< 5%), boot up system and confirmed NDA PD ports is not suspended, and retimer firmware update is not performed; DA port has correct device functions. TEST=On Voxel DVT, when battery level >=5%, confirmed NDA PD port can be suspended and retimer is scanned. DA port has correct device functions; device tested are DP dongle, TBT dock and USB4 device. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I1c5b2bc54b2f6307503f82112f28bbc8d6b0591a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2858283 Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpc: Add common routine to check powerli feng2021-05-012-42/+43
| | | | | | | | | | | | | | | | | | | | | | | This comment is from CL:1123314: We do not want to allow depthcharge to suspend the PD port for a firmware upgrade if there is not enough battery power to last during the full firmware upgrade. A common routine is created to check power: pd_firmware_upgrade_check_power_readiness() in usb_common.c. Firmware upgrade which needs to suspend PD port should check this function to make sure there is enough power. BUG=none BRANCH=none TEST=make -j buildall Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I47910a4d82da9b569c297ad2cd399a2faf4cf98a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2862556 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* TCPMv2: Set CC on contract invalidation only if connectedDiana Z2021-04-301-2/+2
| | | | | | | | | | | | | | | | | | | When a contract is invalidated, it's important we advertise our current limit Rp rather than a residual collision avoidance Rp. However, we should not attempt to set CC's when we're in a disconnected state. This may cause us to set an unexpected CC selection, such as Ra if the TC layer hasn't set the first termination yet. BRANCH=None BUG=b:183182447 TEST=on guybrush, boot with i2c tracing enabled and ensure Ra is never set during init. Perform PR swaps and hard resets as source to ensure correct Rp is set. Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I8fbe06685e4b4a6493dfbf55270ce3bda8cfbdfd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2845013 Reviewed-by: Edward Hill <ecgh@chromium.org>
* config: rename CONFIG_FLASH to CONFIG_FLASH_CROSJeremy Bettis2021-04-273-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 4ac1d81e1430dbfbfba1376a23ab19dfa845d7ef. The config name collides with the same config name in zephyr. Also, renames zephyr Kconfig CONFIG_PLATFORM_EC_FLASH to CONFIG_PLATFORM_EC_FLASH_CROS as the corresponding change at Kconfig side. BUG=chromium:1202406,b:180980668 TEST=make -j16 runhosttests buildall && zmake testall && \ /mnt/host/source/src/platform/ec/zephyr/firmware_builder.py --metrics \ /tmp/tmplt8ty8ci test ; echo $? BRANCH=none Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I5b5e58b30d936b5232e049827f458d9a2ed06340 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2855320 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Enter TBT/USB4 only if port supportsVijay Hiremath2021-04-271-1/+3
| | | | | | | | | | | | | | | Type-C ports may not be symmetrical on Reference Design Platforms hence check if the port supports TBT & USB4 mode before entering the mode. BUG=none BRANCH=none TEST=Tested on ADLRVP, TBT is not entered on non supported port Change-Id: Ifd3eae72f6226686462b07f9008b66bd60c7895b Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2846634 Reviewed-by: Ayushee Shah <ayushee.shah@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* mkbp: Separate MKBP_INFO host command from the keyboard driverBoris Mittelberg2021-04-273-125/+157
| | | | | | | | | | | | Detaching protocol-related info command from the keyboard driver. BUG=b:170966461 BRANCH=main,firmware-dedede-13606.B,firmware-volteer-13672.B-main TEST=None Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I7943f7537bdf003145e9bd909a14f9451d922a5a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2796381