summaryrefslogtreecommitdiff
path: root/zephyr/shim/src
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: Add watchdog reinstall mechanismWealian Liao2021-09-281-0/+7
| | | | | | | | | | | | | | | | | After the sysjump, the watchdog has been installed by the last image. The watchdog install function return -EBUSY while the watchdog has already been set up. This CL adds watchdog running check & reinstall watchdog for sysjump. BUG=none BRANCH=none TEST=RO/RW use the different timeout setting & test the timeout. Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Ibe36d50c030afcfe79eb804ca05c7b426468cb07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3180705 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* zephyr: drivers: thermistors are device tree nodesAaron Massey2021-09-242-28/+73
| | | | | | | | | | | | | | | | | | | Thermistor drivers now query the device tree for configuration. Thermistor tests have been updated to be parameterized on all thermistors enabled in the device tree. BRANCH=none BUG=b:184374937 TEST= 1) zmake testall 2) make runhosttests Cq-Depend: chromium:3161332 Signed-off-by: Aaron Massey <aaronmassey@chromium.org> Change-Id: Ic5330cd5c33e79e192428ca857651de9a225856e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3133812 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Aaron Massey <aaronmassey@google.com> Commit-Queue: Aaron Massey <aaronmassey@google.com>
* zephyr: shim: implement a generic led_get_brightness_rangeFabio Baltieri2021-09-221-0/+14
| | | | | | | | | | | | | | | | | | | Implement a generic led_get_brightness_range function using static values from the device tree. This is currently ignoring led_id, but no pwm_led based device is using it right now anyway, so this could cover all existing use cases. BRANCH=none BUG=b:177452529 TEST=called the function, verified the values in runtime Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I67dc7564eb6724e401961261ff5cc5892899ad5f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3170401 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: fix support for multiple fansMichał Barnaś2021-09-221-4/+4
| | | | | | | | | | | | | | | | | This commit fixes macros used to create named-fans instances. It will enable to have multiple named-fans declared in devicetree without raising "multiple definitions" error during compilation. BRANCH=main BUG=none TEST=Add named-fans instance in device tree and build firmware. Compilation with 2 or more names-fans should work correctly. Change-Id: If5c9a74f743749efc3a2872b0ced98500e96ca52 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3176200 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: shell: add alias for kernel threads commandMichał Barnaś2021-09-221-0/+9
| | | | | | | | | | | | | | | Add taskinfo command as alias for "kernel threads" for backward compatibility with CrOS EC. BRANCH=main BUG=b:190224781 TEST=Check that taskinfo correctly executes "kernel threads" command Change-Id: Ibdce9d8342fb7a99577b1f8d031c419fa485e7b0 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3174058 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: shim: define led_color_map from the devicetreeFabio Baltieri2021-09-221-0/+9
| | | | | | | | | | | | | | | | | | | This adds a set of properties for color mapping in the device tree for the pwm-leds device, and maps them to the internal "struct pwm_led_color_map". BRANCH=none BUG=b:177452529 TEST=compared the structure on gdb TEST=build and run on volteer Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib3a704afccad40eab7115371dbf72c568f5602d9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3170400 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: Restructure GPIO interrupt table to save RAMKeith Short2021-09-181-12/+38
| | | | | | | | | | | | | | | | | | Restructure the GPIO interrupt table to separate the constant data from the data that needs to be updated at runtime. On Herobrine, this saves 180 byts flash and 240 bytes RAM. BUG=b:199328071 BRANCH=none TEST=zmake testall TEST=Boot zephyr on herobrine Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I096aec5b00fd7dc661db326a278ab44a0a1286da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3169563 Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: minor reorganization of GPIO shimKeith Short2021-09-171-18/+19
| | | | | | | | | | | | | | Move a comment and a function to make the next CL cleaner. BUG=none BRANCH=none TEST=none Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I83185db995b083f839709eb564353a66364e87d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3169562 Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: Add test runner in shimmed taskTomasz Michalec2021-09-151-11/+14
| | | | | | | | | | | | | | | | | | | Some functions requires to call task_wait_event in test task context. Because of that there is needed shimmed_tasks entry for TASK_ID_TEST_RUNNER. BUG=none BRANCH=none TEST=make configure --test zephyr/test/drivers Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I92cd3776a827f9a7f9bb1faee67ed998260e23a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3159528 Tested-by: Tomasz Michalec <tmichalec@google.com> Tested-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Tomasz Michalec <tmichalec@google.com>
* zephyr: Add default mapping for remote I2C portsKeith Short2021-09-141-2/+6
| | | | | | | | | | | | | | | | | | For TCPC firmware updates, the host first queries the I2C port from the EC and passes this back during I2C passthrough operations. Default to a 1:1 mapping of the remote port to local port, if the devicetree doesn't explicitly set the remote-port property. BUG=b:197153501 BRANCH=none TEST=Boot zephyr with AUX firmware updates enabled in depthcharge, verify the TCPC firmware is updated. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ie45d302044e94c0325b36cc41c528fc0ca858384 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3158974 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: Automatically detect shared I2C portsKeith Short2021-09-141-4/+42
| | | | | | | | | | | | | | | | | | | Delete the "physical-port" node from named-i2c-ports, and automatically detected when multiple children point to the same I2C bus. This ensures that the I2C bus locking always blocks all matching I2C nodes, without the user needing to specify this relationship manually in the devicetree. BUG=none BRANCH=none TEST=Dump out i2c_physical_ports[] on herobrine. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I3d254684483a95af12e7940446f4cd8743684708 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3154694 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
* 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>