From 21217309bf5fe7d83da437195c0e125177cf1c73 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 10 Sep 2024 09:42:40 -0400 Subject: [PATCH] soc: nuvoton: move init code from SYS_INIT to hooks Replace SYS_INIT with SoC hooks and adapt SoC init code Signed-off-by: Anas Nashif --- soc/nuvoton/npcm/npcm4/CMakeLists.txt | 4 ---- soc/nuvoton/npcm/npcm4/soc.c | 20 -------------------- soc/nuvoton/npcx/common/scfg.c | 6 +----- soc/nuvoton/npcx/npcx4/Kconfig | 1 + soc/nuvoton/npcx/npcx4/soc.c | 8 +++----- soc/nuvoton/npcx/npcx7/Kconfig | 1 + soc/nuvoton/npcx/npcx7/soc.c | 8 +++----- soc/nuvoton/npcx/npcx9/Kconfig | 1 + soc/nuvoton/npcx/npcx9/soc.c | 8 +++----- 9 files changed, 13 insertions(+), 44 deletions(-) delete mode 100644 soc/nuvoton/npcm/npcm4/soc.c diff --git a/soc/nuvoton/npcm/npcm4/CMakeLists.txt b/soc/nuvoton/npcm/npcm4/CMakeLists.txt index 9a246a41b34..37767af77fb 100644 --- a/soc/nuvoton/npcm/npcm4/CMakeLists.txt +++ b/soc/nuvoton/npcm/npcm4/CMakeLists.txt @@ -8,8 +8,4 @@ zephyr_include_directories( ${ZEPHYR_BASE}/drivers ) -zephyr_sources( - soc.c -) - set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/nuvoton/npcm/npcm4/soc.c b/soc/nuvoton/npcm/npcm4/soc.c deleted file mode 100644 index 42536543233..00000000000 --- a/soc/nuvoton/npcm/npcm4/soc.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2024 Nuvoton Technology Corporation. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include - -LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); - -static int soc_npcm4_init(void) -{ - return 0; -} - -SYS_INIT(soc_npcm4_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/soc/nuvoton/npcx/common/scfg.c b/soc/nuvoton/npcx/common/scfg.c index 6dac027cb2e..cb552e7ead1 100644 --- a/soc/nuvoton/npcx/common/scfg.c +++ b/soc/nuvoton/npcx/common/scfg.c @@ -143,7 +143,7 @@ void npcx_dbg_freeze_enable(bool enable) } /* Pin-control driver registration */ -static int npcx_scfg_init(void) +void scfg_init(void) { /* If booter doesn't set the host interface type */ if (!NPCX_BOOTER_IS_HIF_TYPE_SET()) { @@ -154,8 +154,4 @@ static int npcx_scfg_init(void) for (int i = 0; i < ARRAY_SIZE(def_alts); i++) { npcx_pinctrl_alt_sel(&def_alts[i], 0); } - - return 0; } - -SYS_INIT(npcx_scfg_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/soc/nuvoton/npcx/npcx4/Kconfig b/soc/nuvoton/npcx/npcx4/Kconfig index 0983b7c7eff..795ee55c865 100644 --- a/soc/nuvoton/npcx/npcx4/Kconfig +++ b/soc/nuvoton/npcx/npcx4/Kconfig @@ -10,3 +10,4 @@ config SOC_SERIES_NPCX4 select CPU_HAS_FPU select CPU_HAS_ARM_MPU select HAS_PM + select SOC_EARLY_INIT_HOOK diff --git a/soc/nuvoton/npcx/npcx4/soc.c b/soc/nuvoton/npcx/npcx4/soc.c index 28b868bda65..b6137292961 100644 --- a/soc/nuvoton/npcx/npcx4/soc.c +++ b/soc/nuvoton/npcx/npcx4/soc.c @@ -18,7 +18,8 @@ static uintptr_t fiu_insts[] = { DT_FOREACH_STATUS_OKAY(nuvoton_npcx_fiu_qspi, NPCX_FIU_INST_INIT) }; -static int soc_npcx4_init(void) +extern void scfg_init(void); +void soc_early_init_hook(void) { /* * Make sure UMA_ADDR_SIZE field of UMA_ECTS register is zero in npcx4 @@ -29,8 +30,5 @@ static int soc_npcx4_init(void) SET_FIELD(inst->UMA_ECTS, NPCX_UMA_ECTS_UMA_ADDR_SIZE, 0); } - - return 0; + scfg_init(); } - -SYS_INIT(soc_npcx4_init, PRE_KERNEL_1, 0); diff --git a/soc/nuvoton/npcx/npcx7/Kconfig b/soc/nuvoton/npcx/npcx7/Kconfig index 55e5a1c50c0..7387e0b491f 100644 --- a/soc/nuvoton/npcx/npcx7/Kconfig +++ b/soc/nuvoton/npcx/npcx7/Kconfig @@ -11,3 +11,4 @@ config SOC_SERIES_NPCX7 select CPU_HAS_ARM_MPU select CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS select HAS_PM + select SOC_EARLY_INIT_HOOK diff --git a/soc/nuvoton/npcx/npcx7/soc.c b/soc/nuvoton/npcx/npcx7/soc.c index ae892a7d166..0a550c7f323 100644 --- a/soc/nuvoton/npcx/npcx7/soc.c +++ b/soc/nuvoton/npcx/npcx7/soc.c @@ -12,7 +12,8 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); -static int soc_npcx7_init(void) +extern void scfg_init(void); +void soc_early_init_hook(void) { struct scfg_reg *inst_scfg = (struct scfg_reg *) DT_REG_ADDR_BY_NAME(DT_NODELABEL(scfg), scfg); @@ -22,8 +23,5 @@ static int soc_npcx7_init(void) * for more information. It will be fixed in next chip. */ inst_scfg->DEVCNT |= BIT(7); - - return 0; + scfg_init(); } - -SYS_INIT(soc_npcx7_init, PRE_KERNEL_1, 0); diff --git a/soc/nuvoton/npcx/npcx9/Kconfig b/soc/nuvoton/npcx/npcx9/Kconfig index dd93a355e93..44b64446f0e 100644 --- a/soc/nuvoton/npcx/npcx9/Kconfig +++ b/soc/nuvoton/npcx/npcx9/Kconfig @@ -11,6 +11,7 @@ config SOC_SERIES_NPCX9 select CPU_HAS_ARM_MPU select SOC_FAMILY_NPCX select HAS_PM + select SOC_EARLY_INIT_HOOK config NPCX_VCC1_RST_HANG_WORKAROUND bool diff --git a/soc/nuvoton/npcx/npcx9/soc.c b/soc/nuvoton/npcx/npcx9/soc.c index a1427a84088..99144ce904c 100644 --- a/soc/nuvoton/npcx/npcx9/soc.c +++ b/soc/nuvoton/npcx/npcx9/soc.c @@ -12,7 +12,8 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); -static int soc_npcx9_init(void) +extern void scfg_init(void); +void soc_early_init_hook(void) { if (IS_ENABLED(CONFIG_NPCX_VCC1_RST_HANG_WORKAROUND)) { uintptr_t scfg_base = DT_REG_ADDR_BY_NAME(DT_NODELABEL(scfg), scfg); @@ -20,8 +21,5 @@ static int soc_npcx9_init(void) SET_FIELD(NPCX_JEN_CTL1(scfg_base), NPCX_JEN_CTL1_JEN_HEN, NPCX_JEN_CTL1_JEN_DISABLE); } - - return 0; + scfg_init(); } - -SYS_INIT(soc_npcx9_init, PRE_KERNEL_1, 0);