summaryrefslogtreecommitdiff
path: root/common/system.c
Commit message (Collapse)AuthorAgeFilesLines
* ec_commands: Add ec_response_get_version_v1Rob Barnes2021-09-201-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | A field (cros_fwid_rw) was added to ec_response_get_version and the version was updated to v1. Some system components that still use v0 of the version host command fail because the size of the response does not match the updated ec_response_get_version struct. Restore ec_response_get_version to match v0. Create a new ec_response_get_version_v1 structure with the added v1 fields. This allows legacy code to continue using ec_response_get_version, which matches the expected response size for the v0 command. BUG=b:188073399,b:200075921 TEST=EC console 'version' works Legacy 'ectool version' works with old an new EC firmware. New 'ectool version' works with old and new EC firmware. BRANCH=None Change-Id: I51a052a550c2460f2604da8e04fc43c36acba4d5 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3169100 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* system: Add CrOS FWID to version outputRob Barnes2021-09-141-66/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EC version does not follow the the AP and OS version. This causes confusion during development. This change augments the EC version output to include the CrOS FWID when available. The CrOS FWID will be missing when the CrOS EC is built outside of cros_sdk. When CrOS FWID is missing 'CROS_FWID_MISSING' will be used. Zephyr/zmake support will be added later, CROS_FWID32 is set to 'CROS_FWID_MISSING' in zephyr builds until then. BUG=b:188073399 TEST=version 21-05-20 16:43:18.627 Chip: Nuvoton NPCX993F A.00160101 21-05-20 16:43:18.631 Board: 1 21-05-20 16:43:18.631 RO: guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.634 guybrush_13983.0.21_05_20 21-05-20 16:43:18.639 RW_A: * guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.641 * guybrush_13983.0.21_05_20 21-05-20 16:43:18.644 RW_B: guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.644 guybrush_13983.0.21_05_20 21-05-20 16:43:18.647 Build: guybrush_v2.0.8770+f47439f75 21-05-20 16:43:18.651 guybrush_13983.0.21_05_20 2021-05-20 21-05-20 16:43:18.657 16:31:19 robbarnes@robbarnes0 ectool version RO version: guybrush_v2.0.8770+f47439f75 RO cros fwid: guybrush_13983.0.21_05_20 RW version: guybrush_v2.0.8770+f47439f75 RW cros fwid: guybrush_13983.0.21_05_20 Firmware copy: RO Build info: guybrush_v2.0.8770+f47439f75 guybrush_13983.0.21_05_20 2021-05-20 16:31:19 robbarnes@robbarnes0 Tool version: 1.1.9999-f47439f @robbarnes0 BRANCH=None Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: Ief0a0c6e9d35edc72ac2d4780ee203be41d7305f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2894145 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* system: add hibernate flagTim Lin2021-09-031-0/+2
| | | | | | | | | | | | | | | | Add hibernate flag. Before system reset, it should be distinguished as hard reset or hibernate reset and saved in BBRAM. BUG=none BRANCH=none TEST=none Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: I0e06f3d1bea89ead1795cc07677e22e841643a97 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3139528 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* system: fix system_get_scratchpad APIYuval Peress2021-08-201-1/+12
| | | | | | | | | | | | | | | 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>
* common: system: always define host_command_get_board_versionDenis Brockus2021-07-291-2/+0
| | | | | | | | | | | | | | | | | | | There are platforms that have board defined get_board_version and they should be allowed to have host_command_get_board_version even if CONFIG_BOARD_VERSION_* are not defined. BUG=none BRANCH=none TEST=make buildall TEST=zmake configure -b $PROJ_HAYATO Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I6e2765b40c7cbada82a8ace305899f2e319157c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3058354 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>
* cbi: Add CONFIG_EEPROM_CBI_WPAseda Aboagye2021-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | This commit adds the config option, CONFIG_EEPROM_CBI_WP. It is to be defined when the EC directly controls the CBI EEPROM WP signal. The EC will set the WP according to the result of `system_is_locked()`. Note that once the WP is set, the EC must be reset via EC_RST_ODL in order for the WP to become unset. This is enabled by the accompanying hardware. BUG=b:181769483 BRANCH=None TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: If490594ab4dd24af98119b01299215b997913b66 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3046412 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* system: don't hibernate if AC is presentRicardo Quesada2021-07-261-0/+15
| | | | | | | | | | | | | | | | | | | | | | | This CL prevents hibernation if AC adapter is connected. This is to prevent AP from rebooting. This might happen because if EC is hibernated when AC is connected, it might wake up immediately in response to AC being connected, resulting in AP reboot. BUG=b:192259035 TEST=delbin EC console: run "hibernate" w/ AC: didn't hibernate. Press Alt+Volume Up+H w/o AC: it hibernated. Press Alt+Volume Up+H w AC: it didn't hibernate. BRANCH=none Signed-off-by: Ricardo Quesada <ricardoq@google.com> Change-Id: I07dee088e5b6ed7d0b3901049323d93ef4d0b9c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3042989 Commit-Queue: Ricardo Quesada <ricardoq@chromium.org> Tested-by: Ricardo Quesada <ricardoq@chromium.org> Auto-Submit: Ricardo Quesada <ricardoq@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* system: Generalize system_get_board_version()Philip Chen2021-07-121-5/+15
| | | | | | | | | | | | | | | | | | Extend system_get_board_version() to support not only AP-sourced SKU ID but also EC-sourced SKU ID, whose getter function can be customized per board. BRANCH=None BUG=b:186264627 TEST=make buildall -j TEST=zmake testall Change-Id: I764868d6472fb66480a43d028e5a79933b10117d Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3017602 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* system: Clean up system_get_board_version()Philip Chen2021-07-091-19/+28
| | | | | | | | | | | | | | | | | | | Refactor system_get_board_version() a bit so that we can remove CONFIG_BOARD_VERSION_CUSTOM and CONFIG_BOARD_VERSION from config.h. BRANCH=None BUG=b:186264627 TEST=make buildall -j TEST=zmake testall Cq-Depend: chromium:3015243 Change-Id: Id5ab809493c297b7d330ea13dcd6934ec00042a6 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3004112 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* System: Add SYSTEM_IN_MANUAL_RECOVERY flagDaisuke Nojiri2021-07-051-6/+23
| | | | | | | | | | | | | | | | | | This patch adds SYSTEM_IN_MANUAL_RECOVERY, which indicates the system is in recovery mode. It's set when EC_HOST_EVENT_KEYBOARD_RECOVERY is set and cleared when the system shuts down (not when the host event flag is cleared). BUG=b:188242794 BRANCH=None TEST=Verify sysinfo command prints 'Recovery: yes' in recovery screen. TEST=Verify sysinfo command prints 'Recovery: no' after shutting down from recovery screen. Change-Id: I357e25fa4072cb4549dbe2c6bd476b0a93ccbb38 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3001190
* system: Rename reset_flags used in system_encode_save_flagsDaisuke Nojiri2021-07-011-7/+7
| | | | | | | | | | | | | | | | | There is a variable named reset_flags, which is shared by all code in system.c. system_encode_save_flags gives its parameter the same name. This patch renames the local variable to remove the confusion. There is no functionality change. BUG=None BRANCH=None TEST=buildall Change-Id: I9838d8d4c77e3a266731a840c70a77ddf1cefb25 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2998512 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* EFS2: Clear EC_RESET_FLAG_EFS when jumping back to RODaisuke Nojiri2021-06-281-1/+6
| | | | | | | | | | | | | | | | | Currently, EC_RESET_FLAG_EFS isn't cleared once it's set until the next reset. This causes an RO copy to re-run init functions because system_jumped_late returns false. This patch makes EC_RESET_FLAG_EFS cleared before sysjump to RO. BUG=b:192022501 BRANCH=none TEST=buildall Change-Id: Ib151f2f619d1c59f46706a6cd43b05c26d67c74d Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2992548 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* zephyr: fix jdata pointerDawid Niedzwiecki2021-06-151-2/+10
| | | | | | | | | | | | | | | | | Zephyr stores the panic date not at the end of RAM, thus the pointer to the jump data has to be calculated in a different way. With the change, the function system_usable_ram_end returns a correct value which is used to calculate the SharedMem size. BUG=b:178011288 BRANCH=none TEST=run firmware_ECSharedMem test on Lazor Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: If777261a5582071822a998e796973ec5b8cb3cac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2960174 Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: shim: add mpu enable and disable supportFabio Baltieri2021-06-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for allowing the EC code to control the MPU setup. ECOS code used to handle configuration as well as MPU enable/disable. Zephyr has its own way of handling MPU configuration, so that part of the EC code is compiled out, instead make sure that the fixed MPU regions (that cover code & data) are disabled before the EC code starts, and then enable them when mpu_enable() is called Zephyr APIs do not expose any memory protection funciontality outside of the arch specific code, so this sets the MPU regiers directly. That's not very elegant, but it's done in a sample application as well [1], so it should be an acceptable approach. Disabling the MPU unit entirely could also be an option, but only doing the fixed regions has the advantage of leaving the stack protection and null pointer detection regions enabled. [1] https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/application_development/code_relocation/src/main.c BRANCH=none BUG=b:180039888 TEST=actually tried to write in the static region, verified it fauls after sysjump disable Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I020c347e5f1b929500d4cf1c4c400dcd67e78dfa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2950168 Reviewed-by: Yuval Peress <peress@chromium.org>
* include/flash: rename the APIsTim Lin2021-06-091-8/+8
| | | | | | | | | | | | | | | | The names conflict when enabling both Zephyr's flash driver and CONFIG_FLASH_CROS option. Rename all the APIs in include/flash.h BUG=b:187192628 BRANCH=none TEST=make buildall -j4 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: If1fd0ea28fa9f5cec1c1daa8f72f63eb7a0e6500 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2931749 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: Don't reinitialize gpios on a warm rebootSam Hurst2021-06-031-11/+16
| | | | | | | | | | | | | | Don't reinitialize gpios on a warm reboot BRANCH=none BUG=b:187337449,b:186458444 TEST=Verified that the system booted properly Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ie11bdde9fa0124c0bf21cdc9baa3a98a85bbdad2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2904549 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: 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>
* zephyr: Update banner to match Chromium OSKeith Short2021-04-231-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update the boot banner to match Chromium OS. This also modifies the version output to include "_zephyr" after the board name to clearly identify the image type. Boot banner: Booting Zephyr OS build zephyr-v2.5.0-31-g6fcd6373e58a --- UART initialized after reboot --- [Image: RO, volteer_zephyr_v2.0.8350-190d6f 2021-04-08 11:15:09 keithshort@mtbaldy] [Reset cause: reset-pin] uart:~$ version Chip: Nuvoton NPCX796FC 02 Board: 1 RO: volteer_zephyr_v2.0.8350-190d6f RW: volteer_zephyr_v2.0.8350-190d6f Build: volteer_zephyr_v2.0.8350-190d6f 2021-04-08 11:15:09 keithshort@mtbaldy BUG=none BRANCH=none TEST=zmake testall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ia136c4e025aba95217f1d8c51de39255fef54f7b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2822208 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: 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>
* system: Wait 1s for EC to quiesce before hibernateAseda Aboagye2021-04-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | The EC can enter hibernate via a keyboard shortcut alt+vol_up+H when in S0. However, the EC will never actually hibernate from S0; instead, it waits until the system is in S5/Pseudo G3 for 1hr (default setting). If the system is in S0 when hibernate is requested, it performs an unclean shutdown and then enters hibernate immediately. However, this can allow spurious interrupts to wake up the EC again. This commit simply adds a 1s delay after the unordely shutdown and before entering hibernate. BUG=b:185302895,b:185206379 BRANCH=dedede TEST=Build and flash DUT, boot to S0, press alt+vol_up+H, verify DUT turns off and stays off. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I98e094a64ae716811e44fe1858ad981403da7b39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2829116 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* system: Remember AP watchdog resetYu-Ping Wu2021-04-091-0/+4
| | | | | | | | | | | | | | | | | | | | On MT8183, when EC detects a watchdog reset, EC needs to reboot itself in preparation for the next boot. This means that AP loses the reset cause (as AP system reset is toggled), and, therefore, we need to save the reset reason in the EC. This has been done in CL:1295890 for chip stm32. For the new MT8183 model 'cozmo', we need to do the same for chip it83xx. BUG=b:184225435 TEST=firmware_EventLog passed on Cozmo TEST=FW_NAME=cozmo emerge-jacuzzi chromeos-ec BRANCH=none Change-Id: I08d165b5dbd8e1d92fad66ef3873fc406ab6a0e0 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2814079 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* zephyr: npcx: add read & write reset flag functionWealian Liao2021-03-101-12/+0
| | | | | | | | | | | | | | This CL adds chip_save_reset_flags() & chip_read_reset_flags(). Also, fulfill the system_reset() BUG=b:176523207 BRANCH=None. TEST=check 'reboot wait-ext' will wait 10s Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Idb9c2e90e8ad5e8a989f33ac904c3b778b8f48e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2731179 Reviewed-by: Keith Short <keithshort@chromium.org>
* system: Fix ENTERING_RW GPIO name.Aseda Aboagye2021-02-251-2/+2
| | | | | | | | | | | | | | | In haste, I misspelled the ENTERING_RW GPIO name. This fixes it. (sorry) BUG=b:180965428,b:181051734,b:181085178 BRANCH=dedede TEST=make -j buildall Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I0d2f3dece2dcf44a0e16923f500d68216bbadf33 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2719106 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* system: Add board_pulse_entering_rw()Aseda Aboagye2021-02-251-3/+8
| | | | | | | | | | | | | | | | | | | This commit adds an overridable function for pulsing the EC_ENTERING_RW signal. This function should only be overridden in very rare circumstances! The default implementation is unchanged. EC_ENTERING_RW is pulsed for 1ms. BUG=b:180965428,b:181051734,b:181085178 BRANCH=dedede TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Ie04bc0b0d20473be1b3d5f46fa1a986ab6e59953 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2719103 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* zephyr: implement cortex-m's interrupt_disable()Yuval Peress2021-02-181-1/+13
| | | | | | | | | | | | | | | | | | Add implementation in lieu of Zephyr APIs. Zephyr's support for irq_disable() doesn't disable all interrupts (see Zephyr's include/arch/arm/aarch32/asm_inline_gcc.h for more information). The implementation is done via a #define inside the system.c file, this is done on purpose to avoid leaking the interrupt_disable() functionality outside of sysjump. All other uses of disabling interrupts should be done via irq_lock(). BRANCH=none BUG=b:174481378 TEST=build/flash volteer, run sysjump command Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Idccb93211296f81796ce4ba200c62adc5c19e691 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2695959
* Remove CONFIG_HOSTCMD_VBNV_CONTEXTJack Rosenthal2021-02-021-33/+0
| | | | | | | | | | | | | | This is no longer set by any boards, and we don't intend to use it on future projects again. BUG=b:178689388 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I7aa64d52bc197778873e7eb880961c37fb9f34e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2657721 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* version: Rename version.h to cros_version.hYuval Peress2021-01-071-1/+1
| | | | | | | | | | | | | | | This change simply moves the include/version.h file over to avoid a naming collision with zephyr's version.h. BRANCH=none BUG=b:167392037 TEST=make buildall -j Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib41b3c21817d5f81e713d3b550bc46a0d1c55cf8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2612772 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* system: Add EC_REBOOT_COLD_AP_OFF commandPi-Hsun Shih2020-11-171-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | Add EC_REBOOT_COLD_AP_OFF as a command of EC_CMD_REBOOT_EC host command, that would cold reboot EC without booting AP. BUG=chromium:1121907 TEST=With CL:2422025 CL:2459802, echo 1 > /var/lib/power_manager/reset_ec_on_next_shutdown click shutdown on UI and observe that EC is rebooted and AP is still off. TEST=With CL:2422025 CL:2459802, echo 1 > /var/lib/power_manager/reset_ec_on_next_shutdown dbus-send --system --print-reply --dest=org.chromium.PowerManager \ /org/chromium/PowerManager \ org.chromium.PowerManager.RequestRestart \ int32:0 string:test observe that EC is rebooted. Change-Id: Ifccff3831d785091b7c99def0e43a0d20bfc412b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2428361 Commit-Queue: Pi-Hsun Shih <pihsun@chromium.org> Tested-by: Pi-Hsun Shih <pihsun@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* COIL: Rename CONFIG_I2C_CONTROLLERDiana Z2020-11-051-1/+1
| | | | | | | | | | | | | Rename CONFIG_I2C_CONTROLLER and related comments. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ied6a1829bf54a5c9a32e6772982a4b8aa31aaf23 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* System: shutdown chipset before enter hibernateSue Chen2020-11-021-14/+22
| | | | | | | | | | | | | | | | | Pressing Alt + h + Volume Up cannot enter hibernate on lazor. The DUT would boot up immediately. To ensure the KB hibernate successfully, the AP needs fully shutdown before hibernating. BUG=b:171731177 BRANCH=none TEST=Pressing Alt+h+VolumeUp can enter hibernate in S0, and can wake up by plugging AC, pressing power button. make buildall -j2 Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: I3c09c0d339ebbaab33635a283fd57bac61ebf08f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2497371 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* npcx: allow hibernate timeout when LCT is availablestabilize-13532.B-masterCaveh Jalali2020-10-131-1/+2
| | | | | | | | | | | | | | | | The npcx9 supports LCT (long countdown timers). When enabled, hibernate can wake up using the LCT module. BRANCH=none BUG=b:144427579,b:165777478 TEST=verified error message is present on volteer but not on npcx9_evb binary. Signed-off-by: Caveh Jalali <caveh@chromium.org> Change-Id: Id154153fa1a44b538bce1e3e752ea78b199befa6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2454985 Reviewed-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* npcx psl: reject hibernate request with timeoutCaveh Jalali2020-10-021-2/+7
| | | | | | | | | | | | | | | | Some Nuvoton NPCX chips support PSL (power state logic) to put the chip in a very low power state. When this feature is utilized, the alarm feature is off, thus it is not possible to hibernate for a specific period of time. Reject CLI requests to do so. BRANCH=none BUG=b:144427579 TEST=verified non-zero timeout is reject on volteer Change-Id: I17537b4724f03bd8f58ee81b80e374629c8b9b88 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2442037 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* common/system: Use beginning of panic data for calculationsPatryk Duda2020-10-011-1/+1
| | | | | | | | | | | | | | | | panic_get_data() function in some cases doesn't return the beginning of panic data. We should use get_panic_data_start() BUG=b:165773837, b:162254118 BRANCH=none TEST=Compile firmware. Flash EC RW on eve. while running RW firmware issue 'crash watchdog' command. Check if RW properly reports that reset cause was sysjump. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I2c0a7e4555b8c2e43487222d2d6c4500448ac80d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379846 Reviewed-by: Jett Rink <jettrink@chromium.org>
* cleanup:Consolidate multi PD INTR task config to single configPoornima Tom2020-09-041-3/+1
| | | | | | | | | | | | | | | | | | | For a multi Type-C board DUTs, use a common config CONFIG_HAS_TASK_PD_INT for all the PD_INT tasks defined. Also,it must be ensured that PDCMD task and PD_INT tasks are not used togethor. BUG=none BRANCH=none TEST=make buildall -j Also, adding PDCMD and PD_INT tasks in ec.tasklists successfully threw error message:"Should not use PDCMD task with PD INT tasks" Signed-off-by: Poornima Tom <poornima.tom@intel.com> Change-Id: I1c5f3dd6b46bc355bca8b93f8f1d356db54c0faa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2387686 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* system_is_locked: Use static variable to track stateDuncan Laurie2020-08-271-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_SYSTEM_UNLOCKED is not defined the function to check if flash is write protected (flash_get_protect()) can take up to 7ms to execute, and this function is called up to 18 times when booting from RO. Use a static variable to track the status so we do not spend so long executing this one function. Without this change I would regularly see a PD hard reset when booting without a battery and the system would fail to boot. BUG=b:63957122 BRANCH=eve TEST=manual testing to reliably boot without a battery on Eve Change-Id: I806a215b5745b41ce0d99aeb6853ebfecb0cb7d1 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/582542 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2320002 Tested-by: Patryk Duda <pdk@semihalf.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Patryk Duda <pdk@semihalf.com>
* System: Set stay-in-RO reset flag for sysjump and host commandDiana Z2020-08-141-3/+14
| | | | | | | | | | | | | | | | | | With EFS2, the EC can jump itself straight from RO to RW without AP intervention. However, sometimes the AP or a developer may want the EC to remain on RO to perform operations there. In these cases, set the reset flag to say in RO. BRANCH=None BUG=b:161887378 TEST=on waddledee, run "sysjump ro/rw" while the AP is on and confirm the AP remains on. Run "flashrom -p ec -w /tmp/ec.bin" and confirm the operation completes successfully. Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I036bd04514858a55e4e52abfc05eb67896436505 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354742 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* system: correct incorrect sleepJett Rink2020-07-091-1/+1
| | | | | | | | | | | | | | We are using msleep instead of usleep, so we don't need to multiply by MSEC BRANCH=none BUG=none TEST= verify that sleep is only 20 msec and that it is enough to reset power Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I6d0d3f4cf0ec9403c2e76a6ffbc068dd6554735a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290833
* usbc: ensure we are suspending USB-C ports on shutdownJett Rink2020-07-091-6/+14
| | | | | | | | | | | | | | | | | | | | | | After CL:2208221, the check for the PD_CMD task no longer trigger, so we end up not calling suspend on our TCPC ports. We want to continue to suspend, which will apply CC open in TCPMv2 for a cooperative shutdown Also, correct override keyword usage for board_get_usb_pd_port_count since I had to touch those definitions to make IS_ENABLE work BRANCH=none BUG=b:160243292 TEST=See that software sync reboot, applies CC open (and browns out system) Change-Id: I00bf08c7d347441d77834e2c5122a09ca2316280 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276318 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* Swap system_jumped_to_this_image with _late for common codeDaisuke Nojiri2020-06-261-2/+1
| | | | | | | | | | | | | | | | | EFS2 boards need to call system_jumped_late in HOOK_INIT to avoid running init code twice per boot. system_jumped_to_this_image and system_jumped_late are functionally equivalent for non EFS2 boards. BUG=chromium:1072743 BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Iecfd4f6d3e9d43cea535cfd503d6bcf7b79bc4fa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2267684 Reviewed-by: Keith Short <keithshort@chromium.org>
* system: Add system_is_manual_recovery APIDaisuke Nojiri2020-06-131-0/+5
| | | | | | | | | | | | | | | | This patch moves is_manual_recovery from common/vboot to common/system.c to make it available as a common API. There is no functionality change. BUG=none BRANCH=none TEST=EFS2 detects manual recovery. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I3e6acd979feb78ff69b78780f1095fee855b4945 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242663 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* PB: Clear AP_IDLE for EC_REBOOT_HIBERNATE_CLEAR_AP_OFFDaisuke Nojiri2020-06-131-2/+2
| | | | | | | | | | | | | | | | This patch fixes the EC_REBOOT_HIBERNATE_CLEAR_AP_OFF command to match the change made by CL:2213730. There is no functionality change. BUG=b:37536389 BRANCH=none TEST=Verify ectool hibernate-clear-ap-off works. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I70ec3a38b0ceaca8a79c6e2c6df127fb145496e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242662 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* EFS2: Verify and jump when system shuts down in RODaisuke Nojiri2020-06-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when the system shuts down in RO, EC resets with AP_OFF flag. This was for allowing the EC to jump to RW and get ready for the next normal boot after a system shuts down from the recovery mode (chromium:1045209). This behavior causes the reboot from the recovery mode to be stopped (b:154778457). This patch makes RO jump to RW instead of resetting with AP_IDLE flag. After sysjump, the AP can continue to sequence up or down. BUG=b:154778457, chromium:1045209, b:156694627, b:157077589 BRANCH=none TEST=test_that suite:faft_bios passes. TEST=Press power button in recovery screen on Zork, Puff, Volteer. System stays in S5 after sysjump. TEST=firmware_CorruptBothFwSigAB passes on Zork, Puff, Volteer. TEST=Hibernate EC on Zork, Puff, Volteer. Press power button once. System boots. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: If08f3bb7f89c2407e4c5207ade820085f65ea9ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2213359 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* system: Do pending reboot when the chipset is completely offWai-Hong Tam2020-06-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pending reboot command is currently triggered in the CHIPSET_SHUTDOWN hook. The CHIPSET_SHUTDOWN hook is triggered before the power rails are removed. The hook is executed in the CHIPSET task context, meaning the chipset is still ON. Should wait for the chipset is completely off. All the power rails are turned off. So change the hook to the CHIPSET_SHUTDOWN_COMPLETE. Also make it the lowest priority. So other hooks have chances to be executed before EC reboot. BRANCH=None BUG=b:156981868 TEST=Ran "ectool reboot_ec cold at-shutdown" and "shutdown -H now". [45.061296 power state 8 = S3->S5, in 0x0005] [45.068785 Base Accel ODR: 0 - roundup 0 from config0 [AP 0]] [45.070271 Base Accel ODR: 0 - roundup 0 from config0 [AP 0]] [45.076021 Gyro ODR: 0 - roundup 0 from config 0 [AP0]] [45.078307 PD:S3->S5] [45.078877 Gyro ODR: 0 - roundup 0 from config 0 [AP0]] [45.080055 set_pmic_pwron(0)] [45.150585 set_system_power(0)] [45.161457 power shutdown complete] Reboot at shutdown: 4 Change-Id: Ic8258cbf35fccff633d0c9ccd5d09faefc594855 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2228396 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* system: Don't check reset_flags to detect sysjumpDaisuke Nojiri2020-05-231-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, system_common_pre_init checks if reset_flags is zero or not to determine whether it's running after sysjump or not. This used to be a valid condition because reset flags in NVMEM are cleared by RO after they're read. This is not the case for CONFIG_POWER_BUTTON_INIT_IDLE because it clears every flag except AP_IDLE in case the system loses the power again. This is causing boards with CONFIG_POWER_BUTTON_INIT_IDLE fail to detect sysjump (because system_common_pre_init sees a non-zero value in the reset flag). This patch removes the check. system_common_pre_init will continue to check the magic value in the jump data. The jump data magic is always set before sysjump and cleared after sysjump. So, this check is sufficient and necessary to detect sysjump. BUG=b:154778457 BRANCH=none TEST=Verify test_that suite:faft_bios passes. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib5b8dca02dbf414f5168050e5755c993285bf791 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2213732 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* system: Add rflags console commandDaisuke Nojiri2020-05-231-4/+21
| | | | | | | | | | | | | | | | rflags prints the current reset flags saved in non-volatile memory (a.k.a. BBRAM). BUG=none BRANCH=none TEST=Verify rflags print reset flags. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Iec5e0d52c23037c4968e93dbf341b84ceb230143 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2213357 Reviewed-by: Sam Hurst <shurst@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* system: Add option to console command to reboot to ROTom Hughes2020-05-141-1/+4
| | | | | | | | | | | | | | | | | This is the same as "ap-off-in-ro", except it does not have the "AP_OFF" flag. BRANCH=none BUG=b:156401765 TEST=make buildall -j TEST=On bloonchipper console: > reboot ro Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I2f74b8c0558f60a5d5da0fe44ba30158bd946a15 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2197623 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* system: Add EC_RESET_FLAG_EFSDaisuke Nojiri2020-05-141-0/+6
| | | | | | | | | | | | | | | | | This patch adds EC_RESET_FLAG_EFS. It indicates EC jumped to RW by successfully running EFS. system_jumped_late can be used to avoid running some code twice (once in RO and again in RW). Such code is currently (wrongly) guarded by system_jumped_to_this_image. BUG=b:156101251, chromium:1072743 BRANCH=none TEST=Verified the bug is fixed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I58fc18510b2f95dfd116cbacba09875cb7cf5051 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2200245
* PD: Skip pd_prepare_sysjump if PD tasks haven't startedDaisuke Nojiri2020-05-081-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, pd_prepare_sysjump is skipped when VBOOT_EFS2 is defined. Even if VBOOT_EFS2 is enabled, late sysjump can happen when secdata kernel is missing or a communication error happens. This patch makes EC skip pd_prepare_sysjump only when PD tasks haven't started. This workaround was first added by crrev.com/c/233751. THere is no associated bug. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:1072743 BRANCH=none TEST=Verified USB devices are enumerated on Trembyle. Change-Id: I5946fd97fb20b24b9cbcb12aca3bc293651e224f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2188112 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* USB/PD: Skip pd_prepare_sysjump for EFS2 boardsDaisuke Nojiri2020-04-211-4/+10
| | | | | | | | | | | | | | | | | | | | | | Since in EFS2, USB/PD won't be enabled in RO or if it's enabled in RO, EC won't jump to RW, pd_prepare_sysjump is not needed. Even if PD is enabled because the device is not write protected, EFS2 jumps to RW before PD tasks start. So, there is no states to clean up. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:1072743, b:137493121, b:154440914 BRANCH=none TEST=Boot Puff successfully. Change-Id: Ie598105779d2a605cb63842cb6c8428f0e2c5367 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2157728 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Kangheui Won <khwon@chromium.org> Commit-Queue: Kangheui Won <khwon@chromium.org> Tested-by: Kangheui Won <khwon@chromium.org>