Browse Source

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>
pull/78767/head
Anas Nashif 10 months ago committed by Henrik Brix Andersen
parent
commit
72ee7aa279
  1. 1
      soc/ambiq/apollo3x/Kconfig
  2. 6
      soc/ambiq/apollo3x/power.c
  3. 10
      soc/ambiq/apollo3x/soc.c
  4. 1
      soc/ambiq/apollo4x/Kconfig
  5. 6
      soc/ambiq/apollo4x/power.c
  6. 10
      soc/ambiq/apollo4x/soc.c

1
soc/ambiq/apollo3x/Kconfig

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

6
soc/ambiq/apollo3x/power.c

@ -65,7 +65,7 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) @@ -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) @@ -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);

10
soc/ambiq/apollo3x/soc.c

@ -8,7 +8,9 @@ @@ -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) @@ -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);

1
soc/ambiq/apollo4x/Kconfig

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

6
soc/ambiq/apollo4x/power.c

@ -65,7 +65,7 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) @@ -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) @@ -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);

10
soc/ambiq/apollo4x/soc.c

@ -8,7 +8,8 @@ @@ -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) @@ -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);

Loading…
Cancel
Save