summaryrefslogtreecommitdiff
path: root/zephyr/shim/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch cros/main into firmware-dedede-13606.B-masterShou-Chieh Hsu2023-04-2420-111/+155
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generated by: util/update_release_branch.py -r --baseboard dedede --relevant_paths_file util/dedede-relevant-paths.txt firmware- dedede-13606.B-master Relevant changes: git log --oneline cb9e2e8159..de9944a9e6 -- baseboard/dedede board/beadrix board/beetley board/blipper board/boten board/bugzzy board/corori2 board/cret board/dibbi board/drawcia board/drawcia_riscv board/galtic board/kracko board/lantis board/madoo board/magolor board/metaknight board/pirika board/sasuke board/sasukette board/shotzo board/storo board/taranza board/waddledee board/waddledoo board/wheelie chip/it83xx common/charge_state_v2.c common/fpsensor/build.mk common/mkbp_* common/ocpc.c common/usbc/usb_tc_drp_acc_trysrc_sm.c common/usbc/usb_sm.c common/usbc/*_pd_* common/usbc/dp_alt_mode.c common/usbc/usb_prl_sm.c common/usbc/usb_pe_drp_sm.c common/usb_charger.c common/usb_common.c common/usbc_ocp.c driver/charger/sm5803.* driver/charger/isl923x.* driver/tcpm/raa489000.* driver/tcpm/it83* include/power/icelake.h include/intel_x86.h power/icelake.c power/intel_x86.c util/getversion.sh cb17c1f2eb ec: Add another #line directive for usb_common.c f97df4fc01 beadrix: Support POW-TECH battery b5e2ea8b0d zephyr: test: Set up OCPC test project and check console commands 7380b56e8c Taranza: Create initial EC image 312f806c07 Reland "zephyr/tests: emulator and tests for sm5803" 5d015bc961 Dibbi: Add CONFIG_EMULATED_SYSRQ f91109844b Revert "zephyr/tests: emulator and tests for sm5803" fd2415cda6 zephyr/tests: emulator and tests for sm5803 af177eb7ec clock: Remove the weak definition clock_enable_module 1ab21afba9 power/icelake: Wait for enough power before booting the AP 2ed86ebbcb zephyr: Eliminate pointer from SYS_INIT functions 74108a6ab3 USB-PD: Make sink automatically enter EPR mode 1366a27d9b USB-PD: Update pd console command for EPR c3d56ca023 TCPMv2: Disable PE during ErrorRecovery BRANCH=None BUG=b:273720621 b:272518464 b:242544165 b:273842037 b:277664211 BUG=b:248508087 b:272188485 b:257320026 b:276805061 b:276837557 BUG=b:242544165 b:278890420 b:257320026 b:274929940 b:278595739 TEST=`make -j buildall` Force-Relevant-Builds: all Change-Id: I4b90aac0df3186b89ad95ca992dde886c637ea9e Signed-off-by: Shou-Chieh Hsu <shouchieh@google.com>
| * zephyr: Add support for board override of fan duty adjustment logicKornel Dulęba2023-04-211-29/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The generic logic has proven to not work well on whiterun. In order to mitigate that, while not affecting everyone else, a custom fan duty adjustment logic needs to be implemented. The behavior is controlled with CONFIG_CUSTOM_FAN_DUTY_CONTROL, which will be enabled on whiterun in a another patch. Some structs has been moved to the fan header, so that they can be accessed from the custom logic. BUG=b:276577324 BRANCH=none TEST=make try_build_boards Change-Id: Iff31b6526be83b8b0165c4490bafe26f131e6c84 Signed-off-by: Kornel Dulęba <korneld@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4423152 Reviewed-by: Keith Short <keithshort@chromium.org>
| * zephyr: led: Change the node depends on display SOCwen zhang2023-04-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change makes the zephyr shim led driver use the display SoC for the LED node that depends on battery level, so that the charge LED and the display SoC work synchronously. BUG=b:278512388 BRANCH=none TEST=./twister -T zephyr/test/drivers/ -s drivers.led_driver Change-Id: I82a9e6a18486fb806f49855fbb5773bd7176929a Signed-off-by: wen zhang <zhangwen6@huaqin.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4430138 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Siyu Qin <qinsiyu@huaqin.corp-partner.google.com>
| * zephyr: bc12 shim: Remove compat guardstabilize-15432.B-mainKeith Short2023-04-211-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CONFIG_PLATFORM_EC_USB_CHARGER option already guards the bc12.c shim from compiling. A check that a BC1.2 driver is enabled is not required. BUG=none BRANCH=none TEST=zmake compare-builds -a TEST=./twister Change-Id: I1c9598b81a4eb4f96cfc85ef21ecc313db65a8a7 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4426808 Reviewed-by: Al Semjonovs <asemjonovs@google.com>
| * zephyr: LED: Reformated led-pins bindingsJason Yuan2023-04-183-28/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL formats the led-pins devicetree to be more intuitive as part of the LED driver overhaul. led-policy and led driver logic is unmodified in this CL and will be added later. BUG=b:228868616 TEST=twister, power LED verified on Villager, Lazor, Skyrim, Xivu BRANCH=none Change-Id: Ia688e872811199447d1e0b11a5533fd8478d2935 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4426805 Commit-Queue: Wai-Hong Tam <waihong@google.com> Auto-Submit: zhi cheng yuan <jasonyuan@chromium.org> Tested-by: zhi cheng yuan <jasonyuan@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
| * zephyr: Eliminate pointer from SYS_INIT functionsKeith Short2023-04-1711-29/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upstream change https://github.com/zephyrproject-rtos/zephyr/pull/51217 modified the function signature for the SYS_INIT call, eliminating the unused device pointer. Run the Zephyr provided script ./zephyr/scripts/utils/migrate_sys_init.py to update all callers. BUG=b:278595739 BRANCH=none TEST=zmake build -a Cq-Depend: chromium:4422804 Change-Id: I881bc536cef43a7c3ac4bc5eb3ce1893237bbd1f Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4437049 Reviewed-by: Tristan Honscheid <honscheid@google.com>
| * flash: cbi: Block the HCs from flash CBI section modificationMadhurima Paruchuri2023-04-171-17/+3
| | | | | | | | | | | | | | | | | | | | | | BRANCH=None BUG=b:267629295 TEST=./twister -T zephyr/test -c Change-Id: Ibcf176f10860cc126b267908faba054df256c3d4 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4414226 Reviewed-by: Wai-Hong Tam <waihong@google.com>
| * zephyr: tcpc: Add TCPC alt support for all existing TCPCMadhurima Paruchuri2023-04-141-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add TCPC alt support for all TCPCs and tests to test the working of TCPC alternatives BRANCH=none BUG=b:274126703 TEST=./twister -s drivers/drivers.usbc_tcpc -c Change-Id: Icafdaf8b940b09cfc3c17ed124e1b4a0a9427d01 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4375619 Reviewed-by: Keith Short <keithshort@chromium.org>
| * zephyr: Add support for RNG devicesPatryk Duda2023-04-132-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides implementation of trng_rand_bytes() using Zephyr's entropy API. Zephyr driver is responsible for hardware initialization, enabling and disabling, so trng_init() and trng_exit() are no-op. Add hostcmd and console command which can be used to test random number generator. Both commands have unit tests implemented. BUG=b:277029648 BRANCH=none TEST=zmake build bloonchipper TEST=Enable CONFIG_PLATFORM_EC_CONSOLE_CMD_RAND and compile firmware. Use 'rand' command to check if random values are generated. TEST=./twister -v -i -T zephyr/test/drivers/ --test drivers.random Change-Id: I3fa2c6a1aaf84dc23a8fbb06e557d9e07f5d1d32 Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4381919 Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Patryk Duda <patrykd@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* | Merge remote-tracking branch cros/main into firmware-dedede-13606.B-masterShou-Chieh Hsu2023-04-133-8/+68
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generated by: util/update_release_branch.py -r --baseboard dedede --relevant_paths_file util/dedede-relevant-paths.txt firmware- dedede-13606.B-master Relevant changes: git log --oneline b63a6e7c81..fd4151fe81 -- baseboard/dedede board/beadrix board/beetley board/blipper board/boten board/bugzzy board/corori2 board/cret board/dibbi board/drawcia board/drawcia_riscv board/galtic board/kracko board/lantis board/madoo board/magolor board/metaknight board/pirika board/sasuke board/sasukette board/shotzo board/storo board/waddledee board/waddledoo board/wheelie chip/it83xx common/charge_state_v2.c common/fpsensor/build.mk common/mkbp_* common/ocpc.c common/usbc/usb_tc_drp_acc_trysrc_sm.c common/usbc/usb_sm.c common/usbc/*_pd_* common/usbc/dp_alt_mode.c common/usbc/usb_prl_sm.c common/usbc/usb_pe_drp_sm.c common/usb_charger.c common/usb_common.c common/usbc_ocp.c driver/charger/sm5803.* driver/charger/isl923x.* driver/tcpm/raa489000.* driver/tcpm/it83* include/power/icelake.h include/intel_x86.h power/icelake.c power/intel_x86.c util/getversion.sh 57ed659cb9 USB-PD: Update EC_CMD_TYPEC_STATUS for EPR ad568190dd USB-PD: Support Vconn swap during EPR entry for Sink 83e5835dd4 kracko: Override PS8805 device id for A3 chip f6b76a0b61 kracko: Enable 2nd TCPC source PS8805 for port 1 4e4e28c156 kracko: Add SSFC bitmap for TCPC sources 1bdbbe598f kracko: Update SSFC bitmap for codec 88a4be749e TCPMv2: fix force power role when powered cable w/o sink attached (EMCA) 853d0b00ba mkbp_fifo: fix buffer overflow bug BRANCH=None BUG=b:268077715 b:275651680 b:275644832 b:257320026 TEST=`make -j buildall` Force-Relevant-Builds: all Change-Id: Ife8a1de5b45aeb200dc7346d71845728df9d542a Signed-off-by: Shou-Chieh Hsu <shouchieh@google.com>
| * retimer: Add driver for ANX7452 retimerMadhurima Paruchuri2023-04-122-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | BUG=b:267589042 BRANCH=None TEST=./twister -s drivers/drivers.anx7452 -c --coverage Change-Id: I99be488d82a58a5d38a2afcef0966b9c3236074d Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4226575 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
| * zephyr: tcpc: add rt1718s as basic tcpc emulatorlschyi2023-03-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a basic rt1718s tpcp emulator for future testing. BUG=b:273854897 BRANCH=none TEST=./twister -c -i -T zephyr/test/drivers -s drivers.rt1718s Change-Id: I0728be79d724ceea75a3a4189e10a50e6f8da0e8 Signed-off-by: lschyi <lschyi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4369109 Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Sung-Chi Li <lschyi@chromium.org> Tested-by: Sung-Chi Li <lschyi@chromium.org>
| * driver: shim: Port RT1715 TPCP driver to ZephyrMadhurima Paruchuri2023-03-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make RT1715 driver available to be used by zephyr based projects. At present RT1715 driver is also used for RT1716 RT1716 is used as alternate TCPC chip in Rex, hence adding the capability to use it as a alternative TCPC chip BRANCH=none BUG=b:274151516 TEST=none Change-Id: If16c3a8f81799ceee9ab19c3ef4adfb63fc49164 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4348920 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
| * zephyr: tcpc: Add support for multiple alternatives per portMadhurima Paruchuri2023-03-281-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for multiple TCPC alternatives on each USB-C port TCPC chips that are candidates for runtime selection must add the "is-alt" property to the TCPC definition. The board specific code then calls TCPC_ENABLE_ALTERNATE_BY_NODELABEL, specifying both the USB-C port to update, and the nodelabel of the new TCPC device. BRANCH=none BUG=b:274126703 TEST=none Change-Id: I3d6074f3afbf014101438dfeb535d08c4473e3f7 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4356351 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
| * zephyr: move tcpc_get_alert_status to shimJason Yuan2023-03-241-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tcpc_get_alert_status is similar between multiple different projects. They have been now merged into common code. BUG=b:254148652 TEST=twister, usbc charging on villager, lazor BRANCH=none LOW_COVERAGE_REASON=the change from hardcoding to rst-gpios in board specific code is uncovered. The common code is 100% covered. This CL increases the absolute coverage. Change-Id: I3136bd5b600dbb385547e06490dcbf8815b85b85 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4257651 Commit-Queue: zhi cheng yuan <jasonyuan@chromium.org> Auto-Submit: zhi cheng yuan <jasonyuan@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: zhi cheng yuan <jasonyuan@chromium.org>
* | Revert "util: Remove ec_panicinfo"Rob Barnes2023-03-241-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7b039ce808f49503e56a92f57e2482237bce6141. Reason for revert: Revert on dedede firmware branch. Original change's description: > util: Remove ec_panicinfo > > ec_panicinfo is moved to libec. > > BUG=b:172222556 > BRANCH=None > TEST=`BOARD=host make utils-host` > TEST=test with CL:4322820 and parse a sample eccrash and check result > > Cq-Depend: chromium:4318210 > Change-Id: Ib9770932f4555600bd3487757809bfb046f0bad8 > Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4318306 > Reviewed-by: Tom Hughes <tomhughes@chromium.org> BUG=None TEST=make buildall Change-Id: Ic5eac90c7b36d2031faece5f4c7b7ac6b7e089b6 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4367528 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ap_pwrseq: Adapt power interface components to AP Power Sequence driverstabilize-15395.B-mainBernardo Perez Priego2023-03-241-0/+31
| | | | | | | | | | | | | | | This CL make other components to follow AP Power Sequence driver. BUG=b:217952699 BRANCH=none TEST=zmake build Change-Id: I9d528fadd3074bfa9a2e9d1f36cfdeaf45015579 Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3996453 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Commit-Queue: Peter Marheine <pmarheine@chromium.org> Tested-by: Peter Marheine <pmarheine@chromium.org>
* zephyr: tcpc: cleanup TCPC chip macroKeith Short2023-03-231-1/+1
| | | | | | | | | | | | | | | | | Move the separator from each individual TCPC chip macro. This allows the same macro to be used outside an array definition. BUG=b:274126703 BRANCH=none TEST=zmake compare-builds -a Change-Id: Iabc8af8d0a5c32c4a24535c98b3d676083d7efb2 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4356026 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Madhu 🌱 <mparuchuri@google.com> Commit-Queue: caveh jalali <caveh@chromium.org> Tested-by: Madhu 🌱 <mparuchuri@google.com>
* zephyr: ppc: Add support for multiple altnernatesKeith Short2023-03-221-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for multiple PPC altnernate on each USB-C port. PPC chips that are candidates for runtime selection must add the "is-alt" property to the PPC definition. ppc_port0_alt: sn5s330@40 { compatible = "ti,sn5s330"; status = "okay"; reg = <0x40>; is-alt; }; The board specific code then calls PPC_ENABLE_ALTERNATE_BY_NODELABEL, specifying both the USB-C port to update, and the nodelabel of the new PPC device. PPC_ENABLE_ALTERNATE_BY_NODELABEL(0, ppc_nx20p348x_alt); BUG=b:274126703 BRANCH=none TEST=./twister -s drivers/drivers.usbc_ppc Change-Id: I8fff03beac8dbb98fea5b574e2ad456721cefe98 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4354880 Tested-by: Madhu 🌱 <mparuchuri@google.com> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: ppc: Cleanup PPC chip macroKeith Short2023-03-211-1/+1
| | | | | | | | | | | | | | | Move the separator from each individual PPC chip macro. This allows the same macro to be used outside an array definition. BUG=b:274126703 BRANCH=none TEST=zmake compare-builds Change-Id: I62307c5ba6c58f45566e2d65be491e56e9517fd9 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4354879 Tested-by: Madhu 🌱 <mparuchuri@google.com> Reviewed-by: Al Semjonovs <asemjonovs@google.com>
* zephyr: power_button: convert to the input APIFabio Baltieri2023-03-153-28/+20
| | | | | | | | | | | | | | | | | Convert the shim button driver to use the input APIs for the debounced state, use gpio_pin_get_dt() for the signal level one. BUG=b:268200726 BRANCH=none TEST=./twister, cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Cq-Depend: chromium:4339704 Change-Id: Ie4c3729709af7690332bc91aea2131a51aed184e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4329528 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Al Semjonovs <asemjonovs@google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* gpio/i2c: Only use status okay for Zephyr interrupts/named-i2cYuval Peress2023-03-152-7/+8
| | | | | | | | | | | | | | | | | Replace calls for DT_FOREACH_CHILD with DT_FOREACH_CHILD_STATUS_OKAY. This makes it possible for variants to disable some interrupts or i2c buses without having to remove the nodes. BRANCH=none BUG=b:272529568,b:273308069 TEST=zmake build rex rex-sans-sensors TEST=zmake compare-builds -a Change-Id: I3bf9034fd3f5e70665598d9e0b503d5e76bc13e4 Signed-off-by: Yuval Peress <peress@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4339256 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* Zephyr: Correct Temp sensor F75303 read methond.Logan_Liao2023-03-151-12/+13
| | | | | | | | | | | | | | | | This patch correct F75303 read fail on zephyr. BUG=b:269786658 BRANCH=none TEST=test markarth console that temps show right value. Change-Id: I315d80e2166d0b5f4d69f4e671846abe52fccbba Signed-off-by: Logan_Liao <Logan_Liao@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290094 Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Tested-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Chao Gui <chaogui@google.com> Commit-Queue: Logan Liao <logan_liao@compal.corp-partner.google.com>
* util: Remove ec_panicinfoHsin-Yi Wang2023-03-141-1/+1
| | | | | | | | | | | | | | | ec_panicinfo is moved to libec. BUG=b:172222556 BRANCH=None TEST=`BOARD=host make utils-host` TEST=test with CL:4322820 and parse a sample eccrash and check result Cq-Depend: chromium:4318210 Change-Id: Ib9770932f4555600bd3487757809bfb046f0bad8 Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4318306 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* tasks: Remove use of IS_ENABLED in macro conditionsRob Barnes2023-03-131-5/+5
| | | | | | | | | | | | | | | | IS_ENABLED is not meant to be used in macro conditionals according to the documentation: "Note: This macro will only function inside a code block due to the way it checks for unknown values." BUG=None BRANCH=None TEST=Build Change-Id: I407ddfe4f75d51933c9ee4e8f2ea24ec86b47764 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4320980 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cbi: flash: Implement CBI flash storage driver interfaceMadhurima Paruchuri2023-03-093-2/+68
| | | | | | | | | | | BUG=b:267628657 BRANCH=None TEST=./twister -s drivers/drivers.cbi_flash -c --coverage Change-Id: Ia1be34baf79774dc550bd70493ce5d2de31f2f28 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4284566 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* zephyr: forward cros_crc16 to zephyr crc16 implementationDerek Huang2023-03-081-0/+6
| | | | | | | | | | | | | | Shim in support for crc16 used in CPS8100 drive within platform/ec. Add test for platform/ec and zephyr based CRC16 approaches. BUG=b:195708351 BRANCH=none TEST=zmake build -a; ./twister -T zephyr/test/crc/ Change-Id: I52e2c5d6e4568eae5c42ca0b68b6d27731b69f06 Signed-off-by: Derek Huang <derekhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4269953 Reviewed-by: Keith Short <keithshort@chromium.org>
* system: Introduce Memory Dump Host CommandsRob Barnes2023-03-072-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | Add memory dump host commands and memory dump backend. These commands allow the host to fetch metadata about the coredump and fetch the actual coredump data. Host command payloads are limited to <256 byts on many platforms, so these commands are structured to work around this limitation. These commands do not allow fetching arbitrary memory. Each memory dump region must be explicitly registered for dumping before the host may fetch it. BUG=b:263250131 BRANCH=None TEST=Passing memory_dump_hostcmds unit test ectool memory_dump outputs memory dump. Change-Id: Iebddc2c1a65d741d3e7e5936bd6156647f193dc6 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4117923 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr/usba: define the correct symbol for port countsPeter Marheine2023-03-071-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Existing "dumb" code for USB-A port enables uses the USB_PORT_COUNT symbol as the number of ports, whereas "smart" ports use CONFIG_USB_PORT_POWER_SMART_PORT_COUNT. Although only one of those will ever be set in a given configuration and the downstream USB_PORT_ENABLE_COUNT value should always be correct, a lot of older code uses one combination of an upstream value and the downstream one depending on where the code lives and what configuration it assumes. Fixing all users would be a large and difficult-to-make change, so this change only makes the Zephyr behavior consistent with ECOS. One board depended on the dumb symbol being defined even when USB-A control is disabled completely, and is modified so it still builds. LOW_COVERAGE_REASON=uncovered board code is changed only to still build BUG=b:271571241 TEST=zmake build -a; twister BRANCH=nissa Change-Id: I5509159d969107216c8297b1424ab583c0b370c0 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4310766 Reviewed-by: Diana Z <dzigterman@chromium.org>
* tasks: Add extra SHELL task idRob Barnes2023-03-022-0/+16
| | | | | | | | | | | | | | | Add TASK_ID_SHELL to extra non-shimmed tasks list. get_shell_thread method also added to allow mapping between shell task id and shell thread. BUG=b:267470086 BRANCH=None TEST=Task unit tests Change-Id: Id49f983e2ae8b9e7359d5e5887f128985ea87786 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214559 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* gpio: Wrap gpio_get_default_flags by gpio_get_flagsDaisuke Nojiri2023-02-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | Currently, gpio_get_flags returns the runtime GPIO flags while gpio_get_default_flags return the compile time flags. This patch makes gpio_get_flags call gpio_get_default_flags if CONFIG_GPIO_GET_EXTENDED isn't defined so that callers will get the runtime flags by default and fall back to the compile time flags only if runtime flags aren't available. This patch itself introduces no behavior change (since currently gpio_get_flags is defined only if CONFIG_GPIO_GET_EXTENDED is defined). Callers should individually switch to gpio_get_flags if it's calling gpio_get_default_flags by mistake. BUG=None BRANCH=None TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I714bf8ea135d3c91a8cefcc3a1ba577f5650200d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3712029 Reviewed-by: Jes Klinke <jbk@chromium.org>
* zephyr: make bc1.2 optionalTing Shen2023-02-241-1/+3
| | | | | | | | | | | | | | | | For devices that don't support bc1.2, the code should not depend on anything related to usb_charge module (e.g. bc12_ports) BUG=b:269989432 TEST=zmake build --all BRANCH=none Change-Id: I6be47485bbd606f93a581d1638b3402337233b7c Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4274111 Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* system_safe_mode: Use common method for identifying critical tasksRob Barnes2023-02-161-38/+16
| | | | | | | | | | | | | | | | | | | Legacy EC uses tasks, Zephyr uses threads, so separate methods were used to identify critical tasks/threads. This change switches Zephyr EC to use task ids to identify critical tasks. This allows some duplicate code to be removed and avoids the CONFIG_THREAD_MONITOR dependency. This relies on the tasks shim for mapping between task ids and thread ids. BUG=b:266696987 BRANCH=None TEST=Observe threads being disabled when safe mode runs Change-Id: I87bcb7de87b0575cfc5d90bd12b21314ddeea093 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214562 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tasks: Add task_id_to_thread_id and thread_id_to_task_idRob Barnes2023-02-151-7/+51
| | | | | | | | | | | | | | | | | | | Add thread_id_to_task_id and thread_id_to_task_id for mapping between Zephyer thread ids and EC task ids. This change allows for looking up threads without the need of CONFIG_THREAD_MONITOR which costs ~1.5KB of additional flash. Add new tests for checking the mapping between tasks and threads. BUG=b:267470086 BRANCH=None TEST=Unit tests Change-Id: I9c7ef4d14248bfac5aede9f14adc302342fbe9a6 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214561 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* tasks: Add extra MAIN task idRob Barnes2023-02-152-13/+31
| | | | | | | | | | | | | | | | | | Add TASK_ID_MAIN as a non-shimmed extra task. This task is only present when CONFIG_TASK_HOSTCMD_THREAD_DEDICATED is enabled. Add get_hostcmd_thread and get_main_thread helper methods. The hostcmd thread will be the same as the main thread when CONFIG_TASK_HOSTCMD_THREAD_MAIN is enabled. BUG=b:267470086 BRANCH=None TEST=Unit tests Change-Id: If61dca427686a9c3cf6fb05dc5ca4e5a87b47127 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214560 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* tasks: Add local get_syswork_thread methodRob Barnes2023-02-151-2/+7
| | | | | | | | | | | | | | | Add local get_sysworkq_thread method. Also add HAS_TASK_SYSWORKQ. This just cleansup the handling of the syswork task id. BUG=b:267470086 BRANCH=None TEST=Unit tests Change-Id: Ic665d33aa524edd5ab9902e5591bfa4b1a5263b0 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214558 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* tasks: Add extra IDLE task idRob Barnes2023-02-151-0/+15
| | | | | | | | | | | | | Add the idle task to the non-shimmed extra tasks list. BUG=b:267470086 BRANCH=None TEST=Unit tests Change-Id: I87cbbcd32777ab65de09c053a9098031f0950c3e Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214557 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* shim/panic: Fix CODE_UNREACHABLE when running testRob Barnes2023-02-141-3/+2
| | | | | | | | | | | | | | | | | | CODE_UNREACHABLE inisde k_sys_fatal_error_handler is disabled during tests. This was disabled because system_safe_mode needs to test returning from k_sys_fatal_error_handler. However this change will mask asserts in some cases. Switch to __ASSERT_UNREACHABLE which can be disabled on a per test basis. BUG=None BRANCH=None TEST=Unit tests Change-Id: I32e20a5358d85d059985c0cdf4a65ce37e454a80 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4246960 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Jeremy Bettis <jbettis@chromium.org>
* zephyr: shim: Add 1 second to alarm settingSam Hurst2023-02-111-1/+7
| | | | | | | | | | | | | | | | | | | | | | | Adding 1 additional second to alarm setting because the system_get_rtc_sec() function returns the number of seconds truncated to the nearest integer. This results in missed alarms if, for example, the actualvalue is 7.99 seconds and 7 seconds is returned. BUG=b:261377404 BRANCH=None. TEST=check rtc_alarm 1 test_that ${DUT_IP} power_Resume Cq-Depend: 4241078 Change-Id: I1c07ecb8db6a3f6779c48d89cc39a2df12f92d7f Signed-off-by: Sam Hurst <shurst@.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4237580 Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Tested-by: Sam Hurst <shurst@google.com> Commit-Queue: Sam Hurst <shurst@google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* tasks: Return TASK_ID_INVALID on errorRob Barnes2023-02-102-2/+2
| | | | | | | | | | | | | | | | | | Return `TASK_ID_INVALID` when `task_get_current` fails to find the current task instead of 0. 0 is a valid task id. `drivers.host_cmd_thread` test is also updated because it was dependent on this bug. By overriding `in_host_command_main` to return true when the fake main thread is running, `task_get_current` will return `TASK_ID_HOSTCMD` when the fake main thread is running. BUG=b:268477571 BRANCH=None TEST=Unit tests Change-Id: I2d5d6926cc9e2775a1c0e8141d760850bf25141b Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4240327 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: move usbc interrupt handler to shimJason Yuan2023-02-091-3/+80
| | | | | | | | | | | | | | | | | | | TCPC interrupt no longer uses gpio-int. Instead the shim tcpc completely handles its own interrupt. An optional config is added to allow projects to use the legacy tcpc interrupt. The program intelrvp is excluded from this CL. BUG=b:254148652 TEST=twister, usbc charging on villager, lazor, and xivu BRANCH=none Change-Id: Ieeb4fb61ca6cf8f44df212a6cf520d265cff5147 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4108942 Commit-Queue: zhi cheng yuan <jasonyuan@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Diana Z <dzigterman@chromium.org>
* Revert "panic: Publish EC_HOST_EVENT_PANIC on panic"Rob Barnes2023-02-061-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 98e00bb45940f1cf31216a20c7441364d43fd8fb. Reason for revert: On MKBP based boards, host_set_single_event will result in a mutex lock, which will fail when inside the panic ISR. See b/267681436. Original change's description: > panic: Publish EC_HOST_EVENT_PANIC on panic > > Publish EC_HOST_EVENT_PANIC when a panic occurs. > > The kernel may use this event to clean up before the system is reset > (e.g. sync the drive). > > This will be a no-op if the kernel doesn't handle it. > > BUG=b:258195448 > BRANCH=None > TEST=Observe event in kernel. Pass panic_event unit test. > > Change-Id: I34b9847778bf17dd113e81158bbbdf999ad2ca33 > Signed-off-by: Rob Barnes <robbarnes@google.com> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4063818 > Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> > Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Bug: b:258195448 Change-Id: I772ef77ec7e4661f1c98658b94e73941ad74d4f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4225911 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Rob Barnes <robbarnes@google.com> Reviewed-by: Ricardo Quesada <ricardoq@chromium.org> Commit-Queue: Rob Barnes <robbarnes@google.com> Auto-Submit: Rob Barnes <robbarnes@google.com>
* Zephyr: Add configs for F75303matt_wang2023-01-301-1/+39
| | | | | | | | | | | | | | | | | | The F75303 driver needs a Kconfig, and needs to build in zephyr. Add support to the device tree parsing and definition for the F75303 i2c temperature sensors. LOW_COVERAGE_REASON=no emulator for the F75303. b:266089368 BUG=b:262409595 BRANCH=none TEST=build the project that using the F75303 success.(mushu nami markarth) Change-Id: Id769718fbcda3e4213c50c90c9c7918bc0a31a43 Signed-off-by: matt_wang <matt_wang@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4142061 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Chao Gui <chaogui@google.com> Reviewed-by: Chao Gui <chaogui@google.com>
* 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>
* zephyr/shim/led_driver: Add EC_LED_COLOR_INVALID enum valueRobert Zieba2023-01-192-4/+6
| | | | | | | | | | | | | | | | | | | | 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-191-51/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* console: Make it obvious when printk is used for console outputAndrew McRae2023-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Prepend any console messages printed by printk with a marker so that it is obvious. Console output uses printk when invoked from an ISR, and since printk is unbuffered and no mutual exclusion is used, it can be expensive. By highlighting the messages, they can be considered for converting to Zephyr logs. BUG=b:265594963 TEST=Verify that printk messages are marked as desired (e.g DPTF). BRANCH=none Change-Id: Id743cf1ff46dc2d2da0e5c49a96a07378ca7021f Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4165984 Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr:drivers: power button driverAl Semjonovs2023-01-175-0/+186
| | | | | | | | | | | | | | Add power button driver using Zephyr gpio-keys APIs BUG=b:234728861 BRANCH=NONE TEST=./twister -T zephyr/test Change-Id: I8399f7f0689657b6444a300021161cb8a89c50db Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4139709 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* console: Optionally drop output from ISRsstabilize-15317.B-mainAndrew McRae2023-01-171-3/+9
| | | | | | | | | | | | | | | | Optionally drop console output originating from interrupt level, to avoid printk locking up the EC for any length of time. BUG=b:265594963 TEST=Verify that logs from ISRs are not printed. BRANCH=none Change-Id: Ib6241d66bb3ec518439b46860804d928fd3fcfdf Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4165986 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* flash: allow zero num_banks_desc in flash_info requestTing Shen2023-01-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | Some external tools (e.g. flashrom) sends EC_CMD_FLASH_INFO with num_banks_desc=0 to get the total number of banks. EC should allow this type of request. Also add a test to cover this use case. BUG=b:265472751 TEST=1) `flashrom -p ec -w <ec.bin>` on tentacruel 2) ./twister -T zephyr/test/drivers/ \ --sub-test drivers.flash.page_layout 3) ./twister -T zephyr/test/drivers/ --sub-test drivers.flash BRANCH=none Change-Id: Iab97ac754bac87067f949cf9435156be91b07ebc Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4167539 Tested-by: Chen-Tsung Hsieh <chentsung@chromium.org> Reviewed-by: Patryk Duda <patrykd@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Patryk Duda <patrykd@google.com>