diff --git a/soc/ambiq/apollo3x/Kconfig b/soc/ambiq/apollo3x/Kconfig index ad9fb253fcb..02bf72024a9 100644 --- a/soc/ambiq/apollo3x/Kconfig +++ b/soc/ambiq/apollo3x/Kconfig @@ -11,3 +11,4 @@ config SOC_SERIES_APOLLO3X select HAS_SWO select AMBIQ_HAL select HAS_PM + select SOC_EARLY_INIT_HOOK diff --git a/soc/ambiq/apollo3x/power.c b/soc/ambiq/apollo3x/power.c index 630a34638ab..d41dd20c996 100644 --- a/soc/ambiq/apollo3x/power.c +++ b/soc/ambiq/apollo3x/power.c @@ -65,7 +65,7 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) irq_unlock(0); } -static int ambiq_power_init(void) +void ambiq_power_init(void) { /* Enable flash. * Currently all flash area is powered on, but we should only enable the used flash area and @@ -100,8 +100,4 @@ static int ambiq_power_init(void) */ am_hal_sysctrl_control(AM_HAL_SYSCTRL_CONTROL_DEEPSLEEP_MINPWR_EN, 0); #endif - - return 0; } - -SYS_INIT(ambiq_power_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/soc/ambiq/apollo3x/soc.c b/soc/ambiq/apollo3x/soc.c index c76dda6d850..bae475e814f 100644 --- a/soc/ambiq/apollo3x/soc.c +++ b/soc/ambiq/apollo3x/soc.c @@ -8,7 +8,9 @@ #include -static int arm_apollo3_init(void) +extern void ambiq_power_init(void); + +void soc_early_init_hook(void) { /* Set the clock frequency. */ am_hal_clkgen_control(AM_HAL_CLKGEN_CONTROL_SYSCLK_MAX, 0); @@ -23,7 +25,7 @@ static int arm_apollo3_init(void) /* Disable the RTC. */ am_hal_rtc_osc_disable(); - return 0; +#ifdef CONFIG_PM + ambiq_power_init(); +#endif } - -SYS_INIT(arm_apollo3_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/soc/ambiq/apollo4x/Kconfig b/soc/ambiq/apollo4x/Kconfig index 9a48dc9eb21..b22a1c37cda 100644 --- a/soc/ambiq/apollo4x/Kconfig +++ b/soc/ambiq/apollo4x/Kconfig @@ -12,3 +12,4 @@ config SOC_SERIES_APOLLO4X select HAS_SWO select AMBIQ_HAL select HAS_PM + select SOC_EARLY_INIT_HOOK diff --git a/soc/ambiq/apollo4x/power.c b/soc/ambiq/apollo4x/power.c index 30950436517..b799f29c224 100644 --- a/soc/ambiq/apollo4x/power.c +++ b/soc/ambiq/apollo4x/power.c @@ -65,7 +65,7 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) irq_unlock(0); } -static int ambiq_power_init(void) +void ambiq_power_init(void) { am_hal_pwrctrl_mcu_memory_config_t sMcuMemCfg = { .eCacheCfg = AM_HAL_PWRCTRL_CACHE_NONE, @@ -98,8 +98,4 @@ static int ambiq_power_init(void) am_hal_pwrctrl_dsp_memory_config(AM_HAL_DSP0, &sDSPMemCfg); am_hal_pwrctrl_periph_disable(AM_HAL_PWRCTRL_PERIPH_CRYPTO); - - return 0; } - -SYS_INIT(ambiq_power_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/soc/ambiq/apollo4x/soc.c b/soc/ambiq/apollo4x/soc.c index 225f5013441..b434e20f0ee 100644 --- a/soc/ambiq/apollo4x/soc.c +++ b/soc/ambiq/apollo4x/soc.c @@ -8,7 +8,8 @@ #include -static int arm_apollo4_init(void) +extern void ambiq_power_init(void); +void soc_early_init_hook(void) { /* Initialize for low power in the power control block */ @@ -19,8 +20,7 @@ static int arm_apollo4_init(void) /* Disable the RTC. */ am_hal_rtc_osc_disable(); - - return 0; +#ifdef CONFIG_PM + ambiq_power_init(); +#endif } - -SYS_INIT(arm_apollo4_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);