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 
soc_npcx4_init(void)21 static int soc_npcx4_init(void)
22 {
23 	/*
24 	 * Make sure UMA_ADDR_SIZE field of UMA_ECTS register is zero in npcx4
25 	 * series. There should be no address field in UMA mode by default.
26 	 */
27 	for (int i = 0; i < ARRAY_SIZE(fiu_insts); i++) {
28 		struct fiu_reg *const inst = (struct fiu_reg *)(fiu_insts[i]);
29 
30 		SET_FIELD(inst->UMA_ECTS, NPCX_UMA_ECTS_UMA_ADDR_SIZE, 0);
31 	}
32 
33 	return 0;
34 }
35 
36 SYS_INIT(soc_npcx4_init, PRE_KERNEL_1, 0);
37