xref: /optee_os/core/arch/arm/plat-rockchip/main.c (revision 1e3d23f815a50fa8fb6582958fa0ece5639bac3c)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (C) 2017, Fuzhou Rockchip Electronics Co., Ltd.
4  * Copyright (C) 2019, Theobroma Systems Design und Consulting GmbH
5  */
6 
7 #include <console.h>
8 #include <drivers/gic.h>
9 #include <drivers/serial8250_uart.h>
10 #include <io.h>
11 #include <kernel/boot.h>
12 #include <kernel/panic.h>
13 #include <mm/core_memprot.h>
14 #include <platform_config.h>
15 #include <stdint.h>
16 
17 #if defined(CFG_EARLY_CONSOLE)
18 static struct serial8250_uart_data early_console_data;
19 register_phys_mem_pgdir(MEM_AREA_IO_NSEC,
20 			CFG_EARLY_CONSOLE_BASE, CFG_EARLY_CONSOLE_SIZE);
21 #endif
22 
23 #ifdef CFG_DRAM_BASE
24 register_ddr(CFG_DRAM_BASE, CFG_DRAM_SIZE);
25 #endif
26 #ifdef CFG_NSEC_DDR_1_BASE
27 register_ddr(CFG_NSEC_DDR_1_BASE, CFG_NSEC_DDR_1_SIZE);
28 #endif
29 
30 register_phys_mem_pgdir(MEM_AREA_IO_SEC, GIC_BASE, GIC_SIZE);
31 
boot_primary_init_intc(void)32 void boot_primary_init_intc(void)
33 {
34 	gic_init(GICC_BASE, GICD_BASE);
35 }
36 
boot_secondary_init_intc(void)37 void boot_secondary_init_intc(void)
38 {
39 	gic_init_per_cpu();
40 }
41 
plat_console_init(void)42 void plat_console_init(void)
43 {
44 #if defined(CFG_EARLY_CONSOLE)
45 	/*
46 	 * Console devices can vary a lot between devices and
47 	 * OP-TEE will switch to the DT-based real console later,
48 	 * based on DT-devices and the systems chosen node.
49 	 * So early console is only needed for early debugging.
50 	 */
51 	serial8250_uart_init(&early_console_data,
52 			     CFG_EARLY_CONSOLE_BASE,
53 			     CFG_EARLY_CONSOLE_CLK_IN_HZ,
54 			     CFG_EARLY_CONSOLE_BAUDRATE);
55 	register_serial_console(&early_console_data.chip);
56 #endif
57 }
58