summaryrefslogtreecommitdiff
path: root/chip/it83xx/system.c
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2021-03-29 18:31:37 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-07 02:50:27 +0000
commitadcaef75c457970dc5b17e8bf5a2346302836832 (patch)
tree23c70c4f4be0321065b8431a3eeca6c8c72a8e1b /chip/it83xx/system.c
parent19dcdf2830ae424f7d24c828002fa133a7b7b38d (diff)
downloadchrome-ec-adcaef75c457970dc5b17e8bf5a2346302836832.tar.gz
it8xxx2: add support option CONFIG_PRESERVE_LOGS
On it8xxx2 chips, assert WRST# to reset itself will clear memory content to default value, this is a HW mechanism. So if CONFIG_PRESERVE_LOGS and CONFIG_IT83XX_HARD_RESET_BY_GPG1 are enabled at the same time, we have to save EC logs into flash before reset. We will restore logs from flash on the next initialization before jumping to main routine. BUG=b:183899510, b:183466169 BRANCH=none TEST=1) __image_size is same as ec.RW.bin size. 2) buildall. 3) manually verify reboot, poweroff, and sysjump from AP console: localhost ~ # ectool uptimeinfo EC uptime: 64.755 seconds AP resets since EC boot: 0 Most recent AP reset causes: EC reset flags at last EC boot: reset-pin | power-on localhost ~ # reboot ... localhost ~ # ectool uptimeinfo EC uptime: 19.334 seconds AP resets since EC boot: 0 Most recent AP reset causes: 71.609: reset: at AP's request EC reset flags at last EC boot: reset-pin | power-on | hard localhost ~ # poweroff ... localhost ~ # ectool uptimeinfo EC uptime: 20.627 seconds AP resets since EC boot: 0 Most recent AP reset causes: 71.609: reset: at AP's request 32.149: reset: at AP's request EC reset flags at last EC boot: reset-pin | power-on | hard localhost ~ # ectool reboot_ec RW localhost ~ # ectool uptimeinfo EC uptime: 37.998 seconds AP resets since EC boot: 0 Most recent AP reset causes: 71.609: reset: at AP's request 32.149: reset: at AP's request EC reset flags at last EC boot: reset-pin | power-on | sysjump | hard localhost ~ # Change-Id: I76b5f172b7728dc5ce9bf3a965cb7b2d638f8fc3 Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2794322 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Diffstat (limited to 'chip/it83xx/system.c')
-rw-r--r--chip/it83xx/system.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/chip/it83xx/system.c b/chip/it83xx/system.c
index 25907d1191..2f6fbd504b 100644
--- a/chip/it83xx/system.c
+++ b/chip/it83xx/system.c
@@ -13,6 +13,7 @@
#include "hooks.h"
#include "host_command.h"
#include "intc.h"
+#include "link_defs.h"
#include "registers.h"
#include "system.h"
#include "task.h"
@@ -260,6 +261,16 @@ void chip_bram_valid(void)
BRAM_VALID_FLAGS2 = BRAM_VALID_MAGIC_FIELD2;
BRAM_VALID_FLAGS3 = BRAM_VALID_MAGIC_FIELD3;
}
+
+#if defined(CONFIG_PRESERVE_LOGS) && defined(CONFIG_IT83XX_HARD_RESET_BY_GPG1)
+ if (BRAM_EC_LOG_STATUS == EC_LOG_SAVED_IN_FLASH) {
+ /* Restore EC logs from flash. */
+ memcpy((void *)__preserved_logs_start,
+ (const void *)CHIP_FLASH_PRESERVE_LOGS_BASE,
+ (uintptr_t)__preserved_logs_size);
+ }
+ BRAM_EC_LOG_STATUS = 0;
+#endif
}
void system_pre_init(void)
@@ -296,6 +307,15 @@ void system_reset(int flags)
cflush();
}
+#if defined(CONFIG_PRESERVE_LOGS) && defined(CONFIG_IT83XX_HARD_RESET_BY_GPG1)
+ /* Saving EC logs into flash before reset. */
+ flash_physical_erase(CHIP_FLASH_PRESERVE_LOGS_BASE,
+ CHIP_FLASH_PRESERVE_LOGS_SIZE);
+ flash_physical_write(CHIP_FLASH_PRESERVE_LOGS_BASE,
+ (uintptr_t)__preserved_logs_size, __preserved_logs_start);
+ BRAM_EC_LOG_STATUS = EC_LOG_SAVED_IN_FLASH;
+#endif
+
/* Disable interrupts to avoid task swaps during reboot. */
interrupt_disable();