181528dbcSRoberto Vargas /* 288a0523eSAntonio Nino Diaz * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. 381528dbcSRoberto Vargas * 481528dbcSRoberto Vargas * SPDX-License-Identifier: BSD-3-Clause 581528dbcSRoberto Vargas */ 6*09d40e0eSAntonio Nino Diaz 7d323af9eSDaniel Boulby #include <assert.h> 8*09d40e0eSAntonio Nino Diaz 9*09d40e0eSAntonio Nino Diaz #include <drivers/generic_delay_timer.h> 10*09d40e0eSAntonio Nino Diaz #include <plat/common/platform.h> 11*09d40e0eSAntonio Nino Diaz 12*09d40e0eSAntonio Nino Diaz #include <arm_def.h> 1381528dbcSRoberto Vargas #include <plat_arm.h> 1481528dbcSRoberto Vargas 1581528dbcSRoberto Vargas #pragma weak bl2_el3_early_platform_setup 1681528dbcSRoberto Vargas #pragma weak bl2_el3_plat_arch_setup 1781528dbcSRoberto Vargas #pragma weak bl2_el3_plat_prepare_exit 1881528dbcSRoberto Vargas 19d323af9eSDaniel Boulby #define MAP_BL2_EL3_TOTAL MAP_REGION_FLAT( \ 20d323af9eSDaniel Boulby bl2_el3_tzram_layout.total_base, \ 21d323af9eSDaniel Boulby bl2_el3_tzram_layout.total_size, \ 22d323af9eSDaniel Boulby MT_MEMORY | MT_RW | MT_SECURE) 23d323af9eSDaniel Boulby 2481528dbcSRoberto Vargas static meminfo_t bl2_el3_tzram_layout; 2581528dbcSRoberto Vargas 2681528dbcSRoberto Vargas /* 2781528dbcSRoberto Vargas * Perform arm specific early platform setup. At this moment we only initialize 2881528dbcSRoberto Vargas * the console and the memory layout. 2981528dbcSRoberto Vargas */ 3081528dbcSRoberto Vargas void arm_bl2_el3_early_platform_setup(void) 3181528dbcSRoberto Vargas { 3281528dbcSRoberto Vargas /* Initialize the console to provide early debug support */ 3388a0523eSAntonio Nino Diaz arm_console_boot_init(); 3481528dbcSRoberto Vargas 3581528dbcSRoberto Vargas /* 3681528dbcSRoberto Vargas * Allow BL2 to see the whole Trusted RAM. This is determined 3781528dbcSRoberto Vargas * statically since we cannot rely on BL1 passing this information 3881528dbcSRoberto Vargas * in the BL2_AT_EL3 case. 3981528dbcSRoberto Vargas */ 4081528dbcSRoberto Vargas bl2_el3_tzram_layout.total_base = ARM_BL_RAM_BASE; 4181528dbcSRoberto Vargas bl2_el3_tzram_layout.total_size = ARM_BL_RAM_SIZE; 4281528dbcSRoberto Vargas 4381528dbcSRoberto Vargas /* Initialise the IO layer and register platform IO devices */ 4481528dbcSRoberto Vargas plat_arm_io_setup(); 4581528dbcSRoberto Vargas } 4681528dbcSRoberto Vargas 4781528dbcSRoberto Vargas void bl2_el3_early_platform_setup(u_register_t arg0 __unused, 4881528dbcSRoberto Vargas u_register_t arg1 __unused, 4981528dbcSRoberto Vargas u_register_t arg2 __unused, 5081528dbcSRoberto Vargas u_register_t arg3 __unused) 5181528dbcSRoberto Vargas { 5281528dbcSRoberto Vargas arm_bl2_el3_early_platform_setup(); 5381528dbcSRoberto Vargas 5481528dbcSRoberto Vargas /* 5581528dbcSRoberto Vargas * Initialize Interconnect for this cluster during cold boot. 5681528dbcSRoberto Vargas * No need for locks as no other CPU is active. 5781528dbcSRoberto Vargas */ 5881528dbcSRoberto Vargas plat_arm_interconnect_init(); 5981528dbcSRoberto Vargas /* 6081528dbcSRoberto Vargas * Enable Interconnect coherency for the primary CPU's cluster. 6181528dbcSRoberto Vargas */ 6281528dbcSRoberto Vargas plat_arm_interconnect_enter_coherency(); 6381528dbcSRoberto Vargas 6481528dbcSRoberto Vargas generic_delay_timer_init(); 6581528dbcSRoberto Vargas } 6681528dbcSRoberto Vargas 6781528dbcSRoberto Vargas /******************************************************************************* 6881528dbcSRoberto Vargas * Perform the very early platform specific architectural setup here. At the 6981528dbcSRoberto Vargas * moment this is only initializes the mmu in a quick and dirty way. 7081528dbcSRoberto Vargas ******************************************************************************/ 7181528dbcSRoberto Vargas void arm_bl2_el3_plat_arch_setup(void) 7281528dbcSRoberto Vargas { 73d323af9eSDaniel Boulby 7481528dbcSRoberto Vargas #if USE_COHERENT_MEM 75d323af9eSDaniel Boulby /* Ensure ARM platforms dont use coherent memory in BL2_AT_EL3 */ 76d323af9eSDaniel Boulby assert(BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE == 0U); 7781528dbcSRoberto Vargas #endif 78d323af9eSDaniel Boulby 79d323af9eSDaniel Boulby const mmap_region_t bl_regions[] = { 80d323af9eSDaniel Boulby MAP_BL2_EL3_TOTAL, 812ecaafd2SDaniel Boulby ARM_MAP_BL_RO, 82d323af9eSDaniel Boulby {0} 83d323af9eSDaniel Boulby }; 84d323af9eSDaniel Boulby 850916c38dSRoberto Vargas setup_page_tables(bl_regions, plat_arm_get_mmap()); 8681528dbcSRoberto Vargas 8781528dbcSRoberto Vargas #ifdef AARCH32 881e54cbb8SAntonio Nino Diaz enable_mmu_svc_mon(0); 8981528dbcSRoberto Vargas #else 9081528dbcSRoberto Vargas enable_mmu_el3(0); 9181528dbcSRoberto Vargas #endif 9281528dbcSRoberto Vargas } 9381528dbcSRoberto Vargas 9481528dbcSRoberto Vargas void bl2_el3_plat_arch_setup(void) 9581528dbcSRoberto Vargas { 9681528dbcSRoberto Vargas arm_bl2_el3_plat_arch_setup(); 9781528dbcSRoberto Vargas } 9881528dbcSRoberto Vargas 9981528dbcSRoberto Vargas void bl2_el3_plat_prepare_exit(void) 10081528dbcSRoberto Vargas { 10181528dbcSRoberto Vargas } 102