xref: /optee_os/core/arch/arm/plat-uniphier/main.c (revision 11fa71b9ddb429088f325cfda430183003ccd1db)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (c) 2015, Linaro Limited
4  * Copyright (c) 2017, Socionext Inc.
5  */
6 
7 #include <console.h>
8 #include <drivers/gic.h>
9 #include <drivers/serial8250_uart.h>
10 #include <io.h>
11 #include <kernel/generic_boot.h>
12 #include <kernel/panic.h>
13 #include <kernel/pm_stubs.h>
14 #include <mm/tee_pager.h>
15 #include <platform_config.h>
16 #include <stdint.h>
17 #include <tee/entry_std.h>
18 #include <tee/entry_fast.h>
19 
20 register_phys_mem_pgdir(MEM_AREA_IO_SEC,
21 			ROUNDDOWN(CONSOLE_UART_BASE, CORE_MMU_PGDIR_SIZE),
22 			CORE_MMU_PGDIR_SIZE);
23 
24 register_phys_mem_pgdir(MEM_AREA_IO_SEC,
25 			ROUNDDOWN(GIC_BASE, CORE_MMU_PGDIR_SIZE),
26 			CORE_MMU_PGDIR_SIZE);
27 
28 register_phys_mem_pgdir(MEM_AREA_IO_SEC,
29 			ROUNDDOWN(GIC_BASE + GICD_OFFSET, CORE_MMU_PGDIR_SIZE),
30 			CORE_MMU_PGDIR_SIZE);
31 
32 #ifdef DRAM0_BASE
33 register_ddr(DRAM0_BASE, DRAM0_SIZE);
34 #endif
35 #ifdef DRAM1_BASE
36 register_ddr(DRAM1_BASE, DRAM1_SIZE);
37 #endif
38 
39 static struct gic_data gic_data;
40 
41 static const struct thread_handlers handlers = {
42 	.cpu_on = cpu_on_handler,
43 	.cpu_off = pm_do_nothing,
44 	.cpu_suspend = pm_do_nothing,
45 	.cpu_resume = pm_do_nothing,
46 	.system_off = pm_do_nothing,
47 	.system_reset = pm_do_nothing,
48 };
49 
50 static struct serial8250_uart_data console_data;
51 
52 const struct thread_handlers *generic_boot_get_handlers(void)
53 {
54 	return &handlers;
55 }
56 
57 void main_init_gic(void)
58 {
59 	vaddr_t gicc_base, gicd_base;
60 
61 	gicc_base = (vaddr_t)phys_to_virt(GIC_BASE + GICC_OFFSET,
62 					  MEM_AREA_IO_SEC);
63 	gicd_base = (vaddr_t)phys_to_virt(GIC_BASE + GICD_OFFSET,
64 					  MEM_AREA_IO_SEC);
65 
66 	gic_init_base_addr(&gic_data, gicc_base, gicd_base);
67 	itr_init(&gic_data.chip);
68 }
69 
70 void itr_core_handler(void)
71 {
72 	gic_it_handle(&gic_data);
73 }
74 
75 void console_init(void)
76 {
77 	/* Init UART */
78 	serial8250_uart_init(&console_data, CONSOLE_UART_BASE,
79 			     CONSOLE_UART_CLK_IN_HZ, CONSOLE_BAUDRATE);
80 
81 	/* Register console */
82 	register_serial_console(&console_data.chip);
83 }
84