soc: ambiq: move init code from SYS_INIT to hooks

Replace SYS_INIT with SoC hooks and adapt SoC init code

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2024-09-10 09:42:27 -04:00 committed by Henrik Brix Andersen
parent b60efecdf6
commit 72ee7aa279
6 changed files with 15 additions and 19 deletions

View File

@ -11,3 +11,4 @@ config SOC_SERIES_APOLLO3X
select HAS_SWO
select AMBIQ_HAL
select HAS_PM
select SOC_EARLY_INIT_HOOK

View File

@ -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);

View File

@ -8,7 +8,9 @@
#include <am_mcu_apollo.h>
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);

View File

@ -12,3 +12,4 @@ config SOC_SERIES_APOLLO4X
select HAS_SWO
select AMBIQ_HAL
select HAS_PM
select SOC_EARLY_INIT_HOOK

View File

@ -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);

View File

@ -8,7 +8,8 @@
#include <am_mcu_apollo.h>
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);