summaryrefslogtreecommitdiff
path: root/zephyr
Commit message (Collapse)AuthorAgeFilesLines
...
* Add chip-specific shim along with i2c moduleYuval Peress2020-11-0810-4/+173
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 the lid switchJack Rosenthal2020-11-072-0/+9
| | | | | | | | | | | | | | | Enable an option to compile common/lid_switch.c. BUG=b:172652088 BRANCH=none TEST=On volteer, with zephyr-chrome CL, observe lid{open,close,state} console commands, gpio interrupt works Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ica5b8abd1b0e0d9666ded9bd27927562ee36b80c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523456 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: gpio: shim gpio_{en,dis}able_interruptJack Rosenthal2020-11-071-0/+56
| | | | | | | | | | | | | | These two platform/ec functions are used pretty widely across common code, and enables/disables the interrupt functionality on a GPIO PIN. BUG=b:172652088 BRANCH=none TEST=compile with lid switch shim, observe lid state change Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Iad662397da24b58e577537d835c4a2d532307bb3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523455 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: move shimmed_tasks.h include to config.hJack Rosenthal2020-11-071-5/+0
| | | | | | | | | | | | | | | | | Unfortunately, many things in config.h rely on HAS_TASK_* to be defined before we start processing config.h. Move this include a little sooner so we have it then. BUG=b:172678200 BRANCH=none TEST=compiles with host_command.c added Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I791426b78777997748eff2c91210b8a426d9a8ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2522970 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: Don't output a newline in cputs() unless requestedSimon Glass2020-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present this function adds a newline, but it should not. Fix it. BUG=b:167405015 BRANCH=none TEST=zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos Run on volteer and see that the keyboard output looks right. before: 20-11-06 15:17:39.329 keyboard_scan_task 20-11-06 15:17:39.329 [0x00000000T KB init state: -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 -- 20-11-06 15:17:39.342 ] after: 20-11-06 15:19:11.144 [0x00000000T KB init state: -- -- -- -- -- -- -- -- -- -- -- -- --] Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ic2592d49fa1f6debf8d0a65c9dc1b9bef2eb88ef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523390 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: Enable the '8042' commandSimon Glass2020-11-072-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | This is used to provide information about the keyboard operation. Enable this command and its subcommands. Note that in ECOS these subcommands are also top-level commands, but this is not the case in Zephyr, since it seems unnecessary. Note also that changing these to console sub-commands may end up making FAFT testing more difficult since the invocation on the EC UART would be different. BUG=b:167405015 BRANCH=none TEST=make BOARD=volteer zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos Run on volteer and try out '8042 kbd', etc. Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ia11092af350247ac98681485a9ddd309c7192272 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523452 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: Allow keyboard_8042 to build with zephyrSimon Glass2020-11-063-0/+32
| | | | | | | | | | | | | | | | | Make a few changes so that this file can build. It does not work yet. BUG=b:167405015 BRANCH=none TEST=make BOARD=volteer zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos See there are no errors Change-Id: If68cc8e4541f513013481bde859fbe2f4681a0bc Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521358 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Provide parse_bool()Simon Glass2020-11-061-0/+21
| | | | | | | | | | | | | | | | | | Add this function to the shim so it can be used in the keyboard code. Drop strtoul() for now since it has the wrong signature. BUG=b:167405015 BRANCH=none TEST=zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos See there are no errors Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I694369feb192cf49addb7444908b89b6081bffa1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521360 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Build queue moduleSimon Glass2020-11-061-1/+1
| | | | | | | | | | | | | | | | | Add this to the build so we can use their features for the keyboard code. BUG=b:167405015 BRANCH=none TEST=zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos See there are no errors Change-Id: I2d5fddc8cc7b80d3f6d2da7518ffeab989949683 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521357 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Use spaces to line up the source filesSimon Glass2020-11-061-3/+3
| | | | | | | | | | | | | | | | These are easier to read when lined up vertically. Add spaces to achieve this, since Zephyr does not seem to use tabs in CMakeLists.txt files. BUG=b:167405015 BRANCH=none TEST=zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos See there are no errors Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Id1e2f9a8609d5f727df35f0ffa9785c537bac7f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2522130
* zephyr: add zmake.yaml filesJett Rink2020-11-062-0/+18
| | | | | | | | | | | | | | | | | Add the zmake config file for test that don't have one BRANCH=none BUG=none TEST=zmake builds both tests zmake configure -b /tmp/test ~/chromiumos/src/platform/ec/zephyr/test/tasks zmake build /tmp/test Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Ibd9fd114e7fff008bb07cb616529d82cdb774a0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521064 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: shim in hooks and deferredJack Rosenthal2020-11-058-0/+355
| | | | | | | | | | | | | | | | | | | | | | 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-058-0/+493
| | | | | | | | | | | | | | | | 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>
* zephyr: Sort shimmed modulesSimon Glass2020-11-051-1/+1
| | | | | | | | | | | | | | | | | | Sort these into alpha order to make them easier to find as the list grows. BUG=b:167405015 BRANCH=none TEST=zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos See there are no errors Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I863f798381dc1f991b5eca9dd080fabf46e9888f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521356 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr/test/base32: specify board in makelistJett Rink2020-11-051-0/+1
| | | | | | | | | | | | | | | | Instead of specifying the board on the command line to build the base32 test. Specify it in Cmakelist instead. BRANCH=none BUG=none TEST=build and run base32 without passing board on commandline Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I8e7defa48cc285de1e1f32919b3e576698603e78 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2519240 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* cleanup: fix pgio -> gpio typoJett Rink2020-11-051-1/+1
| | | | | | | | | | BRANCH=none BUG=none TEST=none Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Ifcf440bd642f89f3c2b6e23f9944dc651e14fdf3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2519241
* atomic: rename atomic_read_clear to atomic_clearDawid Niedzwiecki2020-11-021-5/+0
| | | | | | | | | | | | | | | | | Rename atomic_read_clear to atomic_clear to be consistent with the rest of the atomic functions, which return the previous value of the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I2588971bd7687879a28ec637cf5f6c3d27d393f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505143 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Zephyr: add sleep_maskYuval Peress2020-10-301-0/+3
| | | | | | | | | | | | | | | | | | | | | platform/ec/include/system.h defines an extern uint32_t sleep_mask which is used in a few modules, but specifically for our interest right now in enable_sleep and disable_sleep inline functions also defined in include/system.h. These functions are used in the following CL when shimming common/i2c_master.c and will likely be used in other .c files that will be shimmed in later. Note that in platform/ec this is also defined in common/system.c it just wasn't needed until now. BRANCH=none BUG=b:171302975 TEST=Built zephyr-chrome/projects/experimental/volteer Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I026be635fad85688301f1009c13722c0f788227f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508761 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: use gpio_pin_set_raw directlyJett Rink2020-10-301-9/+1
| | | | | | | | | | | | | | | | Use the helper function, gpio_pin_set_raw, instead of the port function directly in order to avoid shifting the bit number. This makes the get and set API use similar APIs. BRANCH=none BUG=none TEST=gpioget and gpioset still work on volteer Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I9eb68e8d66113f6a07a182b8af133cdf808f5cbc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508328 Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* test: support building base32 as a Zephyr testPaul Fagerburg2020-10-282-0/+13
| | | | | | | | | | | | | | | | With the Ztest API supported now, add the files to build the base32 unit test as a Zephyr test (instead of an EC test). BUG=b:168032590 BRANCH=None TEST=follow instructions in docs/ztest.md to build as a Zephyr test Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I06dd7864f2de48aab5776950d4840f81728137f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2500465 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* zephyr: fix build breakageJack Rosenthal2020-10-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | We weren't including a header which defined _CONCAT from this file, so it's hit or miss whether the right headers were included before this one. Change to DT_CAT, which does the same thing and is already in devicetree.h. BUG=b:171820560 BRANCH=none TEST=compile for volteer: zmake configure -B ~/volteer-build projects/experimental/volteer zmake build ~/volteer-build Change-Id: Ice319bf3af32e5805fd8933dba9a72dc6c1affff Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2503786 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tree: Use new atomic_* implementationDawid Niedzwiecki2020-10-271-28/+4
| | | | | | | | | | | | | | | | | | | | | | | It is done as a part of porting to Zephyr. Since the implementation of atomic functions is done for all architectures use atomic_* instead of deprecated_atomic_*. Sometimes there was a compilation error "discards 'volatile' qualifier" due to dropping "volatile" in the argument of the functions, thus some pointers casts need to be made. It shouldn't cause any issues, because we are sure about generated asm (store operation will be performed). BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@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>
* zephyr: include config.h before ec_commands.hPaul Fagerburg2020-10-261-0/+1
| | | | | | | | | | | | | | | | | Fixed a compiler warning for multiple definitions of BUILD_ASSERT. BUG=None BRANCH=None TEST=build, see that the warning about BUILD_ASSERT is gone. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I97ed721fc3a28bc29b985e335fbd223cac28eb1c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2499501 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Auto-Submit: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: add gpio interrupts to shimJett Rink2020-10-231-2/+78
| | | | | | | | | | | | | | | | | | | Allow each zephyr project to define the EC_CROS_GPIO_INTERRUPTS item in their gpio_map.h file to register existing platform/ec gpio irq handlers. Unfortunately this cannot go in the device tree file since the device tree does not support function pointers as a data type. BRANCH=none BUG=b:169935802 TEST=hooked up power button GPIO to platform/ec-based gpio irq Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I65d03fed413b270aeae502ad4267b1091582bd91 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2494725 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* cleanup: update comment formattingJett Rink2020-10-231-6/+11
| | | | | | | | | | | | | | Put comments on a newline above fields to allow for longer comments in this file. BRANCH=none BUG=none TEST=none Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I89740558e7bb508f7a213cd6817ae91ad9b6f5a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2495137 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Add shim for system.c (implementing jump data functions)Yuval Peress2020-10-222-0/+219
| | | | | | | | | | | | | | | 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-216-1/+182
| | | | | | | | | | | | | | | | | 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: shim in base32.cPaul Fagerburg2020-10-141-0/+1
| | | | | | | | | | | | | | | Add base32.c to the shim layer. BUG=b:168032590 BRANCH=none TEST=build the base32 unit test in zephyr-chrome Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: If4cd30fcd3ade7c4045432f1f2f1f0a85c13067d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2468631 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* zephyr: use printk instead of shell_Jett Rink2020-10-121-12/+8
| | | | | | | | | | | | | | | The shell print function is not as complete as the printk function. I see have to add functionality for the printk version, but the shell version does not support the specifiers we use in gettime console (e.g. "0x%016llx -> %11.6lld" format specifier) BRANCH=none BUG=none TEST=flash volteer and call gettime on console and see correct results Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Iadf9fc05708c31b70735145ed43750c308b07f39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2446028
* zephyr: add strtoi shim functionJett Rink2020-10-123-1/+15
| | | | | | | | | | | | | | | | | | | | 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: detect the module location in a 2.3/2.4 compatible mannerJack Rosenthal2020-10-121-1/+9
| | | | | | | | | | | | | | | | | | | | | | | Most zephyr modules choose to put CMakeLists.txt at the root of the module, but we instead decided to put ours at zephyr/CMakeLists.txt to keep all CMake contained within the zephyr/ directory. So a change in 2.4 came to bite us. ZEPHYR_CURRENT_MODULE_DIR will now be set to the base of the module, not the directory where the CMakeLists.txt is located. Update the code to probe for the 2.3/2.4 difference. BUG=b:170268298 BRANCH=none TEST=compile zephyr for posix-ec on 2.3 and 2.4 (using zmake; build instructions and WIP CL can be found at go/zmake) Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ia6da8451bd7d25aafe7cf42066d202ead208fa7c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2454973 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
* Fix incomplete rename (deprecated_atomic_clear -> deprecated_atomic_clear_bits)Jack Rosenthal2020-10-061-2/+2
| | | | | | | | | | | | | | | | CL:2428943 renamed deprecated_atomic_clear to deprecated_atomic_clear_bits, but missed these two cases, as they landed thru CQ after CL:2428943 passed the dry run. BUG=b:170132568 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I6fff582b2cf8dbf77bc8a136bc7fa81af30b2cc0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2452889 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Sean Abraham <seanabraham@chromium.org>
* zephyr: shim in the timer moduleJack Rosenthal2020-10-015-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | 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 util.cJack Rosenthal2020-10-011-0/+3
| | | | | | | | | | | | | Provides platform/ec utility functions. BUG=b:167590251 BRANCH=none TEST=compile posix-ec Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ic6846e93dd5190b0db4d666e55ae185c4cc61392 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2442456 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: provide compatible config_chip.h and board.h filesJack Rosenthal2020-10-012-0/+33
| | | | | | | | | | | | | | | | | | | These include files are expected by the EC config system. For board.h, we intentionally leave it empty. For config_chip.h, we populate it with preprocessor guards that translate Zephyr config options to EC config options, and enable/disable some defaults for Zephyr. BUG=chromium:167590251 BRANCH=none TEST=compile common/timer.c with follow-up CLs Change-Id: I2294c6a296f69ae8d514b74ea29f288fe4a240fc Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427098 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: shim in the zephyr shell as the EC consoleJack Rosenthal2020-10-013-1/+148
| | | | | | | | | | | | | | | | | | | | | | | 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: implement atomic.hJack Rosenthal2020-10-011-0/+45
| | | | | | | | | | | | | | This implements a compatibility layer with the deprecated_* atomic operations using Zephyr's APIs. BUG=b:169151160 BRANCH=none TEST=compile timer.c in follow-up CL Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I49fa1afc28790ab14a91d472141a01e2370b24ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427096 Reviewed-by: Jett Rink <jettrink@chromium.org>
* config: add CONFIG_ZEPHYRJack Rosenthal2020-10-011-1/+15
| | | | | | | | | | | | | | This adds a new configuration option, CONFIG_ZEPHYR, which gets enabled during a build of the platform/ec Zephyr module. BUG=b:167590251 BRANCH=none TEST=compiles Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I157928720d9d6ec0b71c2138298f46c64723fe0b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427090 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: add base files for Zephyr moduleJack Rosenthal2020-10-014-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* zephyr: add compatible assert.h headerJack Rosenthal2020-09-251-0/+15
Add a compatible header for "builtin/assert.h" which uses Zephyr's assertion system. BUG=b:167590251 BRANCH=none TEST=compile with follow-up CLs Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id6ead8fd664dca8c391c72325fd98c6990e5fc13 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427099 Reviewed-by: Jett Rink <jettrink@chromium.org>