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 #include <plat/arm/common/plat_arm.h> 17 18 /* Weak definitions may be overridden in specific ARM standard platform */ 19 #pragma weak tsp_early_platform_setup 20 #pragma weak tsp_platform_setup 21 #pragma weak tsp_plat_arch_setup 22 23 #define MAP_BL_TSP_TOTAL MAP_REGION_FLAT( \ 24 BL32_BASE, \ 25 BL32_END - BL32_BASE, \ 26 MT_MEMORY | MT_RW | MT_SECURE) 27 28 /******************************************************************************* 29 * Initialize the UART 30 ******************************************************************************/ 31 #if MULTI_CONSOLE_API 32 static console_pl011_t arm_tsp_runtime_console; 33 #endif 34 35 void arm_tsp_early_platform_setup(void) 36 { 37 #if MULTI_CONSOLE_API 38 /* 39 * Initialize a different console than already in use to display 40 * messages from TSP 41 */ 42 int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE, 43 PLAT_ARM_TSP_UART_CLK_IN_HZ, 44 ARM_CONSOLE_BAUDRATE, 45 &arm_tsp_runtime_console); 46 if (rc == 0) 47 panic(); 48 49 console_set_scope(&arm_tsp_runtime_console.console, 50 CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME); 51 #else 52 console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ, 53 ARM_CONSOLE_BAUDRATE); 54 #endif /* MULTI_CONSOLE_API */ 55 } 56 57 void tsp_early_platform_setup(void) 58 { 59 arm_tsp_early_platform_setup(); 60 } 61 62 /******************************************************************************* 63 * Perform platform specific setup placeholder 64 ******************************************************************************/ 65 void tsp_platform_setup(void) 66 { 67 plat_arm_gic_driver_init(); 68 } 69 70 /******************************************************************************* 71 * Perform the very early platform specific architectural setup here. At the 72 * moment this is only intializes the MMU 73 ******************************************************************************/ 74 void tsp_plat_arch_setup(void) 75 { 76 #if USE_COHERENT_MEM 77 /* Ensure ARM platforms don't use coherent memory in TSP */ 78 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U); 79 #endif 80 81 const mmap_region_t bl_regions[] = { 82 MAP_BL_TSP_TOTAL, 83 ARM_MAP_BL_RO, 84 {0} 85 }; 86 87 setup_page_tables(bl_regions, plat_arm_get_mmap()); 88 enable_mmu_el1(0); 89 } 90