From 76ad5b3801574c9cc6b8624a3f936b04fcf09cfe Mon Sep 17 00:00:00 2001 From: Swift Tian Date: Sat, 31 May 2025 21:01:35 +0800 Subject: [PATCH] soc: ambiq: adjust init process split soc init into two parts as it is too large to be up front at early stages. Signed-off-by: Swift Tian --- soc/ambiq/apollo5x/Kconfig | 2 +- soc/ambiq/apollo5x/soc.c | 45 ++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/soc/ambiq/apollo5x/Kconfig b/soc/ambiq/apollo5x/Kconfig index 8d43ba4981b68..0d3a6b3c9c042 100644 --- a/soc/ambiq/apollo5x/Kconfig +++ b/soc/ambiq/apollo5x/Kconfig @@ -18,7 +18,7 @@ config SOC_SERIES_APOLLO5X select AMBIQ_HAL select HAS_PM select SOC_EARLY_INIT_HOOK - select REQUIRES_FULL_LIBC + select FPU config SOC_AMBIQ_DCACHE_SIZE int diff --git a/soc/ambiq/apollo5x/soc.c b/soc/ambiq/apollo5x/soc.c index 8f168b19141b2..d69886594fb2a 100644 --- a/soc/ambiq/apollo5x/soc.c +++ b/soc/ambiq/apollo5x/soc.c @@ -38,25 +38,6 @@ void soc_early_init_hook(void) /* Internal timer15 for SPOT manager */ IRQ_CONNECT(82, 0, hal_internal_timer_isr, 0, 0); - - /* Initialize for low power in the power control block */ - am_hal_pwrctrl_low_power_init(); - - /* Enable SIMOBUCK for the apollo5 Family */ - am_hal_pwrctrl_control(AM_HAL_PWRCTRL_CONTROL_SIMOBUCK_INIT, NULL); - - /* - * Set default temperature for spotmgr to room temperature - */ - am_hal_pwrctrl_temp_thresh_t dummy; - - am_hal_pwrctrl_temp_update(25.0f, &dummy); - - /* Enable Icache*/ - sys_cache_instr_enable(); - - /* Enable Dcache */ - sys_cache_data_enable(); } #if CONFIG_CACHE_MANAGEMENT @@ -84,3 +65,29 @@ bool buf_in_nocache(uintptr_t buf, size_t len_bytes) return buf_within_nocache; } #endif + +int apollo5x_init(void) +{ + /* Initialize for low power in the power control block */ + am_hal_pwrctrl_low_power_init(); + + /* Enable SIMOBUCK for the apollo5 Family */ + am_hal_pwrctrl_control(AM_HAL_PWRCTRL_CONTROL_SIMOBUCK_INIT, NULL); + + /* + * Set default temperature for spotmgr to room temperature + */ + am_hal_pwrctrl_temp_thresh_t dummy; + + am_hal_pwrctrl_temp_update(25.0f, &dummy); + + /* Enable Icache*/ + sys_cache_instr_enable(); + + /* Enable Dcache */ + sys_cache_data_enable(); + + return 0; +} + +SYS_INIT(apollo5x_init, PRE_KERNEL_1, 0);