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 #ifdef CFG_GIC 31 register_phys_mem_pgdir(MEM_AREA_IO_SEC, GIC_BASE, GIC_SIZE); 32 33 void boot_primary_init_intc(void) 34 { 35 gic_init(GICC_BASE, GICD_BASE); 36 } 37 38 void boot_secondary_init_intc(void) 39 { 40 gic_init_per_cpu(); 41 } 42 #endif 43 44 void plat_console_init(void) 45 { 46 #if defined(CFG_EARLY_CONSOLE) 47 /* 48 * Console devices can vary a lot between devices and 49 * OP-TEE will switch to the DT-based real console later, 50 * based on DT-devices and the systems chosen node. 51 * So early console is only needed for early debugging. 52 */ 53 serial8250_uart_init(&early_console_data, 54 CFG_EARLY_CONSOLE_BASE, 55 CFG_EARLY_CONSOLE_CLK_IN_HZ, 56 CFG_EARLY_CONSOLE_BAUDRATE); 57 register_serial_console(&early_console_data.chip); 58 #endif 59 } 60