diff options
-rw-r--r-- | chip/it83xx/gpio.c | 2 | ||||
-rw-r--r-- | chip/it83xx/system.c | 2 | ||||
-rw-r--r-- | chip/mec1322/gpio.c | 2 | ||||
-rw-r--r-- | chip/mec1322/system.c | 3 | ||||
-rw-r--r-- | chip/npcx/gpio.c | 22 | ||||
-rw-r--r-- | chip/npcx/system.c | 21 | ||||
-rw-r--r-- | chip/stm32/gpio-stm32f0.c | 5 | ||||
-rw-r--r-- | chip/stm32/gpio-stm32f3.c | 5 | ||||
-rw-r--r-- | chip/stm32/gpio-stm32l.c | 5 | ||||
-rw-r--r-- | chip/stm32/gpio.c | 3 | ||||
-rw-r--r-- | chip/stm32/system.c | 9 | ||||
-rw-r--r-- | include/gpio.h | 8 | ||||
-rw-r--r-- | include/system.h | 8 |
13 files changed, 45 insertions, 50 deletions
diff --git a/chip/it83xx/gpio.c b/chip/it83xx/gpio.c index 8ae7c5bbd3..b3d4d11945 100644 --- a/chip/it83xx/gpio.c +++ b/chip/it83xx/gpio.c @@ -381,7 +381,7 @@ int gpio_disable_interrupt(enum gpio_signal signal) void gpio_pre_init(void) { const struct gpio_info *g = gpio_list; - int is_warm = gpio_is_reboot_warm(); + int is_warm = system_is_reboot_warm(); int flags; int i; diff --git a/chip/it83xx/system.c b/chip/it83xx/system.c index fe4c5d83c0..052aa3a1ff 100644 --- a/chip/it83xx/system.c +++ b/chip/it83xx/system.c @@ -64,7 +64,7 @@ static void check_reset_cause(void) system_set_reset_flags(flags); } -int gpio_is_reboot_warm(void) +int system_is_reboot_warm(void) { uint32_t reset_flags; /* diff --git a/chip/mec1322/gpio.c b/chip/mec1322/gpio.c index a8d8ae3b45..2159f2f407 100644 --- a/chip/mec1322/gpio.c +++ b/chip/mec1322/gpio.c @@ -180,7 +180,7 @@ void gpio_pre_init(void) { int i; int flags; - int is_warm = gpio_is_reboot_warm(); + int is_warm = system_is_reboot_warm(); const struct gpio_info *g = gpio_list; diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index fd8c79a2f1..fe68777241 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -56,8 +56,7 @@ static void check_reset_cause(void) system_set_reset_flags(flags); } -/* TODO(crbug.com/40789): Rename this function system_is_reboot_warm */ -int gpio_is_reboot_warm(void) +int system_is_reboot_warm(void) { uint32_t reset_flags; /* diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c index 1173338716..7931d966d8 100644 --- a/chip/npcx/gpio.c +++ b/chip/npcx/gpio.c @@ -521,31 +521,11 @@ int gpio_disable_interrupt(enum gpio_signal signal) return EC_SUCCESS; } -int gpio_is_reboot_warm(void) -{ - uint32_t reset_flags; - /* - * Check reset cause here, - * gpio_pre_init is executed faster than system_pre_init - */ - system_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)) - return 0; - else - return 1; -} - void gpio_pre_init(void) { const struct gpio_info *g = gpio_list; const struct gpio_wui_map *map; - int is_warm = gpio_is_reboot_warm(); + int is_warm = system_is_reboot_warm(); int flags; int i, j; diff --git a/chip/npcx/system.c b/chip/npcx/system.c index b1ef8a62b0..a5b51c6609 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -601,6 +601,27 @@ uint32_t system_get_scratchpad(void) return bbram_data_read(BBRM_DATA_INDEX_SCRATCHPAD); } +int system_is_reboot_warm(void) +{ + uint32_t reset_flags; + + /* + * Check reset cause here, + * gpio_pre_init is executed faster than system_pre_init + */ + system_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)) + return 0; + else + return 1; +} + /*****************************************************************************/ /* Console commands */ diff --git a/chip/stm32/gpio-stm32f0.c b/chip/stm32/gpio-stm32f0.c index fcead72d4f..a26666ac72 100644 --- a/chip/stm32/gpio-stm32f0.c +++ b/chip/stm32/gpio-stm32f0.c @@ -13,11 +13,6 @@ #include "task.h" #include "util.h" -int gpio_is_reboot_warm(void) -{ - return ((STM32_RCC_AHBENR & 0x7e0000) == 0x7e0000); -} - void gpio_enable_clocks(void) { /* diff --git a/chip/stm32/gpio-stm32f3.c b/chip/stm32/gpio-stm32f3.c index 9efddab7fc..a0c6fc39ac 100644 --- a/chip/stm32/gpio-stm32f3.c +++ b/chip/stm32/gpio-stm32f3.c @@ -13,11 +13,6 @@ #include "task.h" #include "util.h" -int gpio_is_reboot_warm(void) -{ - return ((STM32_RCC_AHBENR & 0x7e0000) == 0x7e0000); -} - void gpio_enable_clocks(void) { /* diff --git a/chip/stm32/gpio-stm32l.c b/chip/stm32/gpio-stm32l.c index c015112503..da5595083e 100644 --- a/chip/stm32/gpio-stm32l.c +++ b/chip/stm32/gpio-stm32l.c @@ -13,11 +13,6 @@ #include "task.h" #include "util.h" -int gpio_is_reboot_warm(void) -{ - return ((STM32_RCC_AHBENR & 0x3f) == 0x3f); -} - void gpio_enable_clocks(void) { /* diff --git a/chip/stm32/gpio.c b/chip/stm32/gpio.c index c9591c9ed5..69f4f4d60c 100644 --- a/chip/stm32/gpio.c +++ b/chip/stm32/gpio.c @@ -11,6 +11,7 @@ #include "gpio.h" #include "hooks.h" #include "registers.h" +#include "system.h" #include "task.h" #include "util.h" @@ -22,7 +23,7 @@ static uint8_t exti_events[16]; void gpio_pre_init(void) { const struct gpio_info *g = gpio_list; - int is_warm = gpio_is_reboot_warm(); + int is_warm = system_is_reboot_warm(); int i; /* Required to configure external IRQ lines (SYSCFG_EXTICRn) */ diff --git a/chip/stm32/system.c b/chip/stm32/system.c index 88cde274fd..5e486ea20b 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -377,3 +377,12 @@ int system_get_console_force_enabled(void) else return 0; } + +int system_is_reboot_warm(void) +{ +#if defined(CHIP_FAMILY_STM32F0) || defined(CHIP_FAMILY_STM32F3) + return ((STM32_RCC_AHBENR & 0x7e0000) == 0x7e0000); +#elif defined(CHIP_FAMILY_STM32L) + return ((STM32_RCC_AHBENR & 0x3f) == 0x3f); +#endif +} diff --git a/include/gpio.h b/include/gpio.h index 6b76f29d04..117cd2a5ba 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -245,14 +245,6 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags); void gpio_set_alternate_function(uint32_t port, uint32_t mask, int func); /** - * Return true if the EC is warm booting. - * - * This function is used by the GPIO implementation and should not be called - * outside of that context. - */ -int gpio_is_reboot_warm(void); - -/** * Enable GPIO peripheral clocks. * * This function is used by the GPIO implementation and should not be called diff --git a/include/system.h b/include/system.h index 6767c30a10..e6e585ba21 100644 --- a/include/system.h +++ b/include/system.h @@ -411,4 +411,12 @@ enum system_image_copy_t system_get_shrspi_image_copy(void); */ uintptr_t system_get_fw_reset_vector(uintptr_t base); #endif + +/** + * Check if the EC is warm booting. + * + * @return true if the EC is warm booting. + */ +int system_is_reboot_warm(void); + #endif /* __CROS_EC_SYSTEM_H */ |