From 555a4470c7e6373cb6d5397ea5e9278317bcb008 Mon Sep 17 00:00:00 2001 From: You-Cheng Syu Date: Tue, 9 Apr 2019 13:04:34 +0800 Subject: include: Move RESET_FLAG_* into ec_commands.h as EC_RESET_FLAG_* RESET_FLAGS_* are used when setting/reading the field ec_reset_flags of struct ec_response_uptime_info, which is defined in ec_commands.h. So it might be better to put those macros there. To be consistent with the other macros in the file, add "EC_" prefixes to them. BUG=b:109900671,b:118654976 BRANCH=none TEST=make buildall -j Cq-Depend: chrome-internal:1054910, chrome-internal:1054911, chrome-internal:1045539 Change-Id: If72ec25f1b34d8d46b74479fb4cd09252102aafa Signed-off-by: You-Cheng Syu Reviewed-on: https://chromium-review.googlesource.com/1520574 Tested-by: Yu-Ping Wu Commit-Ready: Yu-Ping Wu Legacy-Commit-Queue: Commit Bot Reviewed-by: Yilun Lin Reviewed-by: Daisuke Nojiri --- chip/g/rbox.c | 5 +++-- chip/g/system.c | 24 +++++++++++----------- chip/g/upgrade_fw.c | 2 +- chip/g/usb.c | 2 +- chip/g/watchdog.c | 3 ++- chip/host/system.c | 11 +++++----- chip/ish/ish_persistent_data.c | 3 ++- chip/ish/system.c | 4 ++-- chip/ish/watchdog.c | 3 ++- chip/it83xx/flash.c | 4 ++-- chip/it83xx/system.c | 26 ++++++++++++------------ chip/lm4/flash.c | 4 ++-- chip/lm4/system.c | 24 +++++++++++----------- chip/mchp/flash.c | 2 +- chip/mchp/system.c | 30 +++++++++++++-------------- chip/mec1322/flash.c | 2 +- chip/mec1322/system.c | 32 ++++++++++++++--------------- chip/mt_scp/system.c | 26 ++++++++++++------------ chip/npcx/gpio.c | 2 +- chip/npcx/system-npcx7.c | 3 ++- chip/npcx/system.c | 46 +++++++++++++++++++++--------------------- chip/nrf51/system.c | 11 +++++----- chip/stm32/flash-f.c | 2 +- chip/stm32/flash-stm32f3.c | 2 +- chip/stm32/flash-stm32h7.c | 4 ++-- chip/stm32/flash-stm32l.c | 2 +- chip/stm32/flash-stm32l4.c | 2 +- chip/stm32/system.c | 26 ++++++++++++------------ 28 files changed, 157 insertions(+), 150 deletions(-) (limited to 'chip') diff --git a/chip/g/rbox.c b/chip/g/rbox.c index 6399f0b612..6aaa0206eb 100644 --- a/chip/g/rbox.c +++ b/chip/g/rbox.c @@ -4,6 +4,7 @@ */ #include "clock.h" +#include "ec_commands.h" #include "hooks.h" #include "rdd.h" #include "registers.h" @@ -68,7 +69,7 @@ static void rbox_release_ec_reset(void) * * Release PINMUX HOLD, so the board can detect changes on TPM_RST_L. */ - if (!(system_get_reset_flags() & RESET_FLAG_HIBERNATE) && + if (!(system_get_reset_flags() & EC_RESET_FLAG_HIBERNATE) && board_uses_closed_loop_reset()) { return; } @@ -77,7 +78,7 @@ static void rbox_release_ec_reset(void) * After a POR, if the power button is held, then delay releasing * EC_RST_L. */ - if ((system_get_reset_flags() & RESET_FLAG_POWER_ON) && + if ((system_get_reset_flags() & EC_RESET_FLAG_POWER_ON) && rbox_powerbtn_is_pressed()) { hook_call_deferred(&rbox_check_rdd_data, RDD_WAIT_TIME); return; diff --git a/chip/g/system.c b/chip/g/system.c index d15ec42ebe..c2ee5bdabb 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -40,7 +40,7 @@ static void check_reset_cause(void) if (g_rstsrc & GC_PMU_RSTSRC_POR_MASK) { /* If power-on reset is true, that's the only thing */ - system_set_reset_flags(RESET_FLAG_POWER_ON); + system_set_reset_flags(EC_RESET_FLAG_POWER_ON); return; } @@ -49,39 +49,39 @@ static void check_reset_cause(void) /* This register is cleared by reading it */ uint32_t g_exitpd = GR_PMU_EXITPD_SRC; - flags |= RESET_FLAG_HIBERNATE; + flags |= EC_RESET_FLAG_HIBERNATE; if (g_exitpd & GC_PMU_EXITPD_SRC_PIN_PD_EXIT_MASK) - flags |= RESET_FLAG_WAKE_PIN; + flags |= EC_RESET_FLAG_WAKE_PIN; if (g_exitpd & GC_PMU_EXITPD_SRC_UTMI_SUSPEND_N_MASK) - flags |= RESET_FLAG_USB_RESUME; + flags |= EC_RESET_FLAG_USB_RESUME; if (g_exitpd & (GC_PMU_EXITPD_SRC_TIMELS0_PD_EXIT_TIMER0_MASK | GC_PMU_EXITPD_SRC_TIMELS0_PD_EXIT_TIMER1_MASK)) - flags |= RESET_FLAG_RTC_ALARM; + flags |= EC_RESET_FLAG_RTC_ALARM; if (g_exitpd & GC_PMU_EXITPD_SRC_RDD0_PD_EXIT_TIMER_MASK) - flags |= RESET_FLAG_RDD; + flags |= EC_RESET_FLAG_RDD; if (g_exitpd & GC_PMU_EXITPD_SRC_RBOX_WAKEUP_MASK) - flags |= RESET_FLAG_RBOX; + flags |= EC_RESET_FLAG_RBOX; } if (g_rstsrc & GC_PMU_RSTSRC_SOFTWARE_MASK) - flags |= RESET_FLAG_HARD; + flags |= EC_RESET_FLAG_HARD; if (g_rstsrc & GC_PMU_RSTSRC_SYSRESET_MASK) - flags |= RESET_FLAG_SOFT; + flags |= EC_RESET_FLAG_SOFT; if (g_rstsrc & GC_PMU_RSTSRC_FST_BRNOUT_MASK) - flags |= RESET_FLAG_BROWNOUT; + flags |= EC_RESET_FLAG_BROWNOUT; /* * GC_PMU_RSTSRC_WDOG and GC_PMU_RSTSRC_LOCKUP are considered security * threats. They won't show up as a direct reset cause. */ if (g_rstsrc & GC_PMU_RSTSRC_SEC_THREAT_MASK) - flags |= RESET_FLAG_SECURITY; + flags |= EC_RESET_FLAG_SECURITY; if (g_rstsrc && !flags) - flags |= RESET_FLAG_OTHER; + flags |= EC_RESET_FLAG_OTHER; system_set_reset_flags(flags); } diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c index 71a9d36403..276eac8f92 100644 --- a/chip/g/upgrade_fw.c +++ b/chip/g/upgrade_fw.c @@ -330,7 +330,7 @@ static int chunk_came_too_soon(uint32_t block_offset) } if (!prev_timestamp) { - int hard_reset = system_get_reset_flags() & RESET_FLAG_HARD; + int hard_reset = system_get_reset_flags() & EC_RESET_FLAG_HARD; /* * If we just recovered from a hard reset, we have to wait until diff --git a/chip/g/usb.c b/chip/g/usb.c index 72fbe75ea8..9a605b65dc 100644 --- a/chip/g/usb.c +++ b/chip/g/usb.c @@ -1296,7 +1296,7 @@ void usb_init(void) * for some other reason, we just do a normal USB reset. The host * doesn't mind. */ - resume = ((system_get_reset_flags() & RESET_FLAG_USB_RESUME) && + resume = ((system_get_reset_flags() & EC_RESET_FLAG_USB_RESUME) && (GR_USB_GINTSTS & GC_USB_GINTSTS_WKUPINT_MASK)); /* TODO(crosbug.com/p/46813): Clean this up. Do only what's needed, and diff --git a/chip/g/watchdog.c b/chip/g/watchdog.c index 1ffd203843..c5560fc0d7 100644 --- a/chip/g/watchdog.c +++ b/chip/g/watchdog.c @@ -6,6 +6,7 @@ /* Watchdog driver */ #include "common.h" +#include "ec_commands.h" #include "hooks.h" #include "registers.h" #include "task.h" @@ -22,7 +23,7 @@ void __attribute__((used)) trace_and_reset(uint32_t excep_lr, uint32_t excep_sp) { watchdog_trace(excep_lr, excep_sp); - system_reset(RESET_FLAG_WATCHDOG); + system_reset(EC_RESET_FLAG_WATCHDOG); } /* Warning interrupt at the middle of the watchdog period */ diff --git a/chip/host/system.c b/chip/host/system.c index 86e6625964..b1654911ab 100644 --- a/chip/host/system.c +++ b/chip/host/system.c @@ -6,6 +6,7 @@ /* System module for emulator */ #include "common.h" +#include "ec_commands.h" #include "host_test.h" #include "panic.h" #include "persistence.h" @@ -100,7 +101,7 @@ static uint32_t load_reset_flags(void) uint32_t ret; if (f == NULL) - return RESET_FLAG_POWER_ON; + return EC_RESET_FLAG_POWER_ON; fread(&ret, sizeof(ret), 1, f); release_persistent_storage(f); remove_persistent_storage("reset_flags"); @@ -141,11 +142,11 @@ test_mockable void system_reset(int flags) { uint32_t save_flags = 0; if (flags & SYSTEM_RESET_PRESERVE_FLAGS) - save_flags = system_get_reset_flags() | RESET_FLAG_PRESERVED; + save_flags = system_get_reset_flags() | EC_RESET_FLAG_PRESERVED; if (flags & SYSTEM_RESET_LEAVE_AP_OFF) - save_flags |= RESET_FLAG_AP_OFF; + save_flags |= EC_RESET_FLAG_AP_OFF; if (flags & SYSTEM_RESET_HARD) - save_flags |= RESET_FLAG_HARD; + save_flags |= EC_RESET_FLAG_HARD; if (save_flags) save_reset_flags(save_flags); emulator_reboot(); @@ -158,7 +159,7 @@ test_mockable void system_hibernate(uint32_t seconds, uint32_t microseconds) if (board_hibernate) board_hibernate(); - save_reset_flags(RESET_FLAG_HIBERNATE); + save_reset_flags(EC_RESET_FLAG_HIBERNATE); if (!seconds && !microseconds) exit(EXIT_CODE_HIBERNATE); diff --git a/chip/ish/ish_persistent_data.c b/chip/ish/ish_persistent_data.c index c5168475d5..003f781d5f 100644 --- a/chip/ish/ish_persistent_data.c +++ b/chip/ish/ish_persistent_data.c @@ -4,6 +4,7 @@ */ #include "common.h" +#include "ec_commands.h" #include "config.h" #include "hooks.h" #include "system.h" @@ -13,7 +14,7 @@ struct ish_persistent_data ish_persistent_data = { .magic = PERSISTENT_DATA_MAGIC, - .reset_flags = RESET_FLAG_POWER_ON, + .reset_flags = EC_RESET_FLAG_POWER_ON, .watchdog_counter = 0, .panic_data = {0}, }; diff --git a/chip/ish/system.c b/chip/ish/system.c index c18261e0da..2d4a55bd3b 100644 --- a/chip/ish/system.c +++ b/chip/ish/system.c @@ -29,7 +29,7 @@ int system_is_reboot_warm(void) { return !(system_get_reset_flags() & - (RESET_FLAG_POWER_ON | RESET_FLAG_HARD)); + (EC_RESET_FLAG_POWER_ON | EC_RESET_FLAG_HARD)); } void system_pre_init(void) @@ -87,7 +87,7 @@ void system_reset(int flags) system_encode_save_flags(flags, &save_flags); if (flags & SYSTEM_RESET_AP_WATCHDOG) { - save_flags |= RESET_FLAG_WATCHDOG; + save_flags |= EC_RESET_FLAG_WATCHDOG; ish_persistent_data.watchdog_counter += 1; if (ish_persistent_data.watchdog_counter >= CONFIG_WATCHDOG_MAX_RETRIES) { diff --git a/chip/ish/watchdog.c b/chip/ish/watchdog.c index 2e83b57f25..bf78f49312 100644 --- a/chip/ish/watchdog.c +++ b/chip/ish/watchdog.c @@ -20,6 +20,7 @@ */ #include "common.h" +#include "ec_commands.h" #include "hooks.h" #include "ish_persistent_data.h" #include "task.h" @@ -37,7 +38,7 @@ int watchdog_init(void) * Put reset counter back at zero if last reset was not caused * by watchdog */ - if ((system_get_reset_flags() & RESET_FLAG_WATCHDOG) == 0) + if ((system_get_reset_flags() & EC_RESET_FLAG_WATCHDOG) == 0) ish_persistent_data.watchdog_counter = 0; /* Initialize WDT clock divider */ diff --git a/chip/it83xx/flash.c b/chip/it83xx/flash.c index cae6eced7c..ec416ee41a 100644 --- a/chip/it83xx/flash.c +++ b/chip/it83xx/flash.c @@ -621,7 +621,7 @@ int flash_pre_init(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) + if (reset_flags & EC_RESET_FLAG_SYSJUMP) return EC_SUCCESS; if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) { @@ -661,7 +661,7 @@ int flash_pre_init(void) * write-protect. If it didn't, then the flash write protect registers * have been permanently committed and we can't fix that. */ - if (reset_flags & RESET_FLAG_POWER_ON) { + if (reset_flags & EC_RESET_FLAG_POWER_ON) { stuck_locked = 1; return EC_ERROR_ACCESS_DENIED; } else { diff --git a/chip/it83xx/system.c b/chip/it83xx/system.c index c5affcff59..667b8130cd 100644 --- a/chip/it83xx/system.c +++ b/chip/it83xx/system.c @@ -56,20 +56,20 @@ static void check_reset_cause(void) /* Determine if watchdog reset or power on reset. */ if (raw_reset_cause & 0x02) { - flags |= RESET_FLAG_WATCHDOG; + flags |= EC_RESET_FLAG_WATCHDOG; } else if (raw_reset_cause & 0x01) { - flags |= RESET_FLAG_POWER_ON; + flags |= EC_RESET_FLAG_POWER_ON; } else { if ((IT83XX_GCTRL_RSTS & 0xC0) == 0x80) - flags |= RESET_FLAG_POWER_ON; + flags |= EC_RESET_FLAG_POWER_ON; } if (raw_reset_cause2 & 0x04) - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; /* watchdog module triggers these reset */ - if (flags & (RESET_FLAG_HARD | RESET_FLAG_SOFT)) - flags &= ~RESET_FLAG_WATCHDOG; + if (flags & (EC_RESET_FLAG_HARD | EC_RESET_FLAG_SOFT)) + flags &= ~EC_RESET_FLAG_WATCHDOG; /* Clear saved reset flags. */ BRAM_RESET_FLAGS0 = 0; @@ -104,12 +104,12 @@ int system_is_reboot_warm(void) check_reset_cause(); reset_flags = system_get_reset_flags(); - if ((reset_flags & RESET_FLAG_RESET_PIN) || - (reset_flags & RESET_FLAG_POWER_ON) || - (reset_flags & RESET_FLAG_WATCHDOG) || - (reset_flags & RESET_FLAG_HARD) || - (reset_flags & RESET_FLAG_SOFT) || - (reset_flags & RESET_FLAG_HIBERNATE)) + if ((reset_flags & EC_RESET_FLAG_RESET_PIN) || + (reset_flags & EC_RESET_FLAG_POWER_ON) || + (reset_flags & EC_RESET_FLAG_WATCHDOG) || + (reset_flags & EC_RESET_FLAG_HARD) || + (reset_flags & EC_RESET_FLAG_SOFT) || + (reset_flags & EC_RESET_FLAG_HIBERNATE)) return 0; else return 1; @@ -165,7 +165,7 @@ void system_reset(int flags) system_encode_save_flags(flags, &save_flags); if (clock_ec_wake_from_sleep()) - save_flags |= RESET_FLAG_HIBERNATE; + save_flags |= EC_RESET_FLAG_HIBERNATE; /* Store flags to battery backed RAM. */ BRAM_RESET_FLAGS0 = save_flags >> 24; diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c index 2a7996aee9..4f7e905e21 100644 --- a/chip/lm4/flash.c +++ b/chip/lm4/flash.c @@ -243,7 +243,7 @@ int flash_pre_init(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) + if (reset_flags & EC_RESET_FLAG_SYSJUMP) return EC_SUCCESS; if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) { @@ -280,7 +280,7 @@ int flash_pre_init(void) * write-protect. If it didn't, then the flash write protect registers * have been permanently committed and we can't fix that. */ - if (reset_flags & RESET_FLAG_POWER_ON) { + if (reset_flags & EC_RESET_FLAG_POWER_ON) { stuck_locked = 1; return EC_ERROR_ACCESS_DENIED; } diff --git a/chip/lm4/system.c b/chip/lm4/system.c index 5797e91da4..cf7705ff06 100644 --- a/chip/lm4/system.c +++ b/chip/lm4/system.c @@ -123,7 +123,7 @@ static void check_reset_cause(void) * Note that this is also triggered by hibernation, because * that de-powers the chip. */ - flags |= RESET_FLAG_POWER_ON; + flags |= EC_RESET_FLAG_POWER_ON; } else if (!flags && (raw_reset_cause & 0x01)) { /* * LM4 signals the reset pin in RESC for all power-on resets, @@ -131,42 +131,42 @@ static void check_reset_cause(void) * this flag mutually-exclusive with power on flag, so we can * use it to indicate a keyboard-triggered reset. */ - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; } if (raw_reset_cause & 0x04) - flags |= RESET_FLAG_BROWNOUT; + flags |= EC_RESET_FLAG_BROWNOUT; if (raw_reset_cause & 0x10) - flags |= RESET_FLAG_SOFT; + flags |= EC_RESET_FLAG_SOFT; if (raw_reset_cause & 0x28) { /* Watchdog timer 0 or 1 */ - flags |= RESET_FLAG_WATCHDOG; + flags |= EC_RESET_FLAG_WATCHDOG; } /* Handle other raw reset causes */ if (raw_reset_cause && !flags) - flags |= RESET_FLAG_OTHER; + flags |= EC_RESET_FLAG_OTHER; if ((hib_status & 0x09) && (hib_wake_flags & HIBDATA_WAKE_HARD_RESET)) { /* Hibernation caused by software-triggered hard reset */ - flags |= RESET_FLAG_HARD; + flags |= EC_RESET_FLAG_HARD; /* Consume the hibernate reasons so we don't see them below */ hib_status &= ~0x09; } if ((hib_status & 0x01) && (hib_wake_flags & HIBDATA_WAKE_RTC)) - flags |= RESET_FLAG_RTC_ALARM; + flags |= EC_RESET_FLAG_RTC_ALARM; if ((hib_status & 0x08) && (hib_wake_flags & HIBDATA_WAKE_PIN)) - flags |= RESET_FLAG_WAKE_PIN; + flags |= EC_RESET_FLAG_WAKE_PIN; if (hib_status & 0x04) - flags |= RESET_FLAG_LOW_BATTERY; + flags |= EC_RESET_FLAG_LOW_BATTERY; /* Restore then clear saved reset flags */ flags |= hibdata_read(HIBDATA_INDEX_SAVED_RESET_FLAGS); @@ -524,10 +524,10 @@ void system_reset(int flags) /* Save current reset reasons if necessary */ if (flags & SYSTEM_RESET_PRESERVE_FLAGS) - save_flags = system_get_reset_flags() | RESET_FLAG_PRESERVED; + save_flags = system_get_reset_flags() | EC_RESET_FLAG_PRESERVED; if (flags & SYSTEM_RESET_LEAVE_AP_OFF) - save_flags |= RESET_FLAG_AP_OFF; + save_flags |= EC_RESET_FLAG_AP_OFF; hibdata_write(HIBDATA_INDEX_SAVED_RESET_FLAGS, save_flags); diff --git a/chip/mchp/flash.c b/chip/mchp/flash.c index ca198476b8..043e2b268f 100644 --- a/chip/mchp/flash.c +++ b/chip/mchp/flash.c @@ -251,7 +251,7 @@ int flash_physical_restore_state(void) * could have applied write protection. Nothing additional needs * to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) { + if (reset_flags & EC_RESET_FLAG_SYSJUMP) { prev = (const struct flash_wp_state *)system_get_jump_tag( FLASH_SYSJUMP_TAG, &version, &size); if (prev && version == FLASH_HOOK_VERSION && diff --git a/chip/mchp/system.c b/chip/mchp/system.c index 3117638bd5..b481f2ba26 100644 --- a/chip/mchp/system.c +++ b/chip/mchp/system.c @@ -60,16 +60,16 @@ static void check_reset_cause(void) * BIT[6] determine VTR reset */ if (rst_sts & MCHP_PWR_RST_STS_VTR) - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; flags |= MCHP_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS); MCHP_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = 0; - if ((status & MCHP_VBAT_STS_WDT) && !(flags & (RESET_FLAG_SOFT | - RESET_FLAG_HARD | - RESET_FLAG_HIBERNATE))) - flags |= RESET_FLAG_WATCHDOG; + if ((status & MCHP_VBAT_STS_WDT) && !(flags & (EC_RESET_FLAG_SOFT | + EC_RESET_FLAG_HARD | + EC_RESET_FLAG_HIBERNATE))) + flags |= EC_RESET_FLAG_WATCHDOG; trace11(0, MEC, 0, "check_reset_cause: EC reset flags = 0x%08x", flags); @@ -86,11 +86,11 @@ int system_is_reboot_warm(void) check_reset_cause(); reset_flags = system_get_reset_flags(); - if ((reset_flags & RESET_FLAG_RESET_PIN) || - (reset_flags & RESET_FLAG_POWER_ON) || - (reset_flags & RESET_FLAG_WATCHDOG) || - (reset_flags & RESET_FLAG_HARD) || - (reset_flags & RESET_FLAG_SOFT)) + if ((reset_flags & EC_RESET_FLAG_RESET_PIN) || + (reset_flags & EC_RESET_FLAG_POWER_ON) || + (reset_flags & EC_RESET_FLAG_WATCHDOG) || + (reset_flags & EC_RESET_FLAG_HARD) || + (reset_flags & EC_RESET_FLAG_SOFT)) return 0; else return 1; @@ -218,17 +218,17 @@ void __attribute__((noreturn)) _system_reset(int flags, /* Save current reset reasons if necessary */ if (flags & SYSTEM_RESET_PRESERVE_FLAGS) - save_flags = system_get_reset_flags() | RESET_FLAG_PRESERVED; + save_flags = system_get_reset_flags() | EC_RESET_FLAG_PRESERVED; if (flags & SYSTEM_RESET_LEAVE_AP_OFF) - save_flags |= RESET_FLAG_AP_OFF; + save_flags |= EC_RESET_FLAG_AP_OFF; if (wake_from_hibernate) - save_flags |= RESET_FLAG_HIBERNATE; + save_flags |= EC_RESET_FLAG_HIBERNATE; else if (flags & SYSTEM_RESET_HARD) - save_flags |= RESET_FLAG_HARD; + save_flags |= EC_RESET_FLAG_HARD; else - save_flags |= RESET_FLAG_SOFT; + save_flags |= EC_RESET_FLAG_SOFT; chip_save_reset_flags(save_flags); diff --git a/chip/mec1322/flash.c b/chip/mec1322/flash.c index 2cd8dd156d..b6ab76113b 100644 --- a/chip/mec1322/flash.c +++ b/chip/mec1322/flash.c @@ -241,7 +241,7 @@ int flash_physical_restore_state(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) { + if (reset_flags & EC_RESET_FLAG_SYSJUMP) { prev = (const struct flash_wp_state *)system_get_jump_tag( FLASH_SYSJUMP_TAG, &version, &size); if (prev && version == FLASH_HOOK_VERSION && diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index 13bb83920b..e50d97bc6d 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -44,16 +44,16 @@ static void check_reset_cause(void) * BIT[6] determine VCC1 reset */ if (rst_sts & MEC1322_PWR_RST_STS_VCC1) - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; flags |= MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS); MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = 0; - if ((status & MEC1322_VBAT_STS_WDT) && !(flags & (RESET_FLAG_SOFT | - RESET_FLAG_HARD | - RESET_FLAG_HIBERNATE))) - flags |= RESET_FLAG_WATCHDOG; + if ((status & MEC1322_VBAT_STS_WDT) && !(flags & (EC_RESET_FLAG_SOFT | + EC_RESET_FLAG_HARD | + EC_RESET_FLAG_HIBERNATE))) + flags |= EC_RESET_FLAG_WATCHDOG; system_set_reset_flags(flags); } @@ -68,12 +68,12 @@ int system_is_reboot_warm(void) check_reset_cause(); reset_flags = system_get_reset_flags(); - if ((reset_flags & RESET_FLAG_RESET_PIN) || - (reset_flags & RESET_FLAG_POWER_ON) || - (reset_flags & RESET_FLAG_WATCHDOG) || - (reset_flags & RESET_FLAG_HARD) || - (reset_flags & RESET_FLAG_SOFT) || - (reset_flags & RESET_FLAG_HIBERNATE)) + if ((reset_flags & EC_RESET_FLAG_RESET_PIN) || + (reset_flags & EC_RESET_FLAG_POWER_ON) || + (reset_flags & EC_RESET_FLAG_WATCHDOG) || + (reset_flags & EC_RESET_FLAG_HARD) || + (reset_flags & EC_RESET_FLAG_SOFT) || + (reset_flags & EC_RESET_FLAG_HIBERNATE)) return 0; else return 1; @@ -113,17 +113,17 @@ void _system_reset(int flags, int wake_from_hibernate) /* Save current reset reasons if necessary */ if (flags & SYSTEM_RESET_PRESERVE_FLAGS) - save_flags = system_get_reset_flags() | RESET_FLAG_PRESERVED; + save_flags = system_get_reset_flags() | EC_RESET_FLAG_PRESERVED; if (flags & SYSTEM_RESET_LEAVE_AP_OFF) - save_flags |= RESET_FLAG_AP_OFF; + save_flags |= EC_RESET_FLAG_AP_OFF; if (wake_from_hibernate) - save_flags |= RESET_FLAG_HIBERNATE; + save_flags |= EC_RESET_FLAG_HIBERNATE; else if (flags & SYSTEM_RESET_HARD) - save_flags |= RESET_FLAG_HARD; + save_flags |= EC_RESET_FLAG_HARD; else - save_flags |= RESET_FLAG_SOFT; + save_flags |= EC_RESET_FLAG_SOFT; chip_save_reset_flags(save_flags); diff --git a/chip/mt_scp/system.c b/chip/mt_scp/system.c index eaf37e5626..6bd2e76644 100644 --- a/chip/mt_scp/system.c +++ b/chip/mt_scp/system.c @@ -96,14 +96,14 @@ void system_reset(int flags) /* Save current reset reasons if necessary */ if (flags & SYSTEM_RESET_PRESERVE_FLAGS) - save_flags = system_get_reset_flags() | RESET_FLAG_PRESERVED; + save_flags = system_get_reset_flags() | EC_RESET_FLAG_PRESERVED; if (flags & SYSTEM_RESET_LEAVE_AP_OFF) - save_flags |= RESET_FLAG_AP_OFF; + save_flags |= EC_RESET_FLAG_AP_OFF; /* Remember that the software asked us to hard reboot */ if (flags & SYSTEM_RESET_HARD) - save_flags |= RESET_FLAG_HARD; + save_flags |= EC_RESET_FLAG_HARD; /* Reset flags are 32-bits, but save only 16 bits. */ ASSERT(!(save_flags >> 16)); @@ -141,14 +141,14 @@ static void check_reset_cause(void) if ((raw_reset_cause & 0xffff0000) == PWRON_DEFAULT) { /* Reboot */ if (raw_reset_cause & PWRON_WATCHDOG) - flags |= RESET_FLAG_WATCHDOG; + flags |= EC_RESET_FLAG_WATCHDOG; else if (raw_reset_cause & PWRON_RESET) - flags |= RESET_FLAG_POWER_ON; + flags |= EC_RESET_FLAG_POWER_ON; else - flags |= RESET_FLAG_OTHER; + flags |= EC_RESET_FLAG_OTHER; } else { /* Power lost restart */ - flags |= RESET_FLAG_POWER_ON; + flags |= EC_RESET_FLAG_POWER_ON; } system_set_reset_flags(SCP_GPR[0] >> 16); SCP_GPR[0] &= 0xffff; @@ -157,12 +157,12 @@ static void check_reset_cause(void) int system_is_reboot_warm(void) { const uint32_t cold_flags = - RESET_FLAG_RESET_PIN | - RESET_FLAG_POWER_ON | - RESET_FLAG_WATCHDOG | - RESET_FLAG_HARD | - RESET_FLAG_SOFT | - RESET_FLAG_HIBERNATE; + EC_RESET_FLAG_RESET_PIN | + EC_RESET_FLAG_POWER_ON | + EC_RESET_FLAG_WATCHDOG | + EC_RESET_FLAG_HARD | + EC_RESET_FLAG_SOFT | + EC_RESET_FLAG_HIBERNATE; check_reset_cause(); diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c index 759d6fbbd8..397d87b501 100644 --- a/chip/npcx/gpio.c +++ b/chip/npcx/gpio.c @@ -511,7 +511,7 @@ void gpio_pre_init(void) * * Make sure to set up the timer before using udelay(). */ - if (system_get_reset_flags() & RESET_FLAG_POWER_ON) { + if (system_get_reset_flags() & EC_RESET_FLAG_POWER_ON) { __hw_early_init_hwtimer(0); udelay(CONFIG_GPIO_INIT_POWER_ON_DELAY_MS * MSEC); } diff --git a/chip/npcx/system-npcx7.c b/chip/npcx/system-npcx7.c index 6b0e5157ea..9e461c5a1b 100644 --- a/chip/npcx/system-npcx7.c +++ b/chip/npcx/system-npcx7.c @@ -7,6 +7,7 @@ #include "common.h" #include "console.h" #include "cpu.h" +#include "ec_commands.h" #include "hooks.h" #include "registers.h" #include "system.h" @@ -165,7 +166,7 @@ void __hibernate_npcx_series(void) #if defined(CONFIG_HIBERNATE_PSL) static void report_psl_wake_source(void) { - if (!(system_get_reset_flags() & RESET_FLAG_HIBERNATE)) + if (!(system_get_reset_flags() & EC_RESET_FLAG_HIBERNATE)) return; CPRINTS("PSL_CTS: 0x%x", NPCX_GLUE_PSL_CTS & 0xf); diff --git a/chip/npcx/system.c b/chip/npcx/system.c index 5bf768dbc6..ff18334533 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -338,9 +338,9 @@ uint32_t chip_read_reset_flags(void) static void board_chipset_startup(void) { uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS); - flags &= ~RESET_FLAG_AP_OFF; + flags &= ~EC_RESET_FLAG_AP_OFF; chip_save_reset_flags(flags); - system_clear_reset_flags(RESET_FLAG_AP_OFF); + system_clear_reset_flags(EC_RESET_FLAG_AP_OFF); CPRINTS("Cleared AP_OFF flag"); } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); @@ -348,9 +348,9 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); static void board_chipset_shutdown(void) { uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS); - flags |= RESET_FLAG_AP_OFF; + flags |= EC_RESET_FLAG_AP_OFF; chip_save_reset_flags(flags); - system_set_reset_flags(RESET_FLAG_AP_OFF); + system_set_reset_flags(EC_RESET_FLAG_AP_OFF); CPRINTS("Set AP_OFF flag"); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, @@ -367,7 +367,7 @@ static void check_reset_cause(void) /* Clear saved reset flags in bbram */ #ifdef CONFIG_POWER_BUTTON_INIT_IDLE /* We'll clear AP_OFF on S5->S3 transition */ - chip_save_reset_flags(flags & RESET_FLAG_AP_OFF); + chip_save_reset_flags(flags & EC_RESET_FLAG_AP_OFF); #else chip_save_reset_flags(0); #endif @@ -378,13 +378,13 @@ static void check_reset_cause(void) if (!IS_BIT_SET(NPCX_RSTCTL, NPCX_RSTCTL_VCC1_RST_SCRATCH)) { #ifdef CONFIG_BOARD_FORCE_RESET_PIN /* Treat all resets as RESET_PIN */ - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; #else /* Check for VCC1 reset */ if (IS_BIT_SET(NPCX_RSTCTL, NPCX_RSTCTL_VCC1_RST_STS)) - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; else - flags |= RESET_FLAG_POWER_ON; + flags |= EC_RESET_FLAG_POWER_ON; #endif } @@ -397,27 +397,27 @@ static void check_reset_cause(void) /* Software debugger reset */ if (IS_BIT_SET(NPCX_RSTCTL, NPCX_RSTCTL_DBGRST_STS)) { - flags |= RESET_FLAG_SOFT; + flags |= EC_RESET_FLAG_SOFT; /* Clear debugger reset status initially*/ SET_BIT(NPCX_RSTCTL, NPCX_RSTCTL_DBGRST_STS); } /* Reset by hibernate */ if (hib_wake_flags & HIBERNATE_WAKE_PIN) - flags |= RESET_FLAG_WAKE_PIN | RESET_FLAG_HIBERNATE; + flags |= EC_RESET_FLAG_WAKE_PIN | EC_RESET_FLAG_HIBERNATE; else if (hib_wake_flags & HIBERNATE_WAKE_MTC) - flags |= RESET_FLAG_RTC_ALARM | RESET_FLAG_HIBERNATE; + flags |= EC_RESET_FLAG_RTC_ALARM | EC_RESET_FLAG_HIBERNATE; /* Watchdog Reset */ if (IS_BIT_SET(NPCX_T0CSR, NPCX_T0CSR_WDRST_STS)) { /* - * Don't set RESET_FLAG_WATCHDOG flag if watchdog is issued by - * system_reset or hibernate in order to distinguish reset cause - * is panic reason or not. + * Don't set EC_RESET_FLAG_WATCHDOG flag if watchdog is issued + * by system_reset or hibernate in order to distinguish reset + * cause is panic reason or not. */ - if (!(flags & (RESET_FLAG_SOFT | RESET_FLAG_HARD | - RESET_FLAG_HIBERNATE))) - flags |= RESET_FLAG_WATCHDOG; + if (!(flags & (EC_RESET_FLAG_SOFT | EC_RESET_FLAG_HARD | + EC_RESET_FLAG_HIBERNATE))) + flags |= EC_RESET_FLAG_WATCHDOG; /* Clear watchdog reset status initially*/ SET_BIT(NPCX_T0CSR, NPCX_T0CSR_WDRST_STS); @@ -925,12 +925,12 @@ int system_is_reboot_warm(void) check_reset_cause(); reset_flags = system_get_reset_flags(); - if ((reset_flags & RESET_FLAG_RESET_PIN) || - (reset_flags & RESET_FLAG_POWER_ON) || - (reset_flags & RESET_FLAG_WATCHDOG) || - (reset_flags & RESET_FLAG_HARD) || - (reset_flags & RESET_FLAG_SOFT) || - (reset_flags & RESET_FLAG_HIBERNATE)) + if ((reset_flags & EC_RESET_FLAG_RESET_PIN) || + (reset_flags & EC_RESET_FLAG_POWER_ON) || + (reset_flags & EC_RESET_FLAG_WATCHDOG) || + (reset_flags & EC_RESET_FLAG_HARD) || + (reset_flags & EC_RESET_FLAG_SOFT) || + (reset_flags & EC_RESET_FLAG_HIBERNATE)) return 0; else return 1; diff --git a/chip/nrf51/system.c b/chip/nrf51/system.c index 6a3b0888c5..dc7bff2059 100644 --- a/chip/nrf51/system.c +++ b/chip/nrf51/system.c @@ -7,6 +7,7 @@ #include "common.h" #include "console.h" +#include "ec_commands.h" #include "registers.h" #include "system.h" #include "task.h" @@ -50,22 +51,22 @@ static void check_reset_cause(void) uint32_t raw_cause = NRF51_POWER_RESETREAS; if (raw_cause & NRF51_POWER_RESETREAS_RESETPIN) - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; if (raw_cause & NRF51_POWER_RESETREAS_DOG) - flags |= RESET_FLAG_WATCHDOG; + flags |= EC_RESET_FLAG_WATCHDOG; /* Note that the programmer uses a soft reset in debug mode. */ if (raw_cause & NRF51_POWER_RESETREAS_SREQ) - flags |= RESET_FLAG_SOFT; + flags |= EC_RESET_FLAG_SOFT; if (raw_cause & (NRF51_POWER_RESETREAS_OFF | NRF51_POWER_RESETREAS_LPCOMP)) - flags |= RESET_FLAG_WAKE_PIN; + flags |= EC_RESET_FLAG_WAKE_PIN; if (raw_cause & (NRF51_POWER_RESETREAS_LOCKUP | NRF51_POWER_RESETREAS_DIF)) - flags |= RESET_FLAG_OTHER; + flags |= EC_RESET_FLAG_OTHER; system_set_reset_flags(flags); diff --git a/chip/stm32/flash-f.c b/chip/stm32/flash-f.c index 5bfec02a62..14182c54a4 100644 --- a/chip/stm32/flash-f.c +++ b/chip/stm32/flash-f.c @@ -689,7 +689,7 @@ int flash_pre_init(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) + if (reset_flags & EC_RESET_FLAG_SYSJUMP) return EC_SUCCESS; if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) { diff --git a/chip/stm32/flash-stm32f3.c b/chip/stm32/flash-stm32f3.c index efa74c90cd..a413d98d43 100644 --- a/chip/stm32/flash-stm32f3.c +++ b/chip/stm32/flash-stm32f3.c @@ -175,7 +175,7 @@ int flash_physical_restore_state(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) { + if (reset_flags & EC_RESET_FLAG_SYSJUMP) { prev = (const struct flash_wp_state *)system_get_jump_tag( FLASH_SYSJUMP_TAG, &version, &size); if (prev && version == FLASH_HOOK_VERSION && diff --git a/chip/stm32/flash-stm32h7.c b/chip/stm32/flash-stm32h7.c index 960f478cd2..5f5d1ef528 100644 --- a/chip/stm32/flash-stm32h7.c +++ b/chip/stm32/flash-stm32h7.c @@ -465,7 +465,7 @@ int flash_pre_init(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) + if (reset_flags & EC_RESET_FLAG_SYSJUMP) return EC_SUCCESS; if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) { @@ -499,7 +499,7 @@ int flash_pre_init(void) * write-protect. If it didn't, then the flash write protect registers * have been permanently committed and we can't fix that. */ - if (reset_flags & RESET_FLAG_POWER_ON) { + if (reset_flags & EC_RESET_FLAG_POWER_ON) { stuck_locked = 1; return EC_ERROR_ACCESS_DENIED; } diff --git a/chip/stm32/flash-stm32l.c b/chip/stm32/flash-stm32l.c index ef4f19e09d..a151a26cf8 100644 --- a/chip/stm32/flash-stm32l.c +++ b/chip/stm32/flash-stm32l.c @@ -436,7 +436,7 @@ int flash_pre_init(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) + if (reset_flags & EC_RESET_FLAG_SYSJUMP) return EC_SUCCESS; if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) { diff --git a/chip/stm32/flash-stm32l4.c b/chip/stm32/flash-stm32l4.c index 97594733c0..c138780d34 100644 --- a/chip/stm32/flash-stm32l4.c +++ b/chip/stm32/flash-stm32l4.c @@ -450,7 +450,7 @@ int flash_pre_init(void) * If we have already jumped between images, an earlier image could * have applied write protection. Nothing additional needs to be done. */ - if (reset_flags & RESET_FLAG_SYSJUMP) + if (reset_flags & EC_RESET_FLAG_SYSJUMP) return EC_SUCCESS; if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) { diff --git a/chip/stm32/system.c b/chip/stm32/system.c index d5884375c9..7cc0881dc2 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -188,25 +188,25 @@ static void check_reset_cause(void) * IWDG or WWDG, if the watchdog was not used as an hard reset * mechanism */ - if (!(flags & RESET_FLAG_HARD)) - flags |= RESET_FLAG_WATCHDOG; + if (!(flags & EC_RESET_FLAG_HARD)) + flags |= EC_RESET_FLAG_WATCHDOG; } if (raw_cause & RESET_CAUSE_SFT) - flags |= RESET_FLAG_SOFT; + flags |= EC_RESET_FLAG_SOFT; if (raw_cause & RESET_CAUSE_POR) - flags |= RESET_FLAG_POWER_ON; + flags |= EC_RESET_FLAG_POWER_ON; if (raw_cause & RESET_CAUSE_PIN) - flags |= RESET_FLAG_RESET_PIN; + flags |= EC_RESET_FLAG_RESET_PIN; if (pwr_status & RESET_CAUSE_SBF) /* Hibernated and subsequently awakened */ - flags |= RESET_FLAG_HIBERNATE; + flags |= EC_RESET_FLAG_HIBERNATE; if (!flags && (raw_cause & RESET_CAUSE_OTHER)) - flags |= RESET_FLAG_OTHER; + flags |= EC_RESET_FLAG_OTHER; /* * WORKAROUND: as we cannot de-activate the watchdog during @@ -215,8 +215,8 @@ static void check_reset_cause(void) * watchdog initialized this time. * The RTC deadline (if any) is already set. */ - if ((flags & (RESET_FLAG_HIBERNATE | RESET_FLAG_WATCHDOG)) == - (RESET_FLAG_HIBERNATE | RESET_FLAG_WATCHDOG)) { + if ((flags & EC_RESET_FLAG_HIBERNATE) && + (flags & EC_RESET_FLAG_WATCHDOG)) { __enter_hibernate(0, 0); } @@ -358,18 +358,18 @@ void system_reset(int flags) /* Save current reset reasons if necessary */ if (flags & SYSTEM_RESET_PRESERVE_FLAGS) - save_flags = system_get_reset_flags() | RESET_FLAG_PRESERVED; + save_flags = system_get_reset_flags() | EC_RESET_FLAG_PRESERVED; if (flags & SYSTEM_RESET_LEAVE_AP_OFF) - save_flags |= RESET_FLAG_AP_OFF; + save_flags |= EC_RESET_FLAG_AP_OFF; /* Remember that the software asked us to hard reboot */ if (flags & SYSTEM_RESET_HARD) - save_flags |= RESET_FLAG_HARD; + save_flags |= EC_RESET_FLAG_HARD; #ifdef CONFIG_STM32_RESET_FLAGS_EXTENDED if (flags & SYSTEM_RESET_AP_WATCHDOG) - save_flags |= RESET_FLAG_AP_WATCHDOG; + save_flags |= EC_RESET_FLAG_AP_WATCHDOG; bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, save_flags & 0xffff); bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS_2, save_flags >> 16); -- cgit v1.2.1