summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/system.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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: Move BBRAM access functions to common system.cWealian Liao2021-08-041-17/+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: use DEVICE_DT_GET for various shim modulesFabio Baltieri2021-06-281-1/+6
| | | | | | | | | | | | | | | | Convert various device_get_binding to DEVICE_DT_GET, which is processed at link time and more efficient. Same pattern on different modules where the output is checked using device_is_ready. BRANCH=none BUG=none TEST=zmake configure -b -B ~/build-volteer/ zephyr/projects/volteer/volteer TEST=zmake configure -b -B ~/build-it8xxx2_evb/ zephyr/projects/it8xxx2_evb Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: If426420da2c61b3bc02eb77e122469a1a40799f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2985463 Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: ztest: Add system_preinitialize back to ztestWealian Liao2021-05-121-3/+2
| | | | | | | | | | | | | | | Per CL:2731180, system_preinitialize() should be added in ztest. Add the dependency functions to ztest_system & add system_preinitialize back to ztest. BUG=b:183611735 BRANCH=none TEST=zmake testall Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Iea90e1909d28556421471d7e905d0e56705b3fc0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2878761 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: npcx: Add power management supportKeith Short2021-04-291-0/+22
| | | | | | | | | | | | | | Add power management support for the NPCX family. BUG=b:184653704 BRANCH=none TEST=zmake testall TEST=Verify deep sleep on Volteer (with next CL) and measure power. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I86eef50c13742e7ca717da38a92636e589af6c58 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2855527 Reviewed-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com>
* zephyr: npcx: Add non-psl hibernate implementationMulin Chao2021-04-141-5/+5
| | | | | | | | | | | | | | | | | | | | | | | Implements non-psl hibernate mechanism for cros_system driver. First, we plan a little hibernate function locates in the last 32K ram block in npcx7 series. Then power down the other ram blocks and go to deep sleep mode for better power consumptions. Please notice do not use global or call the other functions in this hibernate utility since we have turned off the other ram blocks. BUG=b:177904393, b:183745774 BRANCH=none TEST=zmake testall TEST=All wake-up GPIOs can wake-up ec from hibernating on npcx7 evb. Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I48f95b0e616ad27f77a6d0ada8251ec438427741 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2821116 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: Add chip info support in shimmed system driverMulin Chao2021-04-081-3/+9
| | | | | | | | | | | | | | | | | | Add chip vendor, name, and revision information via cros_system driver API in the shimmed system driver. BUG=none BRANCH=none TEST=build & boot ec on volteer Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I09ff25d7ad07371900211426a15560ee61326b12 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2807478 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: shim: system: add hibernate support.Mulin Chao2021-03-311-10/+30
| | | | | | | | | | | | | | | | Add hibernate support via cros_system driver api in the shimmed system driver. It also saves related reset flag for reset cause checking. BUG=b:173787365 BRANCH=none TEST=zmake testall Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I6c919ac46b9f38a9a2888967be0f55412d4bcc26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2794205 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: npcx: add reset cause checkWealian Liao2021-03-241-0/+173
| | | | | | | | | | | | | | | | | | | | | | | | | | | The reset cause will influence the initialization flow. We define some of initial flow of the reset cause for the following development. This CL include the following: 1. Add check_reset_cause() which sets the system reset flag. 2. Add chip_bbram_status_check() to clear the error status & show the error message. 3. Add CONFIG_BOARD_RESET_AFTER_POWER_ON feature. 4. Define the initialize flow for reset cause. BRANCH=none BUG=b:178101173 TEST=check the following reset cause by 'sysinfo' 1. power-up 2. reset-pin reset 3. soft by 'reboot' console command 4. watchdog by 'waitms 2000' Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I515868d8cda4544fdbe782210b0108b4dda0d8cc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2731180 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: add bbram system callWealian Liao2021-03-101-2/+2
| | | | | | | | | | | | | | | | This CL include the following: 1. Adds BBRAM system call. 2. BBRAM read/write data isn't really for characters. Change to use uint8_t. BUG=None. BRANCH=None. TEST=build & boot EC on volteer Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Iff92071e1808c4dacb24bf46e663898120369821 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2731177 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: efs2: Compute the __image_size for efs2 in the linkerYuval Peress2021-02-261-2/+0
| | | | | | | | | | | | | | | | | | | | The __image_size should match used portion of the flash. Note that in Zephyr, different linker scripts have different variables. _flash_used is only available for the verified chips. Other chips may use a different name or may require manual calculation. Compute the size by using the Zephyr sections. This is the parallel to core/cortex-m/ec.lds.S's logic. BRANCH=none BUG=b:164421798 TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: If91acd5dc2b925ad226f2d1c3feccc77617e04df Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2721495 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: Move bbram logic to devicetreeYuval Peress2021-02-051-24/+36
| | | | | | | | | | | | | | | | | Move all bbram logic to a common npcx.dtsi file included in both volteer and kohaku. Updates the bbram access logic in zephyr/shim/src/system.c to use devicetree. Updates the unit tests to match. BRANCH=none BUG=b:178807203 TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I2a7c65b92a395c622e8cfe751e4e98b3173e38fb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2669271 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: flash/system: enable common/flash.c & common/system.cYuval Peress2021-02-031-237/+44
| | | | | | | | | | | | | | | | | | | 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: Add support for panic outputJack Rosenthal2021-01-261-6/+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: Enable the chgramp taskSimon Glass2021-01-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This task is used to ramp up charging from an external source. Add support for this along with required Kconfig options. Add one more stub in system to make it build. This is covered by the existing bug. BUG=b:175434113 BRANCH=none TEST=make BOARD=volteer -j30 build volteer on zephyr So far the output is not interesting (need more drivers): uart:~$ chgramp Chg Ramp: State: 0 Min ICL: 0 Active ICL: 0 Port 0: OC idx:0 OC 0: s-1 oc_det0 icl0 OC 1: s0 oc_det0 icl0 OC 2: s0 oc_det0 icl0 Port 1: OC idx:0 OC 0: s-1 oc_det0 icl0 OC 1: s0 oc_det0 icl0 OC 2: s0 oc_det0 icl0 Signed-off-by: Simon Glass <sjg@chromium.org> Cq-Depend: chromium:2613607 Change-Id: I603ba43d4384b62ed0c1a64b580599b42ae85e81 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2617039 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Add a stub for system_is_locked()Simon Glass2020-12-231-0/+11
| | | | | | | | | | | | | | Add stubs for this and system_get_image_copy(). These should be implemented when we have the underlying functionality available. BUG=b:176171847 BRANCH=none TEST=build on zephyr Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Iddee3b94cdb9e93a52718e49aea2750f77f5ea2e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2601141 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: shim system_jumped_late & system_enter_hibernateWealian Liao2020-12-011-0/+32
| | | | | | | | | | | | | | | | shim the system_jumped_late() and system_enter_hibernate() that needed by keyboard scan. BRANCH=none BUG=b:167405015 TEST=compile with keyboard scan Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I4f79dd3b0313f4ed19550b1896ed0e439407caf6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2552321 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: stub system_hibernateJack Rosenthal2020-11-201-0/+8
| | | | | | | | | | | | | Needed by power sequencing. Doing nothing will work fine for now. BUG=b:173787365 BRANCH=none TEST=compile with power sequencing Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ia4e48d92ebbee7a788e4515f6583095349aea0f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2548306 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: implement system_jumped_to_this_imageJack Rosenthal2020-11-191-0/+5
| | | | | | | | | | | | | | | | Required by power sequencing. Should always be false for now as sysjump is not implemented. BUG=b:171312361 BRANCH=none TEST=compiles with power sequencing Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I1dc6e553211734307ce5a28ed3b5b9feeff002a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2548304 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* cleanup: follow header include styleJett Rink2020-11-091-3/+4
| | | | | | | | | | | | | | | | | In order to align with go/zephyr-shim-how-to, update all of the platform/ec header files to use "quotes" and only use <brackets> for zephyr header files. Also include an empty line between the two. BRANCH=none BUG=none TEST=all zephyr tests build and pass; build volteer Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I27c275c24aa4f8eb40e100b07517b60f548f06cf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521594 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Simon Glass <sjg@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: 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>
* Add shim for system.c (implementing jump data functions)Yuval Peress2020-10-221-0/+218
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>