soc: renesas: 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:42 -04:00 committed by Henrik Brix Andersen
parent f585e852ed
commit 258c4db1e2
35 changed files with 41 additions and 132 deletions

View File

@ -10,3 +10,4 @@ config SOC_SERIES_RA2A1
select HAS_SWO
select XIP
select HAS_RENESAS_RA_FSP
select SOC_EARLY_INIT_HOOK

View File

@ -29,17 +29,10 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra2a1_init(void)
void soc_early_init_hook(void)
{
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
bsp_clock_init();
return 0;
}
SYS_INIT(renesas_ra2a1_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA4E2
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -30,11 +30,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra4e2_init(void)
void soc_early_init_hook(void)
{
extern volatile uint16_t g_protect_counters[];
@ -62,8 +59,4 @@ static int renesas_ra4e2_init(void)
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
return 0;
}
SYS_INIT(renesas_ra4e2_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA4M2
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -30,11 +30,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra4m2_init(void)
void soc_early_init_hook(void)
{
extern volatile uint16_t g_protect_counters[];
@ -62,8 +59,4 @@ static int renesas_ra4m2_init(void)
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
return 0;
}
SYS_INIT(renesas_ra4m2_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA4M3
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -30,11 +30,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra4m3_init(void)
void soc_early_init_hook(void)
{
extern volatile uint16_t g_protect_counters[];
@ -62,8 +59,4 @@ static int renesas_ra4m3_init(void)
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
return 0;
}
SYS_INIT(renesas_ra4m3_init, PRE_KERNEL_1, 0);

View File

@ -12,3 +12,4 @@ config SOC_SERIES_RA4W1
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -30,16 +30,9 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra4w1_init(void)
void soc_early_init_hook(void)
{
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
return 0;
}
SYS_INIT(renesas_ra4w1_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA6E1
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -29,11 +29,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra6e1_init(void)
void soc_early_init_hook(void)
{
uint32_t key;
@ -67,8 +64,4 @@ static int renesas_ra6e1_init(void)
g_protect_pfswe_counter = 0;
irq_unlock(key);
return 0;
}
SYS_INIT(renesas_ra6e1_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA6E2
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -29,11 +29,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra6e2_init(void)
void soc_early_init_hook(void)
{
uint32_t key;
@ -67,8 +64,4 @@ static int renesas_ra6e2_init(void)
g_protect_pfswe_counter = 0;
irq_unlock(key);
return 0;
}
SYS_INIT(renesas_ra6e2_init, PRE_KERNEL_1, 0);

View File

@ -12,3 +12,4 @@ config SOC_SERIES_RA6M1
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -29,11 +29,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra6m1_init(void)
void soc_early_init_hook(void)
{
uint32_t key;
@ -43,8 +40,4 @@ static int renesas_ra6m1_init(void)
g_protect_pfswe_counter = 0;
irq_unlock(key);
return 0;
}
SYS_INIT(renesas_ra6m1_init, PRE_KERNEL_1, 0);

View File

@ -12,3 +12,4 @@ config SOC_SERIES_RA6M2
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -29,11 +29,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra6m2_init(void)
void soc_early_init_hook(void)
{
uint32_t key;
@ -43,8 +40,4 @@ static int renesas_ra6m2_init(void)
g_protect_pfswe_counter = 0;
irq_unlock(key);
return 0;
}
SYS_INIT(renesas_ra6m2_init, PRE_KERNEL_1, 0);

View File

@ -12,3 +12,4 @@ config SOC_SERIES_RA6M3
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -29,11 +29,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra6m3_init(void)
void soc_early_init_hook(void)
{
uint32_t key;
@ -43,8 +40,4 @@ static int renesas_ra6m3_init(void)
g_protect_pfswe_counter = 0;
irq_unlock(key);
return 0;
}
SYS_INIT(renesas_ra6m3_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA6M4
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -29,11 +29,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra6m4_init(void)
void soc_early_init_hook(void)
{
uint32_t key;
@ -67,8 +64,4 @@ static int renesas_ra6m4_init(void)
g_protect_pfswe_counter = 0;
irq_unlock(key);
return 0;
}
SYS_INIT(renesas_ra6m4_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA6M5
select FPU
select HAS_SWO
select XIP
select SOC_EARLY_INIT_HOOK

View File

@ -29,11 +29,8 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra6m5_init(void)
void soc_early_init_hook(void)
{
uint32_t key;
@ -67,8 +64,4 @@ static int renesas_ra6m5_init(void)
g_protect_pfswe_counter = 0;
irq_unlock(key);
return 0;
}
SYS_INIT(renesas_ra6m5_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA8D1
select XIP
select CLOCK_CONTROL_RENESAS_RA_CGC if CLOCK_CONTROL
select HAS_RENESAS_RA_FSP
select SOC_EARLY_INIT_HOOK

View File

@ -29,16 +29,9 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra8d1_init(void)
void soc_early_init_hook(void)
{
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
return 0;
}
SYS_INIT(renesas_ra8d1_init, PRE_KERNEL_1, 0);

View File

@ -13,5 +13,6 @@ config SOC_SERIES_RA8M1
select XIP
select CLOCK_CONTROL_RENESAS_RA_CGC if CLOCK_CONTROL
select HAS_RENESAS_RA_FSP
select SOC_EARLY_INIT_HOOK
help
Enable support for Renesas RA8M1 MCU series

View File

@ -29,16 +29,9 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra8m1_init(void)
void soc_early_init_hook(void)
{
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
return 0;
}
SYS_INIT(renesas_ra8m1_init, PRE_KERNEL_1, 0);

View File

@ -13,3 +13,4 @@ config SOC_SERIES_RA8T1
select XIP
select CLOCK_CONTROL_RENESAS_RA_CGC if CLOCK_CONTROL
select HAS_RENESAS_RA_FSP
select SOC_EARLY_INIT_HOOK

View File

@ -29,16 +29,9 @@ volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int renesas_ra8t1_init(void)
void soc_early_init_hook(void)
{
SystemCoreClock = BSP_MOCO_HZ;
g_protect_pfswe_counter = 0;
return 0;
}
SYS_INIT(renesas_ra8t1_init, PRE_KERNEL_1, 0);

View File

@ -8,3 +8,4 @@ config SOC_RENESAS_RZT2M
select GIC_SINGLE_SECURITY_STATE
select ARM_ARCH_TIMER
select SYSCON
select SOC_EARLY_INIT_HOOK

View File

@ -90,7 +90,7 @@ void rzt2m_enable_counters(void)
syscon_write_reg(dev, 0, CNTCR_EN);
}
static int rzt2m_init(void)
void soc_early_init_hook(void)
{
/* Unlock the Protect Registers
* so that device drivers can access configuration registers of peripherals.
@ -115,7 +115,4 @@ static int rzt2m_init(void)
rzt2m_lock_prcrn(PRCRN_PRC1 | PRCRN_PRC2 | PRCRN_PRC0);
rzt2m_enable_counters();
return 0;
}
SYS_INIT(rzt2m_init, PRE_KERNEL_1, 0);

View File

@ -14,4 +14,5 @@ config SOC_SERIES_DA1469X
select CLOCK_CONTROL_SMARTBOND
select SOC_RESET_HOOK
select PM_DEVICE if PM
select SOC_EARLY_INIT_HOOK
imply TIMER_READS_ITS_FREQUENCY_AT_RUNTIME

View File

@ -45,7 +45,7 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
}
}
static int renesas_da1469x_pm_init(void)
int renesas_da1469x_pm_init(void)
{
static const struct da1469x_sleep_config sleep_cfg = {
.enable_xtal_on_wakeup = DT_NODE_HAS_STATUS(DT_NODELABEL(xtal32m), okay),
@ -55,5 +55,3 @@ static int renesas_da1469x_pm_init(void)
return 0;
}
SYS_INIT(renesas_da1469x_pm_init, PRE_KERNEL_2, 2);

View File

@ -131,7 +131,10 @@ void soc_reset_hook(void)
#endif
}
static int renesas_da1469x_init(void)
/* defined in power.c */
extern int renesas_da1469x_pm_init(void);
void soc_early_init_hook(void)
{
/* Freeze watchdog until configured */
GPREG->SET_FREEZE_REG = GPREG_SET_FREEZE_REG_FRZ_SYS_WDOG_Msk;
@ -176,8 +179,7 @@ static int renesas_da1469x_init(void)
da1469x_pd_acquire(MCU_PD_DOMAIN_TIM);
da1469x_pdc_reset();
return 0;
#if CONFIG_PM
renesas_da1469x_pm_init();
#endif
}
SYS_INIT(renesas_da1469x_init, PRE_KERNEL_1, 0);