summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/CMakeLists.txt
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: shim: set pwm_led data from device treeFabio Baltieri2021-09-101-0/+1
| | | | | | | | | | | | | | | | 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: add batteries to device treeMichał Barnaś2021-09-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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>
* common: move standard library functions from util.c to another fileMichał Barnaś2021-08-251-1/+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>
* zephyr: provide unified method to get sku id and board versionMichał Barnaś2021-08-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | 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-161-0/+4
| | | | | | | | | | | | | | | | | | 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: Create devicetree node for keyscanKeith Short2021-08-101-0/+1
| | | | | | | | | | | | | | 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>
* 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>
* config: Rename CONFIG_CROS_BOARD_INFOPhilip Chen2021-06-161-1/+1
| | | | | | | | | | | | | | | | | | Rename CONFIG_CROS_BOARD_INFO to CONFIG_CBI_EEPROM to make it clear that the information comes from on-board EEPROM. It sets up the groundwork for adding more options of CBI sources later. BRANCH=None BUG=b:186264627 TEST=make buildall -j Signed-off-by: Philip Chen <philipchen@google.com> Change-Id: I9a6feee0a8b35bbf29e445544243485507767ad8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2945792 Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* zephyr: shim: move mpu code under core/cortex-mFabio Baltieri2021-06-141-1/+0
| | | | | | | | | | | | | | The MPU code is cortex-m specific, so move it out of shim/src and into shim/core/cortex-m. BRANCH=none BUG=b:180039888 TEST=build & run on volteer Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ic77d6f58751822e3dad461f9236f5b43da764164 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2961189 Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: move keyboard_raw most functions to shim/srcRuibin Chang2021-05-181-0/+1
| | | | | | | | | | | | | | | Move shim/chip/npcx/keyboard_raw.c most functions to shim/src/keyboard_raw.c. BUG=none BRANCH=none TEST=zmake -lDEBUG configure -B zephyr/build -b zephyr/projects/volteer/volteer Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Change-Id: Ic69752223517cabb9e1d1c7ff16c9eb4914186db Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2900122 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: Rework CBI to be used as a driverDawid Niedzwiecki2021-05-141-1/+1
| | | | | | | | | | | | | | | | | | Rework the CBI support in Zephyr to be used via driver API. Change also approach what to do with SSFC - let sensor drivers decide how to handle alternative sensors. BUG=b:183990188 BRANCH=none TEST=Add alternative motion sensors to the device tree, modify CBI SSFC with 'cbi set 8 value 4', reboot EC and verify that the new sensors are used with the 'accelinfo' command. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I701af96bfa7a17333220530a5c63b8e8aaeb0d6b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2862727 Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: Add CBI SSFC supportDawid Niedzwiecki2021-04-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some boards support different motion sensors based on the CBI SSFC field stored in EEPROM. The decision about which sensor is made in runtime thus all drivers have to be built-in. Define structure of the SSFC in the device tree("named-cbi-ssfc"), that allows using generic driver instead of board-specific code as it is done in CrosEC. Every SSFC field value("named-cbi-ssfc-value") is associated with an alternative sensor(or sensors) which will be used (instead of the one pointed by 'alternative-for' property) if the value in EEPROM matches. BUG=b:183990188 BRANCH=none TEST=Add alternative motion sensors to the device tree, modify CBI SSFC with 'cbi set 8 value 4', reboot EC and verify that the new sensors are used with the 'accelinfo' command. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I3b5f3c171005885d96b1fdf14e844aaf862b6818 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2851896 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* config: rename CONFIG_FLASH to CONFIG_FLASH_CROSJeremy Bettis2021-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 4ac1d81e1430dbfbfba1376a23ab19dfa845d7ef. The config name collides with the same config name in zephyr. Also, renames zephyr Kconfig CONFIG_PLATFORM_EC_FLASH to CONFIG_PLATFORM_EC_FLASH_CROS as the corresponding change at Kconfig side. BUG=chromium:1202406,b:180980668 TEST=make -j16 runhosttests buildall && zmake testall && \ /mnt/host/source/src/platform/ec/zephyr/firmware_builder.py --metrics \ /tmp/tmplt8ty8ci test ; echo $? BRANCH=none Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I5b5e58b30d936b5232e049827f458d9a2ed06340 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2855320 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* Revert "config: rename CONFIG_FLASH to CONFIG_FLASH_CROS"stabilize-13935.B-mainJack Rosenthal2021-04-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 4e074a16c5703f0cdd7b7d780a8ae1bea53a445a. Reason for revert: responsible for CQ failures (crbug.com/1202406) BUG=chromium:1202406 BRANCH=none TEST=CQ Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Original change's description: > config: rename CONFIG_FLASH to CONFIG_FLASH_CROS > > The config name collides with the same config name in zephyr. > > Also, renames zephyr Kconfig CONFIG_PLATFORM_EC_FLASH to > CONFIG_PLATFORM_EC_FLASH_CROS as the corresponding change at Kconfig > side. > > BUG=b:180980668 > TEST=make buildall > BRANCH=none > > Change-Id: Ibac008ddff8c041aae04dca0bbf973823abe7640 > Signed-off-by: Eric Yilun Lin <yllin@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2816622 > Tested-by: Eric Yilun Lin <yllin@google.com> > Reviewed-by: Keith Short <keithshort@chromium.org> > Commit-Queue: Keith Short <keithshort@chromium.org> Bug: b:180980668 Change-Id: Idc5e799d3b0ea8cc76dbbb49a91b3758ce6e9719 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2847274 Auto-Submit: Jack Rosenthal <jrosenth@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* config: rename CONFIG_FLASH to CONFIG_FLASH_CROSEric Yilun Lin2021-04-231-1/+1
| | | | | | | | | | | | | | | | | | | The config name collides with the same config name in zephyr. Also, renames zephyr Kconfig CONFIG_PLATFORM_EC_FLASH to CONFIG_PLATFORM_EC_FLASH_CROS as the corresponding change at Kconfig side. BUG=b:180980668 TEST=make buildall BRANCH=none Change-Id: Ibac008ddff8c041aae04dca0bbf973823abe7640 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2816622 Tested-by: Eric Yilun Lin <yllin@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: Enable link time optimization (LTO)Keith Short2021-03-241-29/+29
| | | | | | | | | | | | | | | | | | | The upstream Zephyr repo does not support LTO. Reconfigure the platform/ec source files into a cmake library so the LTO option can be enabled for all the platorm/ec sources. This reduces the Volteer flash image size by 9176 bytes. BUG=none BRANCH=none TEST=zmake testall TEST=boot zephyr-ec on Volteer, verfiy AP boots Cq-Depend: chromium:2776218 Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I8312773c8b21c498ec8116a8558b7571831159ff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2776217 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: use device tree for sensor configHyungwoo Yang2021-03-241-0/+2
| | | | | | | | | This change switches to use device tree for sensor configuration. Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: Ibadd91ce26520973ce4f70580e66abe484c0ca75 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2778825 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: add shim fanDawid Niedzwiecki2021-03-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add fan support to Zephyr. The fan is controlled with PWM and the fan speed is measured with the tachometer. Fan properties are defied in the dts file. The struct fan_t fans[] array and enum fan_channel are generated automatically according to named-fans node in the device tree. The implementation is based on the npxc driver, but it is platform-independent. It assumes that there are PWM channel to control the fan and the tachometer sensor to measure RPM (in RPM mode). If it is not the case in the future, the shim may be split per chip. Enable fan related console commands - fanduty, fanset, faninfo, fanauto and host commands - EC_CMD_PWM_GET_FAN_TARGET_RPM, EC_CMD_PWM_SET_FAN_TARGET_RPM, EC_CMD_PWM_SET_FAN_DUTY, EC_CMD_THERMAL_AUTO_FAN_CTRL. BUG=b:174851463 BRANCH=none TEST=build Zephyr TEST=Run "fanset"/"fanduty" commands and check with "faninfo" if the fan follows the command. Then run "fanauto" and verify that the fan controls the temperature correctly. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I52255848e271fb5b204cd1eb8a797e2fbc81130d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2729375 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: add shim thermal supportDawid Niedzwiecki2021-02-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add thermal support to Zephyr which includes handling temperature threshold for certain events. The thresholds are defined in the dts file as temperature sensor parameters - there are limits per temperature sensor. The struct ec_thermal_config thermal_params[] array with all parameters is generated automatically based on named_temp_sensors node. Enable "thermalget" and "thermalset" console commands along with EC_CMD_THERMAL_GET_THRESHOLD and EC_CMD_THERMAL_SET_THRESHOLD host commands. Also, add a few functions to utils needed to verify if an event occurred (falling/rising edge). BUG=b:179886912 BRANCH=none TEST=build Zephyr TEST=Run "thermalget" command to check current thresholds. Change the thresholds with "thermalset" to verify if AP throttling is requested. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I5f527ceecab2427b3034fd8baa62bb8482f99ff3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2698845 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: add watchdogWealian Liao2021-02-221-0/+1
| | | | | | | | | | | | | | | | | | | In npcx7 series, the Timer and Watchdog module (TWD) generates the clocks and interrupts used for timing periodic functions in the system. It also provides watchdog reset signal generation in response to a failure detection. This CL enables the watchdog functionality in zephyr system. BUG=b:176523207, b:177604307 BRANCH=None. TEST=add stall function to check the system can reset by the watchdog Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Iee0312dd6132ce76e622178b3a666aa415bc735a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2659135 Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
* zephyr: add shim temperature sensorsDawid Niedzwiecki2021-02-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Add temperature sensors shim. Use platform/ec the temperature sensors drivers. Generate needed global variables/types: enum temp_sensor_id and temp_sensors from dts. Each temperature sensor type has its own compatible property to assign a correct read function in the temp_sensor_t temp_sensors[] array. Themrmisors has also adc property to point an ADC channel connected to the sensor. Enable "temps" console command and EC_CMD_TEMP_SENSOR_GET_INFO host command. BUG=b:174851465 BRANCH=none TEST=build Zephyr TEST=Run "temps" command, it should return the current temperature measurements Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ie680ec0771ea3da598066eb98db80944a93daca5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2687218 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: Add support for CONFIG_MPUSimon Glass2021-02-131-0/+1
| | | | | | | | | | | | | | | | | | Add this option so that the Memory-Protection Unit (MPU) can be enabled. The implementation is still to be worked out. Note that CONFIG_PLATFORM_EC_EXTERNAL_STORAGE is not defined, as it should be. That work is ongoing elsewhere. BUG=b:180039888 BRANCH=none TEST=build zephyr volteer Build ECOS for volteer Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ie26e8ba4b3f0b8024930e42fbbb03f0f2a26f3da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2691566 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: implement console read/snapshot host commandsJack Rosenthal2021-02-111-0/+2
| | | | | | | | | | | | | | | | | | | | | Implement an optional console output buffer, and wire it up to the associated host commands. We don't use the EC's uart buffering module for this, as it implements a UART buffer which also is used for transmit buffering (we don't do that, and instead immediately send to printk). We don't use Zephyr's ring buffer structure for this as we need to track multiple heads due to the semantics of snapshots. BUG=b:178033156 BRANCH=none TEST="ectool console" on volteer Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ib1d39e32e8bad5b23b98034c33f56534a8c89fcb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2685412 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: add shim ADCDawid Niedzwiecki2021-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Add ADC shim to connect the platform/ec ADC API to the Zephyr ADC API. Generate needed global variables/types: enum adc_channel and adc_channels from dts. Once ADC_CMD config is enabled, it replaces the "adc" Zephyr console function. The shim assues only ADC_0 module. More specific channel options can be added to named-adc.yaml e.g. shift or gain. BUG=b:175881324 BRANCH=none TEST=build Zephyr TEST=Run "adc" command, it should return current levels in mv of configured channels Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ic9c03223e611f916bebc1296cbee614401098994 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2673418 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: flash/system: enable common/flash.c & common/system.cYuval Peress2021-02-031-2/+7
| | | | | | | | | | | | | | | | | | | Bring both flash.c and system.c into the build. zephyr/shim/src/system.c now includes only code that is needed to stub out the chip specific system.c implementation in platform/ec (which is now using the devicetree values). BRANCH=none BUG=b:176828988, b:174481378 TEST=zmake testall TEST=build volteer, flash, and test flashinfo. Cq-Depend: chromium:2631353 Change-Id: I5c542fca01dcc4af98401bcbbf402e579cd45e36 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2649463 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Enable base support for real-time-clock (RTC)Simon Glass2021-02-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add Kconfig options for the various RTC features. Add stubs for the actual implementation, to be implemented using Zephyr API calls to the RTC driver, when available. The duplication of RTC functions across different chips can be addressed in b/179055201 Also add the <init.h> header to zephyr_host_command.h since otherwise we get a build error. It seems better to have the header there than in the files that use DECLARE_CONSOLE_COMMAND(). BUG=b:178230662, b:179055201 BRANCH=none TEST=build volteer for zephyr, try rtc and rtc_alarm command make BOARD=volteer -j8 Change-Id: I036b1f3d91543a357ad779e475a03584759a3de4 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645570 Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Yuval Peress <peress@chromium.org>
* zephyr: add PWM shimKeith Short2021-01-291-0/+1
| | | | | | | | | | | | | | Adds PWM shim to connect the platform/ec PWM API to the Zephyr PWM API. BUG=b:174850923 BRANCH=none TEST=make buildall TEST=Run "pwmduty" command against Volteer LEDs Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I49047734bc1a3fb3d4010f0040145171275c5657 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2623163 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Add support for panic outputJack Rosenthal2021-01-261-0/+1
| | | | | | | | | | | | | | | Add basic panic implementation for Zephyr. Not using any fancy shared or always-on memory for now ... need to resolve how that will be handled later. BUG=b:178011288 BRANCH=none TEST=run various crash commands on volteer, observe output Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ia1ce386f738283a2a2b9b60ef7e0bf97f8317837 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645687
* zephyr: add MKBP supportHyungwoo Yang2021-01-261-8/+9
| | | | | | | | | | | | | | Add MKBP support to zephyr. BUG=b:173507858 BRANCH=none TEST=make buildall -j8 build volteer on zephyr Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: I9b7d979241b0df5dc0fa5d9741f05dc9875189ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2639854 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: Use Chrome EC's libgcc implementation over the compiler'sPatrick Georgi2021-01-261-0/+2
| | | | | | | | | | | | | | | | | | | | | gcc's libgcc is built with a compile time notion of what an architecture's ABI will look like. If that happens to be wrong, you're out of luck. Instead, use our own implementation which, while written in assembly (and as such not as flexible as it could be) is processed with the right set of flags. BUG=b:178363068 BRANCH=none TEST=zephyr boots on kohaku when built with coreboot-sdk. Signed-off-by: Patrick Georgi <pgeorgi@google.com> Change-Id: I6d27bb48478081b6c2ff8927734492282e55e898 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2648666 Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
* zephyr: Shim the DECLARE_HOST_COMMANDWealian Liao2021-01-191-7/+8
| | | | | | | | | | | | | | | | | | | | Shim the DECLARE_HOST_COMMAND so that host commands can be declared and found. BUG=b:177065174, b:172678200 BRANCH=none TEST=build & boot EC for Volteer 0x0d & 0xa4 don't have error message. 21-01-11 16:42:09.226 [1.528500 HC 0x0d] 21-01-11 16:42:09.227 [1.532100 HC 0xa4] Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ief3b5768715dcc164bcb25ae0d1c8de749514f92 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2620729 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Add the beginnings of a shim for flash accessSimon Glass2020-12-291-0/+1
| | | | | | | | | | | | | | Add myriad Kconfig options to make the flash code compile. This does not yet do anything useful, as we need to connect up to the Zephyr flash device (and need support for this in the npcx too). BUG=b:174873770 BRANCH=none TEST=build for volteer Change-Id: Ib4bed4cdd39cdf33a1d27b39aadb89df491941b3 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2575208
* zephyr: shim some basic eSPI functionalityJack Rosenthal2020-11-201-0/+1
| | | | | | | | | | | | | Add some basic functionality to get and set virtual wires. BUG=b:171815541 BRANCH=none TEST=volteer power sequencing to S0 (requires follow-up CLs) Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I07655fd3a768aca962112a98d6f1f593633eb605 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2548307 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: forward cros_crc8 to zephyrs crc8 implJett Rink2020-11-131-0/+1
| | | | | | | | | | | | | | | Shim in support for crc8 used in CBI, I2C, and other applications within platform/ec BRANCH=none BUG=b:168032589 TEST=add unit test for platform/ec and zephyr based CRC8 approaches and verify they both pass. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I9b6112cb83dab81a44a1ac020d4efb1b7bb1df5f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2532692 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Revert "zephyr: forward cros_crc8 to zephyrs crc8 impl"Jett Rink2020-11-111-1/+0
| | | | | | | | | | | | | | | Something slipped through CQ coverage. Need to figure out, but in the mean time, revert the 3 CLs that seemed to have caused the issue. BRANCH=none BUG=chromium:1147953 TEST=none This reverts commit 22ee9a346718a9a07955fd81b0d03c4dde5b2ec8. Change-Id: I5617e39204a7c05001363d5780fa2f52e3e1ea05 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2533355
* zephyr: forward cros_crc8 to zephyrs crc8 implJett Rink2020-11-111-0/+1
| | | | | | | | | | | | | | | Shim in support for crc8 used in CBI, I2C, and other applications within platform/ec BRANCH=none BUG=b:168032589 TEST=add unit test for platform/ec and zephyr based CRC8 approaches and verify they both pass. Change-Id: Ib609f98596c4edc6e6f0d01b6242e62a1f95ad72 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527811 Reviewed-by: Yuval Peress <peress@chromium.org>
* Add chip-specific shim along with i2c moduleYuval Peress2020-11-081-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change accomplishes 2 things: 1. It refactors the zephyr/shim directory to structure around chip specific compilation. In this example, we're focusing on npcx7m6fb which is used in volteer but others can be added easily. 2. It shims the common/i2c_master.c by providing an alternate implementation of i2c_xfer_unlocked that calls down to the Zephyr API i2c_write_read instead of the chip specific i2c_xfer_no_retry or chip_i2c_xfer_with_notify. The shim layer is made possible by the addition of zephyr/shim/include/i2c/i2c.h which adds a functions that needs to be implemented per chip (npcx7 family in this case) and allows us to map the current port int which is defined in chip/${CHIP}/registers.h (chip/npcx/registers-npcx7.h in our case). This function (i2c_get_device_for_port) maps the platform/ec port int to a const struct device * which is needed in the Zephyr I2C APIs. BRANCH=none BUG=b:171302975 TEST=clean_build.sh projects/experimental/volteer/ and make BOARD=eve Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I210f4758337bf384d0d6f103eef8b89126887d11 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2504285 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
* zephyr: shim in hooks and deferredJack Rosenthal2020-11-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | Implement deferred calls using the Zephyr's delayed work queues. Implement hooks using SYS_INIT and a hooks registry created during init. BUG=b:168030971 BRANCH=none TEST=provided unit tests Build instructions for unit tests: zmake configure -B/tmp/test \ ~/trunk/src/platform/ec/zephyr/test/hooks zmake build /tmp/test Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id019cd1fe7bb3354377773d171036767e7efa706 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2504489 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: add task shimJett Rink2020-11-051-0/+1
| | | | | | | | | | | | | | | | Provide shim/translation layer for converting platform/ec tasks into zephyr threads. Provide implementation API for platform/ec task_ API BRANCH=none BUG=b:171741620 TEST=unit test provided TEST=clean_build.sh ~/chromiumos/src/platform/ec/zephyr/tests/tasks && ../build/zephyr/zephyr.elf Change-Id: Ia2a1f808ec56a89c2a08df9de318edb1b6e9f869 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518665 Reviewed-by: Simon Glass <sjg@chromium.org>
* Only shim system.c if the cros_ec is usedYuval Peress2020-10-261-1/+1
| | | | | | | | | | | | BRANCH=none BUG=none TEST=built volteer and unit tests Change-Id: Ieedf0ffbe3137f8f6d2d7569d13ee7bff615f428 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2499414 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* Add shim for system.c (implementing jump data functions)Yuval Peress2020-10-221-0/+1
| | | | | | | | | | | | | | | This change adds the system.h/system.c shim layer to import jump data passing between images. BRANCH=none BUG=b:167392037 TEST=Added tests in zephyr-chrome/tests/ Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I8c6ae2cf579be063c5b3f7219c440aadad3eefa1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2491430 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: add initial gpio shimJett Rink2020-10-211-0/+1
| | | | | | | | | | | | | | | | | Add the gpioget and gpioset commands to zephyr build. This requires a minimum set of platform/ec gpio_ API functions. Add the minimum set of gpio_ functions. More can be added later depending on future uses BRANCH=none BUG=b:169935802 TEST=verify gpioget and gpioset console command work on volteer TEST=verify that posix-ec compiles without any named_gpios in DT Change-Id: Ie6f0b4505aa17c50c01b71fc4ea5b59393f39fce Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2488141 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: add strtoi shim functionJett Rink2020-10-121-0/+1
| | | | | | | | | | | | | | | | | | | | When I compile volteer, I only need one stdlib style function and it is something we made ourselves. There is a long verion in Zephyr and long and int are the same size for 32-bit MCUs so we just need to forward the implementation. Also remove compilation of our existing platform/ec util file since Zephyr already provides these basic stdlib like functions. BRANCH=none BUG=b:169935794 TEST=Run Zephyr image on Volteer using this function. TEST=Build and run posix-ec target as well Change-Id: Idb4ea4d5e0a6ad3da8ddc5781e16aeb6e666d85f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2444371 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: shim in the timer moduleJack Rosenthal2020-10-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This enables building timer.c in the Zephyr shim. In addition, we provide definitions for the symbols __hw_clock_source_read64 and __hw_clock_event_get defined for Zephyr to provide times to the CrOS EC. The event timer does not make sense for Zephyr code, but we need it defined to prevent link errors (timerinfo uses it). Perhaps the solution to this is to add a new config option (e.g., CONFIG_EVENT_TIMER) which can be used to selectively enable/disable the event timer in the CrOS EC. But punting this work for now and just adding a fake definition. BUG=b:167590251 BRANCH=none TEST=compile for posix-ec, run gettime and timerinfo commands Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I58990a6295625f9c34ec080360470431b46155bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427100 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: shim in the zephyr shell as the EC consoleJack Rosenthal2020-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This provides compatible macros for DECLARE_CONSOLE_COMMAND, DECLARE_SAFE_CONSOLE_COMMAND, and DECLARE_CONSOLE_COMMAND_FLAGS. Note: the concept of command flags and command restriction are not enabled currently for Zephyr. We simply define everything for now. These macros use the Zephyr shell subsystem as the backend for commands. In addition, cprints, cprintf, and cputs have been redirected to the shell for CC_CONSOLE channel outputs, and printk for all other outputs. We will look at using Zephyr's logging subsystem instead of printk for the other channels in the future. BUG=b:167590251 BRANCH=none TEST=run "gettime" and "timerinfo" commands with follow-up CLs Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17caedcd0b84a21dd2b135312f683885eaf694af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427097 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: add base files for Zephyr moduleJack Rosenthal2020-10-011-0/+5
This adds the minimum files necessary for platform/ec to be considered a Zephyr module, as well as some of the discussed CMakeLists files from go/zephyr-shim. BUG=b:167590251 BRANCH=none TEST=Append platform/ec dir to ZEPHYR_MODULES, build for posix-ec To replicate: $ export ZEPHYR_TOOLCHAIN_VARIANT=llvm $ export ZEPHYR_BASE=... $ ZEPHYR_CHROME=... $ PLATFORM_EC=... $ cmake -S ${ZEPHYR_CHROME}/projects/experimental/posix-ec \ -B /tmp/zephyr-build \ -D ZEPHYR_MODULES="${ZEPHYR_CHROME};${PLATFORM_EC}" $ ninja -C /tmp/zephyr-build $ /tmp/zephyr-build/zephyr/zephyr.elf Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id5eb4e4d3b761a9499e876dfe2178be7f7961e93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427089 Reviewed-by: Jett Rink <jettrink@chromium.org>