xref: /optee_os/core/arch/arm/plat-rockchip/main.c (revision 890d675199ac46a85d50c7635d0a6867bdef1c8b)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (C) 2017, Fuzhou Rockchip Electronics Co., Ltd.
4  */
5 
6 #include <console.h>
7 #include <drivers/gic.h>
8 #include <drivers/serial8250_uart.h>
9 #include <io.h>
10 #include <kernel/generic_boot.h>
11 #include <kernel/panic.h>
12 #include <kernel/pm_stubs.h>
13 #include <mm/core_memprot.h>
14 #include <platform_config.h>
15 #include <stdint.h>
16 #include <tee/entry_std.h>
17 #include <tee/entry_fast.h>
18 
19 static struct gic_data gic_data;
20 static struct serial8250_uart_data console_data;
21 
22 register_phys_mem_pgdir(MEM_AREA_IO_SEC, PERIPH_BASE, PERIPH_SIZE);
23 register_phys_mem_pgdir(MEM_AREA_IO_NSEC, ISRAM_BASE, ISRAM_SIZE);
24 
25 static const struct thread_handlers handlers = {
26 	.cpu_on = pm_do_nothing,
27 	.cpu_off = pm_do_nothing,
28 	.cpu_suspend = pm_do_nothing,
29 	.cpu_resume = pm_do_nothing,
30 	.system_off = pm_do_nothing,
31 	.system_reset = pm_do_nothing,
32 };
33 
34 void main_init_gic(void)
35 {
36 	vaddr_t gicc_base;
37 	vaddr_t gicd_base;
38 
39 	gicc_base = (vaddr_t)phys_to_virt_io(GICC_BASE);
40 	gicd_base = (vaddr_t)phys_to_virt_io(GICD_BASE);
41 
42 	if (!gicc_base || !gicd_base)
43 		panic();
44 
45 	gic_init(&gic_data, gicc_base, gicd_base);
46 	itr_init(&gic_data.chip);
47 }
48 
49 void main_secondary_init_gic(void)
50 {
51 	gic_cpu_init(&gic_data);
52 }
53 
54 const struct thread_handlers *generic_boot_get_handlers(void)
55 {
56 	return &handlers;
57 }
58 
59 void console_init(void)
60 {
61 	serial8250_uart_init(&console_data, CONSOLE_UART_BASE,
62 			     CONSOLE_UART_CLK_IN_HZ, CONSOLE_BAUDRATE);
63 	register_serial_console(&console_data.chip);
64 }
65