1 /* 2 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 9 #include <platform_def.h> 10 11 #include <bl32/tsp/platform_tsp.h> 12 #include <common/bl_common.h> 13 #include <common/debug.h> 14 #include <drivers/arm/pl011.h> 15 #include <drivers/console.h> 16 17 #include <plat_arm.h> 18 19 #define BL32_END (unsigned long)(&__BL32_END__) 20 21 /* Weak definitions may be overridden in specific ARM standard platform */ 22 #pragma weak tsp_early_platform_setup 23 #pragma weak tsp_platform_setup 24 #pragma weak tsp_plat_arch_setup 25 26 #define MAP_BL_TSP_TOTAL MAP_REGION_FLAT( \ 27 BL32_BASE, \ 28 BL32_END - BL32_BASE, \ 29 MT_MEMORY | MT_RW | MT_SECURE) 30 31 /******************************************************************************* 32 * Initialize the UART 33 ******************************************************************************/ 34 #if MULTI_CONSOLE_API 35 static console_pl011_t arm_tsp_runtime_console; 36 #endif 37 38 void arm_tsp_early_platform_setup(void) 39 { 40 #if MULTI_CONSOLE_API 41 /* 42 * Initialize a different console than already in use to display 43 * messages from TSP 44 */ 45 int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE, 46 PLAT_ARM_TSP_UART_CLK_IN_HZ, 47 ARM_CONSOLE_BAUDRATE, 48 &arm_tsp_runtime_console); 49 if (rc == 0) 50 panic(); 51 52 console_set_scope(&arm_tsp_runtime_console.console, 53 CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME); 54 #else 55 console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ, 56 ARM_CONSOLE_BAUDRATE); 57 #endif /* MULTI_CONSOLE_API */ 58 } 59 60 void tsp_early_platform_setup(void) 61 { 62 arm_tsp_early_platform_setup(); 63 } 64 65 /******************************************************************************* 66 * Perform platform specific setup placeholder 67 ******************************************************************************/ 68 void tsp_platform_setup(void) 69 { 70 plat_arm_gic_driver_init(); 71 } 72 73 /******************************************************************************* 74 * Perform the very early platform specific architectural setup here. At the 75 * moment this is only intializes the MMU 76 ******************************************************************************/ 77 void tsp_plat_arch_setup(void) 78 { 79 #if USE_COHERENT_MEM 80 /* Ensure ARM platforms don't use coherent memory in TSP */ 81 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U); 82 #endif 83 84 const mmap_region_t bl_regions[] = { 85 MAP_BL_TSP_TOTAL, 86 ARM_MAP_BL_RO, 87 {0} 88 }; 89 90 setup_page_tables(bl_regions, plat_arm_get_mmap()); 91 enable_mmu_el1(0); 92 } 93