summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* zephyr/test: Fix TYPEC_VDM_RESPONSE paramstabilize-15329.59.B-mainstabilize-15329.44.B-mainrelease-R111-15329.B-mainCaveh Jalali2023-01-261-1/+1
| | | | | | | | | | | | | | | | The EC_CMD_TYPEC_VDM_RESPONSE host command takes a 'struct ec_params_typec_vdm_response' as input, not 'struct ec_params_typec_status'. These structs are identical, so no functional change is introduced. BRANCH=none BUG=b:258110734,b:208884535 TEST='./twister -v -T zephyr/test' passes Change-Id: I583ed1b24eadf7cd3e4c751346337525342d4327 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4195665 Reviewed-by: Boris Mittelberg <bmbm@google.com>
* zephyr: west manifestAl Semjonovs2023-01-251-0/+44
| | | | | | | | | | | | | | Create a manifest for west initialization BUG=None BRANCH=NONE TEST=west init west update Change-Id: I2480cf7c3750fdc0d3e628da70fb75fb90496b40 Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4189422 Reviewed-by: Yuval Peress <peress@google.com>
* flash_fp_mcu: Dynamically determine gpiochip number for volteerPatryk Duda2023-01-251-18/+18
| | | | | | | | | | | | | | | | | Volteer-kernelnext uses upstream kernel which changes every week. In this case it's cumbersome to hardcode gpiochip number in the script and we should determine it dynamically. BUG=b:266463371 BRANCH=none TEST=Run `flash_fp_mcu --hello` on volteer and volteer-kernelnext Change-Id: I80e32d9ce3a291d1ace886a1c1cd2508dca7fdb9 Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4193840 Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Patryk Duda <patrykd@google.com> Reviewed-by: Josie Nordrum <josienordrum@google.com>
* board/hyperdebug: Enable DFUJes B. Klinke2023-01-254-4/+44
| | | | | | | | | | | | | | | Configure HyperDebug board similar to Servo V4, in that the RO copy of the firmware is replaced with a 4kB bootloader, whose only task is to decide whether to jump to STM ROM DFU bootloader or to RW. BUG=b:192262089 TEST=Upgrade firmware on STM32L5 based Nucleo board using dfu-util Change-Id: I5a9461a5a9b28642b274f26affa1c64a4c2bfe11 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4183942 Reviewed-by: Brian Nemec <bnemec@google.com> Commit-Queue: Jes Klinke <jbk@chromium.org> Tested-by: Jes Klinke <jbk@chromium.org>
* common: Allow boards to opt out of image paddingJes B. Klinke2023-01-253-0/+6
| | | | | | | | | | | | | | | | | | | | | The HyperDebug board uses the DFU bootloader in the same way as Servo V4 is going to, meaning that the RO section is 4kB and the RW section takes up the rest of the 512kB flash space. Currently, less than 64kB of actual code is in the RW. In order to make image files smaller, and speed up DFU flashing by a factor of ten, I want the option of not having the ec.bin image padded to the size of the flash space. This CL introduces a CONFIG_IMAGE_PADDING, which defaults to being enabled. TEST=make BOARD=hyperdebug, then flash the smaller image using DFU BUG=b:192262089 Change-Id: I12cdd4f7b7a3e48c9c7640bafa2d6f10e4ca24f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4193070 Commit-Queue: Jes Klinke <jbk@chromium.org> Tested-by: Jes Klinke <jbk@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* chip/stm32: Modification to DFU for STM32L5Jes B. Klinke2023-01-253-18/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The STM32L5 series behaves the same as STM32L4 to a large degree, so this CL adds code to enable RTC clock on L5 using the same register bits as on L4. The "backup registers" however, sit in a new "Tamper" component on L5, and not in the RTC component as on L4. This CL adds register declarations for the TAMP component. Lastly, jumping to the ROM bootloader with C function pointer call, as was done in jump_to_dfu(), does not work on the STM32L5 ROM bootloader (at least not on my Nucleo-X552EZ board.) The flaw seems to be that an ARM vector table contains a reset vector, and separately contains an initial value for the stack register. The previous code made no attempt at setting the stack point as the bootloader expected, and depending on how the EC code (and the STM ROM bootloader) is compiled, this may or may not work. This CL adds assembly code to set the stack pointer to the value given in the ROM header, before performing the jump. BUG=b:192262089 TEST=Upgrade firmware on STM32L5 based Nucleo board using dfu-util Change-Id: I2a871f0eaf9ea9f4c27c75ccb472cd4ff9616524 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4190164 Reviewed-by: Brian Nemec <bnemec@google.com> Tested-by: Jes Klinke <jbk@chromium.org> Commit-Queue: Jes Klinke <jbk@chromium.org>
* TCPMv2: Clear DPM state on disconnectDiana Z2023-01-252-0/+62
| | | | | | | | | | | | | | When a partner disconnects, clear the DPM state so stale data from it won't be presented to the AP. BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test Change-Id: Idf800b6c5c223e67c72c2124fb111fad27ce6361 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179363 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Test: Add test for VDM:Attention deliveryDiana Z2023-01-251-0/+247
| | | | | | | | | | | | | | Add unit tests to ensure we deliver VDM:Attention properly up to the AP with messages in the correct order. BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test Change-Id: I922b391e6d2fb9c969063be2b8d2e492fe8e74b3 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171492 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add host command VDM:Attention retrievalDiana Z2023-01-254-1/+30
| | | | | | | | | | | | | | | Add onto the existing VDM_RESPONSE host command to allow the AP to retrieve VDM:Attention messages. BRANCH=None BUG=b:208884535 TEST=build, deploy on skyrim and confirm ectool shows Attention messages from the queue until it empties Change-Id: Ice2e23b745f0faf892d2fd598c6e573e63e6a982 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171491 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Queue Attention messages for consumptionDiana Z2023-01-255-6/+142
| | | | | | | | | | | | | | | Set up a queue within the DPM to hold VDM:Attention messages which the AP will be able to deplete at its leisure. BRANCH=None BUG=b:208884535 TEST=builds with and without AP VDM control Change-Id: Ia73ac3c6164251ab021776fdca252033646797dd Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171490 Code-Coverage: Aaron Massey <aaronmassey@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Rearrange VDM response HC contentsDiana Z2023-01-255-22/+18
| | | | | | | | | | | | | | | | | | The AP would like to consume VDM:Attention packets in the same host command as the VDM responses. To support this, pull the previous return error into a response structure field instead. Also correct an incorrect struct for the VDM response test utility (though it is functionally equivalent to the TYPEC_STATUS struct). BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test Change-Id: I5d976dda6be40b72de15e84f4bbd9311d908a904 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171489 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* util: check_zephyr_project_config: keep paths as Path objectsFabio Baltieri2023-01-252-14/+14
| | | | | | | | | | | | | | Use Path objects for ZEPHYR_BASE and use the site module to add module paths instead modifying sys.path. BRANCH=none BUG=none TEST=pytest Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: If6f3b60d90d9acaff91609d55acffbfb605e0961 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4188740 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: zmake: Add config and device tree check capability to compare-buildsMadhurima Paruchuri2023-01-254-48/+178
| | | | | | | | | | | | | | | | | The invocation of command with -con arg now will compare config files, -dt will compare devicetree files along with binary files and outputs the failed projects lists separately along with combined list. With -bin arg now binaries comparisons can be avoided. BUG=b:262374758 BRANCH=none TEST=zmake compare-builds it8xxx2_evb -bin -con -dt TEST=Modified dt and config in Rex and saw comparison failing Change-Id: I29751c640b833792f6bfbacbdb80b9119bdb8efc Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4169805 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* herobrine: Delay enabling 5V if battery is disconnectedYu-An Chen2023-01-242-30/+82
| | | | | | | | | | | | | | | | Wait negotiated VBUS transition before enabling 5V rail when battery is disconnected BUG=b:260192201 BRANCH=none TEST=zmake build evoker TEST=./twister -T zephyr/test/herobrine Change-Id: Ieebd10ea32b26e9f1f3f3e438351ba519ae1b337 Signed-off-by: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4123671 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com>
* chip/stm32: Correction to EXTI register declarations for STM32L5Jes B. Klinke2023-01-243-13/+60
| | | | | | | | | | | | | | | | | | Originally, I copied STM32L4 declarations for STM32L5, making adjustments for base addresses, and other obvious differences. It turns out that the external interrupt controller has som subtle changes to its registers. Most notably the EXTICR registers (used for selection which external pin is routed to which of the 16 edge detection "engines") have been moved from the SYSCFG component into EXTI component. BUG=b:192262089 TEST=Observe edge detection working on HyperDebug (based on STM32L5) Change-Id: I4ad4f2559c60bef73a29812ebac1316cfa389a3e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4166670 Commit-Queue: Jes Klinke <jbk@chromium.org> Tested-by: Jes Klinke <jbk@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/build.mk: Allow shmalloc/shared_mem in RW when using DFUJes B. Klinke2023-01-231-1/+11
| | | | | | | | | | | | | | | | | | | | | | | CONFIG_MALLOC can ordinarily be used to control whether shmalloc.o or shared_mem.o is linked, with the latter being the automatic default is CONFIG_MALLOC is disabled in either or both of RO and RW. CONFIG_DFU_BOOTMANAGER_MAIN was introduced, allowing the RO stage to be completely replaced by a 4Kb bootloader, but it had the unintended side effect that NEITHER shmalloc.o nor shared_mem.o will be linked with the RW stage. Thic change makes it such that of of the shared memory files are linked into the RW stage, depending on the setting of CONFIG_MALLOC. BUG=b:192262089 TEST=make BOARD=hyperdebug Change-Id: Ie21ffb772447d4817632210656f9820bfad4946a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4183954 Reviewed-by: Brian Nemec <bnemec@google.com> Commit-Queue: Jes Klinke <jbk@chromium.org> Tested-by: Jes Klinke <jbk@chromium.org>
* common/hooks.h: Tolerate same function registered as multiple hooksJes B. Klinke2023-01-231-4/+4
| | | | | | | | | | | | | | | | | | The file clock-stm32l4.c registers the function clock_chipset_startup as both HOOK_CHIPSET_STARTUP and HOOK_CHIPSET_RESUME. Before this change, compiling with hooks disabled would lead to a linker error as a function unused_hook_clock_chipset_startup() would be declared twice. This change makes it such that the hook, as well as the name of the registered function is concatenated into the synthetic function name. BUG=b:192262089 TEST=make BOARD=hyperdebug Change-Id: Ic7ead88e2fd86d509769a1c0a88a788b72576238 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4183953 Tested-by: Jes Klinke <jbk@chromium.org> Commit-Queue: Jes Klinke <jbk@chromium.org> Reviewed-by: Brian Nemec <bnemec@google.com>
* docs: Update coverage requirement to 90%Tristan Honscheid2023-01-231-4/+3
| | | | | | | | | | | | | | | Update the firmware testing requirements doc to reflect the new 90% threshold. BUG=None BRANCH=None TEST=None, ironically Change-Id: I35f90b1592db2203d3c6f7ae05071fdd23ad0695 Signed-off-by: Tristan Honscheid <honscheid@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4182781 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* mchp: Remove undefined behavior in espi msvw handlersDustin L. Howett2023-01-231-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code in espi_msvw[12]_interrupt relies on undefined behavior today. __builtin_ctz is specified as returning values in the range [0, 31], but we are checking for 32. This behavior may be unexpected compared to the CTZ/CLZ instruction on ARM, which use the value 32 to indicate that there are no ones in the provided input. GCC 11+ optimizes the two loops below into infinite loops, as it can see that the condition will never be met. After this change, the disassembly of espi_mswv1_interrupt can be confirmed to contain an exit behind a branch. ... // r4 is loaded with girq24_result and has bits successively cleared 1a: b90c cbnz r4, 20 <espi_mswv1_interrupt+0x20> 1c: e8bd 81f0 ldmia.w sp!, {r4, r5, r6, r7, r8, pc} 20: fa94 f5a4 rbit r5, r4 ... BUG=None BRANCH=main TEST=Examined the disassembly for espi_msvw[12]_interrupt; see above Change-Id: I68a5c753233a17b6b0fb61a31f1eeccf78c00aba Signed-off-by: Dustin L. Howett <dustin@howett.net> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4114450 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Alexandru Stan <amstan@chromium.org>
* nissa: Enable AC_PRESENT charger supportAndrew McRae2023-01-231-0/+1
| | | | | | | | | | | | | | When using the RAA489000 charger, enable the code to correctly generate the AC_PRESENT signal. BUG=b:263691951 TEST=Verify on nirwen that AC_PRESENT is correctly generated BRANCH=none Change-Id: I3086104af8dda692b0eddbc2d71cf41e2512cea2 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179437 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* raa489000: Support AC_PRESENT when OTG modeAndrew McRae2023-01-233-0/+70
| | | | | | | | | | | | | | | | | | Flip the comparator inverter output when the charger chip is running in OTG mode so that the AC_PRESENT signal is correctly generated. The AC_PRESENT relies on the ACOK signal, but during OTG mode, ACOK is on when the charger is sourcing power to the port, so AC_PRESENT should be off. BUG=b:263691951 TEST=Verify with nivviks that AC_PRESENT is generated correctly BRANCH=none Change-Id: I004b8caaa63a902dd54288840c044bbe920e1347 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179436 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* charger: Add config item for the RAA489000 supporting AC_PRESENTAndrew McRae2023-01-231-0/+12
| | | | | | | | | | | | | | | | On systems where the GSC input signal AC_PRESENT is generated by the charger, some support may be required within the RAA489000 driver to invert the comparator output. Add a config item to enable this when required. BUG=b:263691951 TEST=Verify that config item appears in generated config. BRANCH=none Change-Id: I5402fff5fba383f1dd4067d2357f581b1488b876 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179435 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* tcpci: allow get_chip_info callers to update the cachePeter Marheine2023-01-224-44/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some drivers massage retrieved chip info in assorted ways (usually because the chips misbehave), but it's both confusing and inefficient how that interacts with cached chip info because the consuming driver needs to always interpose itself between possibly-cached values and its caller, usually requiring another layer of caching. This adds a new tcpci_get_chip_info_mutable() function that works like tcpci_get_chip_info(), but the caller can provide a function that modifies the cached data in order to do any required massaging. A callback is used rather than an output pointer to give the implementation freedom to change its behavior more, such as by adding locking to prevent the latent concurrency bugs that currently lurk in it. This also fixes a bug in the previous implementation where partial data would be cached if an error occurred in reading certain TCPC registers. BUG=b:244502337 TEST=make buildall; zmake build -a; twister BRANCH=none Change-Id: Ia3dcac109eb22bf0326e3fd1722aa64fe9f73f50 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179431 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Zephyr: Remove binman.dtsi requirementsBrian J. Nemec2023-01-202-3/+2
| | | | | | | | | | | | | | | | | | | | Starfish uses the EC build environment but does not use the CrOSEC stubs and does not use the EC partition. This leads to linker errors when building due to CONFIG_PLATFORM_EC_RW_TOTAL_IMAGE_SIZE dependencies which is undefined on Zephyr only targets. Adds defined() guards to checks in the linker to avoid build failures. BUG=b:243700103 BRANCH=None TEST=None Change-Id: I98b207f25edd4f6306fa9ed3a0c1a0ce91f46856 Signed-off-by: Brian Nemec <bnemec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4182530 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* rex: enable volume button interruptsLi Feng2023-01-202-0/+11
| | | | | | | | | | | | | | | | Enable interrupts so EC can respond to hardware volume button press. BUG=none BRANCH=none TEST=Press volume up/down button on Rex DB, EC console prints correct trace messages. Change-Id: I5d7e22765e81842bc247f635dc703b4a2d1f5e3b Signed-off-by: Li Feng <li1.feng@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4163828 Reviewed-by: RAJESH KUMAR <rajesh3.kumar@intel.com> Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr/test: Add EC_CMD_GET_NEXT_EVENT V2 coverageCaveh Jalali2023-01-201-0/+58
| | | | | | | | | | | | | | | | | Add coverage for the EC_CMD_GET_NEXT_EVENT V2 host command. This version is essentially identical to the V0 version but uses a bit in ec_response_get_next_event.event_type for the EC_MKBP_HAS_MORE_EVENTS flag. The test focuses on whether the bit is set as expected. BRANCH=none BUG=b:249163956 TEST='./twister -v -T zephyr/test' passes Change-Id: I067070638c45ed79ff46b8ad4cca305aa491e66b Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4183343 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr/shim/led_driver: Update `GET_PROP_NVE` macroRobert Zieba2023-01-203-13/+14
| | | | | | | | | | | | | | Rename the `GET_PROP_NVE` macro to `GET_COLOR_PROP_NVE` since it now evaluates to `EC_LED_COLOR_INVALID` instead of -1 as a default. BRANCH=none BUG=b:260547985 TEST=Builds Change-Id: I20c16682d4338dc53776907a766391b0af524716 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179862 Reviewed-by: Keith Short <keithshort@chromium.org>
* ec_commands: Fix EC_CMD_GET_BOOT_TIME response namingCaveh Jalali2023-01-204-5/+5
| | | | | | | | | | | | | | | | | | | | | | Rename the EC_CMD_GET_BOOT_TIME response struct to 'struct ec_response_get_boot_time' so it is consistent with the prevailing naming convention for host commands. The previous 'struct ap_boot_time_data' name has not propagated to any other repo (including upstream coreboot), so it is sufficient to rename it in the EC repo. BRANCH=none BUG=b:249163956 TEST='./twister -v -T zephyr/test' passes 'make buildall' passes 'make BOARD=host utils-host' passes Change-Id: Id0c02040b27b66b8e5c8bd1be08f0d59af76468c Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179360 Reviewed-by: Boris Mittelberg <bmbm@google.com> Reviewed-by: RAJESH KUMAR <rajesh3.kumar@intel.com>
* zephyr/test: Add EC_CMD_USB_PD_DEV_INFO coverageCaveh Jalali2023-01-207-0/+73
| | | | | | | | | | | | | | | | | Add rudimentary coverage for the EC_CMD_USB_PD_DEV_INFO host command. This is a host command used to interact with PD chips (TCPCs) running cros EC code. These are only found on very old hardware and are not really supported any more. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes 'make buildall' passes Change-Id: I96e704d521fc569d31d03dcdc588727da1f11951 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4176178 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* common/mkbp_event: Fix EC_CMD_GET_NEXT_EVENT responseCaveh Jalali2023-01-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | The EC_CMD_GET_NEXT_EVENT host command returns a 'struct ec_response_get_next_event' and should be implemented as such. So, replace 'uint8_t *' casting/dereferencing with struct member accesses. Callers (unit tests, kernel) already use 'struct ec_response_get_next_event' for this host command, so it makes sense to "fix" the implementation. No functional change in the data format is introduced. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes 'make buildall' passes Change-Id: I4cd1a30d1503cac9c7fd3add09b0b317a343cbcb Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171496 Reviewed-by: Tristan Honscheid <honscheid@google.com> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* zephyr: shi: default the shi node as disabled on iteFabio Baltieri2023-01-2014-6/+63
| | | | | | | | | | | | | | | Change the shi node definition for ite platforms to be declared without pinctrl and as disabled. That allows a program to enable the node and define the pin used in the specific implementation. BRANCH=none BUG=none TEST=zmake compare-builds Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I2e01a725fbc017d88c95b8567ad43294dbdcb9cc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4177234 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* Test: Correct SVDM versions in AP VDM testDiana Z2023-01-191-13/+26
| | | | | | | | | | | | | | | Correct the SVDM versions which our VDMs use in this test. Since the port partner is PD 3.0, they should be using SVDM version 2.0. BRANCH=None BUG=None TEST=./zephyr -T ./zephyr/test Change-Id: I9643816be0aa3b673a57abc5a8154b0f15b18059 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179362 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr/shim/led_driver: Add EC_LED_COLOR_INVALID enum valueRobert Zieba2023-01-193-4/+7
| | | | | | | | | | | | | | | | | | | | The ARM EABI uses `-fshort-enums` by default. This causes `enum ec_led_colors` to be represented as a `uint8_t`. This can cause issues with the off LED state which is supposed to use -1 for its color. However, its color ends up as 255 instead. This can cause buffer overflows in the LED code. Add `EC_LED_COLOR_INVALID` to cause the enum to be represented as a signed integer and update existing code to use this value instead of a plain -1. BRANCH=none BUG=b:260547985 TEST=Successfully ran LED factory test Change-Id: Ibc5fd1d46ad408b6e94dc1c3a9b01f269ac8ba7e Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179359 Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* shim/src/watchdog: Add support for watchdog helperPatryk Duda2023-01-193-67/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Watchdog helper is used to print a warning along with useful debugging information before hardware watchdog will reset SOC. Zephyr provides counter based watchdog which is very similar to watchdog helper from EC. This patch adds support for using multiple watchdogs simultaneously. One of the watchdogs will be counter based, the other will be hardware based (e.g. IWDG on STM32). Watchdog tests was modified to address the problem with allocating new counter channel every time watchdog_init() is called while there is no way to free them. BUG=b:239712345 BRANCH=none TEST=Add 'zephyr,counter-watchdog' node to DTS. Use 'waitms' command to check if a warning from watchdog based counter is triggered. TEST=./twister -i -T zephyr/test/drivers \ --test external/platform/ec/zephyr/test/drivers/drivers.default Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I66b5474d7e65978791450c2fd62dd3d345cd474a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116769 Tested-by: Patryk Duda <patrykd@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* herobrine: Rerun the ppc_init after 5V rail readyYu-An Chen2023-01-192-2/+35
| | | | | | | | | | | | | | | | | | Due to the delay of the 5V rail enabling until 5V@3A is ready, the ppc_init may run when the PPC is not powered on. This CL reruns the ppc_init function after the 5V rail enables to prevent Type-C port no function. BUG=b:260192201 BRANCH=none TEST=check boot log on evoker TEST=./twister -T zephyr/test/herobrine Change-Id: Ifd17e46e936d15fdfd7f93673606f51c9c8252d6 Signed-off-by: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4112732 Reviewed-by: Bob Moragues <moragues@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* zephyr: remove /dts-v1/ in .dtsi filesTing Shen2023-01-195-10/+0
| | | | | | | | | | | | | | | | | | | | | | According to devicetree spec 0.4, section 6.4 File layout, /dts-v1/ line should not appear in the middle of a preprocessed dts file. In general we should only put /dts-v1/ in .dts files, not .dtsi. DTS compiler didn't catch these because they are in the first #include directive of dts file. BUG=b:265763662 TEST=zmake compare-builds --all BRANCH=none Change-Id: I5d14c4713c23d29197bbd280da6a1ca6712efd43 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4176183 Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* zephyr: npcx: move npcx-cros-shi node to the bottom of dtsTing Shen2023-01-194-14/+39
| | | | | | | | | | | | | | | | | The /delete-node/ line need to be placed after the shi node definition in dts/arm/nuvoton/npcx.dtsi. BUG=b:265763662 TEST=manually checked packer/source.dts, make sure the shi node has compatible string "nuvoton,npcx-cros-shi". BRANCH=none Change-Id: Ibd6deb7f8571e20a267c5c2912b429160b49c424 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4176184 Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* chip/stm32: Fix copy/paste errorJes B. Klinke2023-01-181-2/+2
| | | | | | | | | | | | | | | | Existing code for extracting chip independent EC pin flags from stm32 registers suffered from a copy/paste error, meaning that it could never recognize interrupt triggering on a falling edge. BUG=none TEST=make BOARD=hyperdebug Change-Id: I4c752b092bfd3c6ea70192006a9453e0b81b0d9b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4166669 Tested-by: Jes Klinke <jbk@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Jes Klinke <jbk@chromium.org>
* tcpci: handle tcpc tx discarded eventScott Chao2023-01-182-7/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | In Revision 2.0, Version 1.3 USB Type-C® Port Controller Interface Specification 4.7.1. If the transmission was discarded due to an incoming received message, the TCPC sets the TransmitSOP*MessageDiscarded bit in the ALERT register. In the old process, TCPM will always send soft reset if TCPC did not set TransmitSOP*MessageSuccessful. It will cause the pending message be cleared. For example, when TCPC get ATTENTION from USB-C dock and TCPM send GET_SINK_CAP to TCPC at the same time. The TCPC will set TransmitSOP*MessageDiscarded and TCPM will send soft reset and cause TCPM did not get ATTENTION message. BUG=b:265247056 BRANCH=none TEST=make sure dock can display. TEST=make buildall TEST=./twister -v -T zephyr/test Change-Id: I2597894c1f7abceea3c352ba1066d270d2d01ba0 Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4160814 Reviewed-by: Diana Z <dzigterman@chromium.org>
* zephyr:test: Correct port80 suite nameAl Semjonovs2023-01-181-1/+1
| | | | | | | | | | | | | | | ZTEST suite for port80 console command went to port80 host command suite. Correcting for console command suite. BUG=None BRANCH=NONE TEST=./twister -c -T zephyr/test Change-Id: I3e31a8a9d92f1dcc0402981b9cdf4551f05b18c3 Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4178238 Commit-Queue: Tristan Honscheid <honscheid@google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* TCPMv2: Add SOP minor revision to EC_CMD_TYPEC_STATUSJameson Thies2023-01-188-20/+64
| | | | | | | | | | | | | | | | | | | | EC_CMD_TYPEC_STATUS is used to send data about USB-C partners and cables to the kernel where it can then be exposed to userspace. Currently, EC_CMD_TYPEC_STATUS only assigns major PD revision to sop_revision causing the minor revision to appear as "0" regardless of the devices actual minor PD revision. This CL adds minor revision assignment to EC_CMD_TYPEC_STATUS so that it can be correctly reported by the kernel. BUG=b:261736720 BRANCH=None TEST="cat /sys/class/typec/port0-partner/usb_power_delivery_revision" for USB PD 2.0, 3.0 and 3.1 devices. Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: I8c1858d6e6d577628b373d16f9aabdfd15a0e3c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4163826 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* skyrim/project.conf: Enable CONFIG_PLATFORM_EC_HOSTCMD_AP_RESETTim Van Patten2023-01-181-0/+3
| | | | | | | | | | | | | | | | Enable CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET in `skyrim/project.conf`. This enables `ectool apreset` on Skyrim devices. BUG=b:265856820 TEST=`ectool apreset`, verify AP is reset BRANCH=none Change-Id: I993d14d72036a51ef689e47df09d6d44e5ebf6c4 Signed-off-by: Tim Van Patten <timvp@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4175424 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* util/ectool: Fix EC_CMD_SMART_DISCHARGE responseCaveh Jalali2023-01-181-1/+1
| | | | | | | | | | | | BRANCH=none BUG=b:258110734 TEST='make BOARD=host utils-host' passes Change-Id: I22761cbba3568a90fdd49acee75f9e4ecb3e8665 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171502 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* util/ectool: Fix EC_CMD_USB_PD_DEV_INFO resultCaveh Jalali2023-01-181-2/+2
| | | | | | | | | | | | BRANCH=none BUG=b:258110734 TEST='make BOARD=host utils-host' passes Change-Id: Iba75092bab6e2bf72f73535ffa94b912613c0c45 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171501 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* util/ectool: Fix EC_CMD_USB_PD_DISCOVERY resultCaveh Jalali2023-01-181-2/+2
| | | | | | | | | | | | BRANCH=none BUG=b:258110734 TEST='make BOARD=host utils-host' passes Change-Id: I06dc0c8c5d657e12704b6ebb60bf8eff78f0bef7 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171500 Reviewed-by: Boris Mittelberg <bmbm@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr/test: test_shim_rtc: Fix EC_CMD_RTC_GET_* responseCaveh Jalali2023-01-181-2/+2
| | | | | | | | | | | | | | | | The EC_CMD_RTC_GET_* host commands return a 'struct ec_response_rtc' not 'struct ec_params_rtc'. These structs are identical, so no functional change is introduced. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes Change-Id: I077d3114a54cd3445dd39ebf49ae493a4927fbd3 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171499 Reviewed-by: Boris Mittelberg <bmbm@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr/test: host_event_commands: Fix EVENT_CLEAR testsCaveh Jalali2023-01-181-9/+5
| | | | | | | | | | | | | | | | | | The EC_CMD_HOST_EVENT_CLEAR* host commands do not return data. Remove code for handling nonexistent return data. Next, make host_event_mask_cmd_helper() static since it's not used outside this file and signature has changed. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes Change-Id: Id101dc5c52110eca581da544e78cf9f0605f6698 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171498 Reviewed-by: Boris Mittelberg <bmbm@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr/test: keyboard_scan: Fix MKBP_SIMULATE_KEY testCaveh Jalali2023-01-181-6/+4
| | | | | | | | | | | | | | | | The EC_CMD_MKBP_SIMULATE_KEY host command does not return data. Remove code that sets up a 'struct ec_response_keyboard_factory_test' as the return parameter. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes Change-Id: Iac1a95453e612b384e22b0cf99812a134b18e378 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171497 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* qcom: Suppress the power signal log of AP_SUSPENDWai-Hong Tam2023-01-183-2/+15
| | | | | | | | | | | | | | | | Introduce a new flag to suppress the log of the power signal. Enable this new flag for the AP_SUSPEND signal as it toggles frequently in S3. BRANCH=None BUG=b:249750823 TEST=Make the device in S3 and check the EC UART not too noisy. Change-Id: Ib0155373ce85c0adc06153e8d3b24b8ac72c8036 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4172846 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/usb_pd_host_cmd: Fix EC_CMD_USB_PD_DEV_INFO paramCaveh Jalali2023-01-181-3/+3
| | | | | | | | | | | | | | | | | | | The EC_CMD_USB_PD_DEV_INFO host command should be implemented to use a 'struct ec_params_usb_pd_info' as the input parameter instead of a uint8_t. Callers (ectool, kernel) already pass a 'struct ec_params_usb_pd_info' for this host command, so it makes sense to "fix" the implementation. The struct only has a uint8_t member, so no functional change is introduced. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes 'make buildall' passes Change-Id: I8f70496ea4148340971a2c6b29408a0529ec8f3e Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4171495 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>