summaryrefslogtreecommitdiff
path: root/zephyr/shim/src
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: riscv: Drop gp register from panic dataJack Rosenthal2021-09-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | In v2.7, the gp register was removed from the data collected during a fatal error. See this PR for more details: https://github.com/zephyrproject-rtos/zephyr/pull/36235 Since that PR implies gp has no useful value, let's just drop it from the panic data. BUG=b:198824039 BRANCH=none TEST=build with Zephyr main branch for hayato note: still fails at link step due to missing symbol "_image_rom_size" Change-Id: Ia917d50c193fd2e493612a6d2dd6c0c6d92a1e6b Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3160405 Commit-Queue: Keith Short <keithshort@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: Cleanup I2C initializationKeith Short2021-09-141-6/+8
| | | | | | | | | | | | | | | | Move the I2C initialization to compile time, saving a modest amount of RAM space BUG=b:199328071 BRANCH=none TEST=zmake testall TEST=boot Zephyr on Herobrine. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I9d324eedca25666bcce1928b069918a357cf6081 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3158973 Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: I2C cleanupKeith Short2021-09-141-10/+7
| | | | | | | | | | | | | | | | | | | Zephyr does not use the GPIO based I2C recovery. Delete i2c_get_line_levels() and I2C_CONFIG_GPIO() as these symbols are no longer referenced. Move a the DT_NODE_EXISTS to the top of the file as the named-i2c-ports node is need throughout this file. BUG=none BRANCH=none TEST=zmake testall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I62cec339b448b78d1e9ca150227f604f23af32f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3158972 Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: Use NOP to wait for the external reset from H1Wealian Liao2021-09-131-6/+15
| | | | | | | | | | | | | | | | The current initial stage couldn't use the kernel delay function. Use CPU nop instruction to wait for the external reset from H1. BUG=b:182875520 BRANCH=none TEST=Enable CONFIG_BOARD_RESET_AFTER_POWER_ON for evb & toggle GPIO. Check the delay is 2 seconds. Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: If221181358c2a4df758d5bb9b57c3fbba31100aa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3143633 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: shim/system: fix APIs of call BBRAM read and writestabilize-14217.B-mainTim Lin2021-09-131-10/+10
| | | | | | | | | | | | | | | | | | | | The APIs of BBRAM read and write have been renamed and moved to drivers/bbram. The related call routines of shim/system.c need to be fixed. BUG=b:195843756 BRANCH=none TEST=the board of asurada and it8xxx2_evb can boot EC and access bbram successfully after adding this CL. zmake testall --> pass Change-Id: I98e51a278a24eeb4bbc92343fe6fc97e3e758e8a Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3153117 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: shim: set pwm_led data from device treeFabio Baltieri2021-09-102-0/+38
| | | | | | | | | | | | | | | | Set up the pwm_leds data from the device tree, gets rid of most static map defines and sets CONFIG_LED_PWM_COUNT automatically. BRANCH=none BUG=b:177452529 TEST=build and run on volteer TEST=compared the built up pwm_leds structure with gdb Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib41faf86ae018f5a1ed8a1c96c4b6ec081e175d9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3154256 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: fix compilation of kx022 driverMichał Barnaś2021-09-092-2/+2
| | | | | | | | | | | | | | | Add EC root directory to include directories list and fix include directive in kx022 driver info file. BRANCH=main BUG=b:194424288 TEST=Compilation for lazor should work correctly. Change-Id: I1312b4cac8695e61936b9635c7a59c2f59907502 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3129961 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: hooks: use k_work_reschedule to schedule deferred tasksJack Rosenthal2021-09-081-1/+1
| | | | | | | | | | | | | | | | k_work_reschedule will reschedule a work item if it's already been scheduled. Switching from k_work_schedule to k_work_reschedule fixes us the hooks test snag we saw during the v2.6 uprev. BUG=b:195971523 BRANCH=none TEST=zmake testall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I66f6bbad1cd39847e68a178165c9c59922abbb7c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3144378 Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: Replace DT_ENUM_TOKEN with DT_STRING_TOKENJack Rosenthal2021-09-077-39/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Zephyr v2.7, DT_ENUM_TOKEN is deprecated in favor of DT_STRING_TOKEN. Additionally, DT_ENUM_UPPER_TOKEN is deprecated in favor of DT_STRING_UPPER_TOKEN. See the v2.7 release notes for details: https://docs.zephyrproject.org/latest/releases/release-notes-2.7.html Since we backported the DT_STRING_* macros to our v2.6 branch, let's switch to them ahead of time to prepare for the v2.7 uprev. Note: the DT_STRING_* macros are compatible with Zephyr's device tree enums, but also allow non-enum properties to be used in the same fashion. This commit does the bare minimum for compatibility with v2.7, i.e., just swap the macros without dropping enum properties anywhere. We should investigate whether we want to continue using the enum properties or abandon some of them for any string in the future. BUG=b:198824039 BRANCH=none TEST=zmake testall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I1efd8f99bc7d93504c0ab94510406cd36ad24cd3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3144536 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: console: Use DT bindings to get shell uart dev on 2.7+Jack Rosenthal2021-09-071-24/+15
| | | | | | | | | | | | | | | | | | | In Zephyr 2.7+, CONFIG_UART_SHELL_ON_DEV_NAME is removed in favor of using the zephyr,shell-uart device chosen by the UART driver. Since we choose zephyr,shell-uart on all of our boards, we are clear to make this change ahead of the v2.7 uprev. Also see https://github.com/zephyrproject-rtos/zephyr/pull/37902. BUG=b:198824039 BRANCH=none TEST=zmake testall TEST=compile posix-ec with v2.7_rc1 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ic066ce0617fa900ae7c1c96a2cbece0b698764bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3142750 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: add batteries to device treeMichał Barnaś2021-09-032-0/+71
| | | | | | | | | | | | | | | | | | | | | | This commit adds possibility to define board's batteries in device tree. Default battery is defined by adding "default_battery" as node's label. It also adds common batteries definitions that can be used using compatible string. If no 'batteries' node is defined in device tree, custom board's logic must be used and old "named-batteries" should be defined. BRANCH=main BUG=b:183544739 TEST=This commit shouldn't change behaviour of any build. Compiling and flashing CrOS EC and Zephyr should work without problems. Change-Id: I94f0121f45eb061f1358fadbcd7d8006c08b0bea Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3107385 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: Add test runner task idTomasz Michalec2021-09-021-0/+16
| | | | | | | | | | | | | | | | | Code calling task_get_current() requires to return from this function valid task ID. To test this code, new TASK_ID_TEST_RUNNER is introduced. Test can set current thread as test runner and guarantee that task_get_current() return valid task ID. BUG=b:184856919 BRANCH=none TEST=none Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: Id5470e5337ab2419aad07f0f22de5f1576e870c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3110086 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: test: drivers: add eSPI test using host commandYuval Peress2021-08-312-5/+11
| | | | | | | | | | | | | | | | | | | | Verify that we can call host commands from driver tests by adding a test that calls the EC_CMD_GET_PROTOCOL_INFO host command. Add a few convenience functions to host_command.h when building with CONFIG_ZTEST enabled. Also, add eSPI emulator to support the test. Coverage: - lines 17.4% -> 17.8% - functions 21.4% -> 22.0% BRANCH=none BUG=b:189954415 TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib9e750eeab555ea629a560cbf3beed28e346c460 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3031842 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* adc: Allow runtime config of adc_channelsCaveh Jalali2021-08-271-0/+5
| | | | | | | | | | | | | | | This adds the CONFIG_ADC_CHANNELS_RUNTIME_CONFIG config option to allow the adc_channels array to be tweaked at runtime. BRANCH=none BUG=b:183452273,b:181271666 TEST=buildall passes Change-Id: I1241012b6e36c19baa7fe80853a6c6de4affeefa Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3116990 Reviewed-by: Boris Mittelberg <bmbm@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* common: move standard library functions from util.c to another fileMichał Barnaś2021-08-252-356/+0
| | | | | | | | | | | | | | | | | | This commit moves some of the standard library functions from util.c file to util_stdlib.c file. It will allow to use util.c for both CrOS EC and Zephyr builds and will make shim util file unnecessary. BRANCH=main BUG=b:177096231 TEST=Build both, CrOS EC and Zephyr firmwares Compilation should finish without any problems After flashing, both versions work as they should Change-Id: If6f930a04d28bec35faa16759f43b36176bf3de7 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3081827 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* system: fix system_get_scratchpad APIYuval Peress2021-08-201-11/+7
| | | | | | | | | | | | | | | The current API for system_get_scratchpad mixes the status and the value being read. Update the signature to allow both. BRANCH=none BUG=b:195481980 TEST=make testall && zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I3a5f5ad523d507c53a5d474806f58afafb82e70c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3074828 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: Disable console help stringsKeith Short2021-08-181-1/+8
| | | | | | | | | | | | | | | | | | Add support for disabling the console command help strings. With CONFIG_SHELL_HELP=n, 2000 bytes saved on Volteer BUG=none BRANCH=none TEST=zmake testall TEST=Verify console on Volteer with and without CONFIG_SHELL_HELP enabled. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I2186828f28691182f673851ac27d207b4a4a6f44 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3093492 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: reduce code duplication of console shimKeith Short2021-08-181-12/+9
| | | | | | | | | | | | | | | | | | Change the console command shim to pass in a struct, reducing the amount of duplicated code. This change saves 500 bytes on Volteer BUG=none BRANCH=none TEST=zmake testall TEST=verify console on Volteer Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I2da374b9a3b3b78a3e7b66d5c31f4ed2131aef01 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3093491 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: provide unified method to get sku id and board versionMichał Barnaś2021-08-183-0/+100
| | | | | | | | | | | | | | | | | | | | | | Previously, functions for reading board version and sku id were defined in board.c files which are not compiled in Zephyr builds. Logic from board.c files should be moved to the DeviceTree files. This commit adds support for defining board version and sku id pins and numeral system used to decode them. BRANCH=main BUG=b:194136536 TEST=Call system_get_sku_id and system_get_board_version on CrOS EC and Zephyr, values should be correct and the same on both versions Change-Id: I61b5e205cb2a2299ad86c5dff38c05a9659eb2d3 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3048102 Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Wai-Hong Tam <waihong@google.com> Tested-by: Wai-Hong Tam <waihong@google.com>
* zephyr: add support for switchcap in device treeMichał Barnaś2021-08-163-0/+102
| | | | | | | | | | | | | | | | | | This commit adds support for switchcap definition in device tree. It will allow to remove board specific files which implemented the switchcap functionalities. This will unify the logic between different board in zephyr. BRANCH=main BUG=b:194211207 TEST=Use linked TEST commits to see example of definitions for lazor Use GPIO or LN9310 version, build and flash to lazor. Board should be able to boot correctly. Signed-off-by: Michał Barnaś <mb@semihalf.com> Change-Id: Ib80a73dcb2db95e2dcf48e33f876a39246fd506a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3085670 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: shim: cleanup comments and code in console.cDenis Brockus2021-08-121-5/+8
| | | | | | | | | | | | | | | BUG=none BRANCH=none TEST=none Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Iab1f8a1274e94491590697ad1efffdca46cb8e4c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3088235 Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Fix keyscan_configWealian Liao2021-08-121-2/+2
| | | | | | | | | | | | | | | | DT_DRV_COMPAT doesn't have the compatible node. Fix it to use cros_keyscan. BRANCH=none BUG=none TEST=zmake testall TEST=check volteer & lazor key by "ksstate on" Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Ib1280f64ac2fa42539fb93d24922626c9adf2278 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3088960 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: cleanup Zephyr v2.5 ifdefsJack Rosenthal2021-08-112-18/+0
| | | | | | | | | | | | | | We no longer support version 2.5. Drop these obsolete ifdefs. BUG=b:195571108 BRANCH=none TEST=zmake testall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I85985108bcf175a2756a2f8096b0aa9e3c22fce5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3086368 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: shim: zephyr_print option to use printkDenis Brockus2021-08-111-1/+9
| | | | | | | | | | | | | | | | | | | | Some devices are not able to output fast enough using shell_fprintf and they timeout unrelated functionality. For this case it will be allowed to use a define CONFIG_PLATFORM_EC_CONSOLE_USES_PRINTK to force zephyr_print to use printk BUG=b:193585176 BRANCH=none TEST=zmake configure -b $PROJ_HAYATO Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I8a08fc730637e1d9e2b612b877572fac235a4be4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3082328 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Create devicetree node for keyscanKeith Short2021-08-102-0/+35
| | | | | | | | | | | | | | Create devicetree node to specify the keyscan runtime parameters. BUG=b:195945894 BRANCH=none TEST=zmake testall TEST=verify keyboard on Volteer with next CL Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I4dbf5e4f2205f31651d33b6ffc1ecd1dd6696795 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3083721 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: shim: reimplement hooks using iterablesFabio Baltieri2021-08-101-12/+14
| | | | | | | | | | | | | | | | | | Reimplement the hooks shim code using Zephyr iterable sections. Keep the existing hook_registry based structure, gets rid of the per-hook init functions and instead initializes all the list nodes from a single init call. BRANCH=none BUG=b:195521227 TEST=build and run on volteer Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ic166d214ee1dcd1431ec484e5014cb297f7fb8c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3069399 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: shim: reimplement mkbp_event using iterablesFabio Baltieri2021-08-101-18/+3
| | | | | | | | | | | | | | | Rewrite the MKBP events shim using iterable sections. BRANCH=none BUG=b:195521227 TEST=build and run on volteer Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ia96fb9ec06b1a86b1be293209db317a361ae4741 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3069398 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: shim: reimplement host commands using iterablesFabio Baltieri2021-08-101-24/+3
| | | | | | | | | | | | | | | | | Rewrite the host command shim using Zephyr iterable sections. This allows initializing the HC structure statically and gets rid of the runtime init code entirely. BRANCH=none BUG=b:195521227 TEST=build and run on volteer Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I94a55f8eb3e1d58de6a1d93c31b6170a5541a1fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010284 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: shim/src: task: add in_interrupt_context routineTim Lin2021-08-051-0/+5
| | | | | | | | | | | | | | | This routine is needed when enable CONFIG_HOST_COMMAND_STATUS. This routine allows the caller to customize its actions, depending on whether it is a thread or an ISR. BUG=b:195342437 BRANCH=none TEST=zmake testall Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: Id2a948c67de81fbc8ee161e5711cff17b8ac359d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3070941 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: Move BBRAM access functions to common system.cWealian Liao2021-08-042-26/+68
| | | | | | | | | | | | | | | | | | NPCX & IT8xxx2 series are both use BBRAM for scratchpad/reset_flags access. cros_bbram API already handles the chip-specific code. This CL moves scratchpad/reset_flags access functions to the common system.c to avoid duplicate those functions. BUG=none BRANCH=none TEST=zmake testall TEST=check reset cause on lazor & npcx_evb Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I0a394e5fbf784ec2e3caea77f194c88ae9d5542e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3067156 Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Yuval Peress <peress@chromium.org>
* zephyr: i2c: protect physical portDino Li2021-07-221-0/+17
| | | | | | | | | | | | | | | | | | If i2c devices are connected to the same port, they should use the same mutex_lock() index. So the new transaction won't break the ongoing transaction. BRANCH=none BUG=b:189855648 TEST=Enable CONFIG_SMBUS_PEC and voltage regulator function on asurada. No i2c transaction is broken. Change-Id: Ib848e3c2e60b99ce66ad5fd2fc7095f90820a15d Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010920 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* zephyr: Remove NPCX dependency from shim/src/espi.cYuval Peress2021-07-221-6/+5
| | | | | | | | | | | | | | | | Allow building the zephyr/shim/src/espi.c for other SOCs by adding inline functions to abstract away these concepts. Each SOC should then implement these under the zephyr/shim/chip/<soc> specific directory. BRANCH=none BUG=b:189954415 TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I776bd65326b509ada3b271177ae727a32d4f96da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3044400 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: fix uart output flushDawid Niedzwiecki2021-07-151-0/+6
| | | | | | | | | | | | | | | | | | | Make sure the whole UART buffer/fifo is flushed in the uart_flush_output function by checking the interrupt state. The shell_process function only passes data from shell layer to the shell_trasport layer(UART) which has its own buffers. The bug was impacting e.g. hibernating. BUG=b:191724484, b:193482737 BRANCH=none TEST=Verify the console output and hibernate works Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Iaf245809be57fdba69c6a5a69d394f024ccf60ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3024264 Reviewed-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* cbi: Introduce CONFIG_CBI_GPIOPhilip Chen2021-07-141-0/+1
| | | | | | | | | | | | | | | | | | | For the boards where SKU_ID/BRD_ID comes from the strapping pins on EC, this new config enables AP to ask EC for those hardware configs using the CBI host command `EC_CMD_GET_CROS_BOARD_INFO`. BRANCH=None BUG=b:186264627 TEST=make buildall -j TEST=Enabled CONFIG_CBI_GPIO for lazor and manually verified with `ectool cbi get`. Change-Id: I7ec9097bab96d2076d9d42db2d003460db000113 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3002452 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* zephyr: implement panic register print for riscvJack Rosenthal2021-07-131-1/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement panic register print for rv32i. This lets us see the registers after a crash, which is very useful for debugging. BUG=b:193552648 BRANCH=none TEST=got a crash, see this on UART: Fatal error: 0 ra = 0x80005864 gp = 0x8010D3C0 tp = 0x00000000 a0 = 0x00000000 a1 = 0x00000000 a2 = 0x00000000 a3 = 0x00000000 a4 = 0x80107FC0 a5 = 0x00000500 a6 = 0x00000000 a7 = 0xAAAAAAAA t0 = 0x00000000 t1 = 0x8010D298 t2 = 0x435F4450 t3 = 0x00000030 t4 = 0x00000000 t5 = 0x00000000 t6 = 0x00000000 mepc = 0xFFFFFFF4 mstatus = 0x00001880 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I5b91276d274f5792ff6b9136adc319d03ed6dbb3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3024958 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: shim: implement a stub signal_is_gpioFabio Baltieri2021-07-131-0/+5
| | | | | | | | | | | | | | | | | Implement a signal_is_gpio to have the system compile with CONFIG_ASSERT=y. The function is used to check if the line is SoC GPIO, but there's no platform with that setup right now, so just returning true for the moment. BRANCH=none BUG=none TEST=build and run on volteer with asserts enabled Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I41d3c11d0915ce5b6e888d7152fb3c3bdc43d054 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3017986 Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Yuval Peress <peress@chromium.org>
* zephyr: switch to using shell_*, not printkDawid Niedzwiecki2021-07-091-10/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reimplement the printf functions for Zephyr to use shell_* functions instead of printk. The main differences are: -UART output is buffered by the shell layer. The size of the buffer should be adjusted per board (SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE) -The shell uses non-blocking UART FIFO operations while printk waits actively for every sent byte. -The shell prints can not be split by the other shell prints so it should increase the quality of the output. However the shell_* functions can not be used in interrupts, so use printk instead which can divide the shell output. The output may be messy for boards that have a lot of prints in interrupts e.g. volteer. EC uses unusual print format e.g. "%pT" to print a timestamp, so use the CrosEC's vfnprintf function and then pass the generated string to the shell_* print. Use the sprintf function for that purpose. Long term, the EC codebase should switch to a usual print format, so shell_* can be used directly and not 2 versions of vfnprintf. This change should also help to pass tests that wait for a certain pattern on output e.g. ECBootTime. BUG=b:191724484, b:178033156 BRANCH=none TEST=Verify the console output works Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ifaed2093ab8c43038c7d3e0ded1449a93f7f7da5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2988194 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: shim: Support reading tri-state GPIOPhilip Chen2021-07-092-0/+75
| | | | | | | | | | | | | | | | Copy gpio_get_ternary() and binary_first_base3_from_bits() to zephyr. BRANCH=None BUG=b:186264627 TEST=zmake testall Change-Id: I7086668a33da095132dbccae0f41264b59b1b20e Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3015243 Tested-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: panic: Clean-up panic printingYuval Peress2021-07-081-5/+7
| | | | | | | | | | | | | | | If CONFIG_LOG is enabled we can let the default handler print the panic information. It is much more detailed. BRANCH=none BUG=b:180422087 TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Idefa9992aad7d69b8aa01394a5b509e592809e8b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3015239 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: implement irq functions for tasksDino Li2021-07-071-2/+4
| | | | | | | | | | | | | | | Implement irq functions for tasks. BRANCH=none BUG=b:190203712 TEST=can zmake hayato and it8xxx2_evb Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Change-Id: Ic35ed656f10a1b24543145421843b540a6cbc5a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2988744 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: change host console shim interfaceDawid Niedzwiecki2021-07-022-15/+21
| | | | | | | | | | | | | | | | | | | Allow passing a whole string to the console buffer, which is sent to host. This should speed up printing because a mutex doesn't have to be locked for every char separately. BUG=b:191724484 BRANCH=none TEST=Make sure buffering of console to host works with the 'ectool console' command Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I5b081984bfa4f930ad4729b19975b1c2eb4bbd18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2988193 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr/drivers: npcx: reorganizes the flash driver(3)Tim Lin2021-07-011-56/+4
| | | | | | | | | | | | | | | | | | | | | Move NPCX specific code crec_flash_physical_get_protect(), crec_flash_physical_get_protect_flags(), crec_flash_physical_protect_at_boot(), and crec_flash_physical_protect_now() from shim/flash.c to cros_flash/cros_flash_npcx.c. BUG=b:187192628 BRANCH=none TEST=zmake -lDEBUG configure -b -B zephyr/build_volteer \ zephyr/projects/volteer/volteer/ Cq-Depend: chromium:2994430 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: Id6ed382ad4578969838339c9eb874b323390c485 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2891674 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org>
* zephyr/drivers: npcx: reorganizes the flash driver(2)Tim Lin2021-07-011-29/+0
| | | | | | | | | | | | | | | | | | Move NPCX specific code flash_dev_init(), crec_flash_physical_write() and crec_flash_physical_erase() from shim/flash.c to cros_flash/cros_flash_npcx.c. BUG=b:187192628 BRANCH=none TEST=none Cq-Depend: chromium:2994429 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: I094e26c5b670402872a665ba4d24a6594f7ca77e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2994430 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr/drivers: npcx: reorganizes the flash driver(1)Tim Lin2021-07-011-194/+0
| | | | | | | | | | | | | | | | | | | Move the flash protection routines flash_get_status1() through flash_write_prot_reg() from shim/flash.c to cros_flash/cros_flash_npcx.c. BUG=b:187192628 BRANCH=none TEST=none Cq-Depend: chromium:2891674 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: Iaca3a32cfb35a77df10b87745bdabc1ed1cd3c40 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2994429 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org>
* zephyr: Fix duplicate ec consoleYuval Peress2021-06-301-10/+17
| | | | | | | | | | | | | | | | Logs in /var/log/cros_ec.log contained many duplicate entries. This was caused by not moving the actual head pointer when reading from the buffer. BRANCH=none BUG=b:180423400 TEST=Flash lazor and observe /var/log/cros_ec.log Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I7951d2fc3e6f13a5d6aebcf0b347238bcb790973 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2995713 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: tasks: fix task id for deferred callsTomasz Michalec2021-06-301-0/+8
| | | | | | | | | | | | | | | In Zephyr deferred calls are run in k_sys_work_queue context instead of thread running hook_task(). Because of that shimmed task_get_current() is modfied to return TASK_ID_HOOKS if run from k_sys_work_queue context. BUG=b:190727776 TEST=make hosttest BRANCH=none Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I9e15627df8dce6b0829ad872150cbe2318330f28 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953225 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: use DEVICE_DT_GET for phandle referencesFabio Baltieri2021-06-284-12/+10
| | | | | | | | | | | | | | | Convert few device_get_binding based on DT_PROP_BY_PHANDLE to DEVICE_DT_GET. BRANCH=none BUG=none TEST=zmake configure -b -B ~/build-volteer/ zephyr/projects/volteer/volteer TEST=zmake configure -b -B ~/build-it8xxx2_evb/ zephyr/projects/it8xxx2_evb Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib8feee8de759481b833010be815cdeb8178f3710 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2985464 Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: use DEVICE_DT_GET for various shim modulesFabio Baltieri2021-06-286-22/+33
| | | | | | | | | | | | | | | | Convert various device_get_binding to DEVICE_DT_GET, which is processed at link time and more efficient. Same pattern on different modules where the output is checked using device_is_ready. BRANCH=none BUG=none TEST=zmake configure -b -B ~/build-volteer/ zephyr/projects/volteer/volteer TEST=zmake configure -b -B ~/build-it8xxx2_evb/ zephyr/projects/it8xxx2_evb Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: If426420da2c61b3bc02eb77e122469a1a40799f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2985463 Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: Migrate to v2.6 deferred work APIsYuval Peress2021-06-221-1/+13
| | | | | | | | | | | | | | | | Update deferred work API calls to work with v2.6. Currently, these will give warnings, but most of these have been replaced completely in upstream Zephyr's main branch. BRANCH=none BUG=b:190731415 TEST=zmake configure -b zephyr/projects/trogodr/lazor Change-Id: I99e71089439656a8a45ff35ce489e21ad60f2143 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2980433 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* zephyr: gpio: Fix assert for init_gpios()Wealian Liao2021-06-221-2/+1
| | | | | | | | | | | | | | | gpio_pin_interrupt_configure() without interrupt flag generates the assert. Change to use gpio_pin_configure(). BUG=b:190731415 BRANCH=none TEST=Lazor boot to OS screen Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I2e4b816ba52a8746bb694ad55d551b427868302a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2977861 Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Yuval Peress <peress@chromium.org>