1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright 2022-2023 NXP
4  */
5 
6 #include <console.h>
7 #include <drivers/ns16550.h>
8 #include <kernel/boot.h>
9 #include <kernel/tee_common_otp.h>
10 #include <platform_config.h>
11 #include <plic.h>
12 
13 static struct plic_data plic_data __nex_bss;
14 static struct ns16550_data console_data __nex_bss;
15 
16 register_ddr(DRAM_BASE, DRAM_SIZE);
17 
18 register_phys_mem_pgdir(MEM_AREA_IO_NSEC, UART0_BASE,
19 			CORE_MMU_PGDIR_SIZE);
20 
21 #ifdef	CFG_RISCV_PLIC
main_init_plic(void)22 void main_init_plic(void)
23 {
24 	plic_init(&plic_data, PLIC_BASE);
25 	itr_init(&plic_data.chip);
26 }
27 
main_secondary_init_plic(void)28 void main_secondary_init_plic(void)
29 {
30 	plic_hart_init(&plic_data);
31 }
32 #endif /* CFG_RISCV_PLIC */
33 
console_init(void)34 void console_init(void)
35 {
36 	ns16550_init(&console_data, UART0_BASE, IO_WIDTH_U8, 0);
37 	register_serial_console(&console_data.chip);
38 }
39 
itr_core_handler(void)40 void itr_core_handler(void)
41 {
42 	if (IS_ENABLED(CFG_RISCV_PLIC))
43 		plic_it_handle(&plic_data);
44 }
45