1 /*
2  * Copyright (c) 2023 Nuvoton Technology Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/device.h>
9 #include <zephyr/init.h>
10 #include <soc.h>
11 #include <zephyr/logging/log.h>
12 
13 LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
14 
15 #define NPCX_FIU_INST_INIT(node_id) DT_REG_ADDR(node_id),
16 
17 static uintptr_t fiu_insts[] = {
18 	DT_FOREACH_STATUS_OKAY(nuvoton_npcx_fiu_qspi, NPCX_FIU_INST_INIT)
19 };
20 
21 extern void scfg_init(void);
soc_early_init_hook(void)22 void soc_early_init_hook(void)
23 {
24 	/*
25 	 * Make sure UMA_ADDR_SIZE field of UMA_ECTS register is zero in npcx4
26 	 * series. There should be no address field in UMA mode by default.
27 	 */
28 	for (int i = 0; i < ARRAY_SIZE(fiu_insts); i++) {
29 		struct fiu_reg *const inst = (struct fiu_reg *)(fiu_insts[i]);
30 
31 		SET_FIELD(inst->UMA_ECTS, NPCX_UMA_ECTS_UMA_ADDR_SIZE, 0);
32 	}
33 	scfg_init();
34 }
35