13e4b8fdcSSoby Mathew /* 21af540efSRoberto Vargas * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. 33e4b8fdcSSoby Mathew * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 53e4b8fdcSSoby Mathew */ 63e4b8fdcSSoby Mathew 73e4b8fdcSSoby Mathew #include <arm_config.h> 83e4b8fdcSSoby Mathew #include <arm_def.h> 9e29efeb1SAntonio Nino Diaz #include <arm_spm_def.h> 10c4fa1739SSandrine Bailleux #include <arm_xlat_tables.h> 11955242d8SJeenu Viswambharan #include <assert.h> 12955242d8SJeenu Viswambharan #include <cci.h> 1371237876SSoby Mathew #include <ccn.h> 143e4b8fdcSSoby Mathew #include <debug.h> 153e4b8fdcSSoby Mathew #include <gicv2.h> 163e4b8fdcSSoby Mathew #include <mmio.h> 173e4b8fdcSSoby Mathew #include <plat_arm.h> 18ba597da7SJohn Tsichritzis #include <platform.h> 19e29efeb1SAntonio Nino Diaz #include <secure_partition.h> 203e4b8fdcSSoby Mathew #include <v2m_def.h> 213e4b8fdcSSoby Mathew #include "../fvp_def.h" 221af540efSRoberto Vargas #include "fvp_private.h" 233e4b8fdcSSoby Mathew 243e4b8fdcSSoby Mathew /* Defines for GIC Driver build time selection */ 253e4b8fdcSSoby Mathew #define FVP_GICV2 1 263e4b8fdcSSoby Mathew #define FVP_GICV3 2 273e4b8fdcSSoby Mathew 283e4b8fdcSSoby Mathew /******************************************************************************* 293e4b8fdcSSoby Mathew * arm_config holds the characteristics of the differences between the three FVP 303e4b8fdcSSoby Mathew * platforms (Base, A53_A57 & Foundation). It will be populated during cold boot 313e4b8fdcSSoby Mathew * at each boot stage by the primary before enabling the MMU (to allow 323e4b8fdcSSoby Mathew * interconnect configuration) & used thereafter. Each BL will have its own copy 333e4b8fdcSSoby Mathew * to allow independent operation. 343e4b8fdcSSoby Mathew ******************************************************************************/ 353e4b8fdcSSoby Mathew arm_config_t arm_config; 363e4b8fdcSSoby Mathew 373e4b8fdcSSoby Mathew #define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \ 383e4b8fdcSSoby Mathew DEVICE0_SIZE, \ 393e4b8fdcSSoby Mathew MT_DEVICE | MT_RW | MT_SECURE) 403e4b8fdcSSoby Mathew 413e4b8fdcSSoby Mathew #define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \ 423e4b8fdcSSoby Mathew DEVICE1_SIZE, \ 433e4b8fdcSSoby Mathew MT_DEVICE | MT_RW | MT_SECURE) 443e4b8fdcSSoby Mathew 45284c3d67SSandrine Bailleux /* 46284c3d67SSandrine Bailleux * Need to be mapped with write permissions in order to set a new non-volatile 47284c3d67SSandrine Bailleux * counter value. 48284c3d67SSandrine Bailleux */ 493e4b8fdcSSoby Mathew #define MAP_DEVICE2 MAP_REGION_FLAT(DEVICE2_BASE, \ 503e4b8fdcSSoby Mathew DEVICE2_SIZE, \ 51fe7de035SAntonio Nino Diaz MT_DEVICE | MT_RW | MT_SECURE) 523e4b8fdcSSoby Mathew 533e4b8fdcSSoby Mathew /* 54b5fa6563SSandrine Bailleux * Table of memory regions for various BL stages to map using the MMU. 55b5fa6563SSandrine Bailleux * This doesn't include Trusted SRAM as arm_setup_page_tables() already 56b5fa6563SSandrine Bailleux * takes care of mapping it. 5791fad655SSandrine Bailleux * 5891fad655SSandrine Bailleux * The flash needs to be mapped as writable in order to erase the FIP's Table of 5991fad655SSandrine Bailleux * Contents in case of unrecoverable error (see plat_error_handler()). 603e4b8fdcSSoby Mathew */ 613d8256b2SMasahiro Yamada #ifdef IMAGE_BL1 623e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 633e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 643e4b8fdcSSoby Mathew V2M_MAP_FLASH0_RW, 653e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 663e4b8fdcSSoby Mathew MAP_DEVICE0, 673e4b8fdcSSoby Mathew MAP_DEVICE1, 683e4b8fdcSSoby Mathew #if TRUSTED_BOARD_BOOT 69284c3d67SSandrine Bailleux /* To access the Root of Trust Public Key registers. */ 70284c3d67SSandrine Bailleux MAP_DEVICE2, 71284c3d67SSandrine Bailleux /* Map DRAM to authenticate NS_BL2U image. */ 723e4b8fdcSSoby Mathew ARM_MAP_NS_DRAM1, 733e4b8fdcSSoby Mathew #endif 743e4b8fdcSSoby Mathew {0} 753e4b8fdcSSoby Mathew }; 763e4b8fdcSSoby Mathew #endif 773d8256b2SMasahiro Yamada #ifdef IMAGE_BL2 783e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 793e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 803e4b8fdcSSoby Mathew V2M_MAP_FLASH0_RW, 813e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 823e4b8fdcSSoby Mathew MAP_DEVICE0, 833e4b8fdcSSoby Mathew MAP_DEVICE1, 843e4b8fdcSSoby Mathew ARM_MAP_NS_DRAM1, 85b09ba056SRoberto Vargas #ifdef AARCH64 86b09ba056SRoberto Vargas ARM_MAP_DRAM2, 87b09ba056SRoberto Vargas #endif 883eb2d672SSandrine Bailleux #ifdef SPD_tspd 893e4b8fdcSSoby Mathew ARM_MAP_TSP_SEC_MEM, 903eb2d672SSandrine Bailleux #endif 91284c3d67SSandrine Bailleux #if TRUSTED_BOARD_BOOT 92284c3d67SSandrine Bailleux /* To access the Root of Trust Public Key registers. */ 93284c3d67SSandrine Bailleux MAP_DEVICE2, 9460e19f57SAntonio Nino Diaz #if !BL2_AT_EL3 95ba597da7SJohn Tsichritzis ARM_MAP_BL1_RW, 9660e19f57SAntonio Nino Diaz #endif 97ba597da7SJohn Tsichritzis #endif /* TRUSTED_BOARD_BOOT */ 98e29efeb1SAntonio Nino Diaz #if ENABLE_SPM 99e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_MMAP, 100e29efeb1SAntonio Nino Diaz #endif 1013e4b8fdcSSoby Mathew #if ARM_BL31_IN_DRAM 1023e4b8fdcSSoby Mathew ARM_MAP_BL31_SEC_DRAM, 1033e4b8fdcSSoby Mathew #endif 104810d9213SJens Wiklander #ifdef SPD_opteed 105b3ba6fdaSSoby Mathew ARM_MAP_OPTEE_CORE_MEM, 106810d9213SJens Wiklander ARM_OPTEE_PAGEABLE_LOAD_MEM, 107810d9213SJens Wiklander #endif 1083e4b8fdcSSoby Mathew {0} 1093e4b8fdcSSoby Mathew }; 1103e4b8fdcSSoby Mathew #endif 1113d8256b2SMasahiro Yamada #ifdef IMAGE_BL2U 1123e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 1133e4b8fdcSSoby Mathew MAP_DEVICE0, 1143e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1153e4b8fdcSSoby Mathew {0} 1163e4b8fdcSSoby Mathew }; 1173e4b8fdcSSoby Mathew #endif 1183d8256b2SMasahiro Yamada #ifdef IMAGE_BL31 1193e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 1203e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 121e35a3fb5SSoby Mathew ARM_MAP_EL3_TZC_DRAM, 1223e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1233e4b8fdcSSoby Mathew MAP_DEVICE0, 1243e4b8fdcSSoby Mathew MAP_DEVICE1, 125f145403cSRoberto Vargas ARM_V2M_MAP_MEM_PROTECT, 126e29efeb1SAntonio Nino Diaz #if ENABLE_SPM 127e29efeb1SAntonio Nino Diaz ARM_SPM_BUF_EL3_MMAP, 128e29efeb1SAntonio Nino Diaz #endif 1293e4b8fdcSSoby Mathew {0} 1303e4b8fdcSSoby Mathew }; 131e29efeb1SAntonio Nino Diaz 132e29efeb1SAntonio Nino Diaz #if ENABLE_SPM && defined(IMAGE_BL31) 133e29efeb1SAntonio Nino Diaz const mmap_region_t plat_arm_secure_partition_mmap[] = { 134e29efeb1SAntonio Nino Diaz V2M_MAP_IOFPGA_EL0, /* for the UART */ 135c4fa1739SSandrine Bailleux MAP_REGION_FLAT(DEVICE0_BASE, \ 136c4fa1739SSandrine Bailleux DEVICE0_SIZE, \ 137c4fa1739SSandrine Bailleux MT_DEVICE | MT_RO | MT_SECURE | MT_USER), 138e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_MMAP, 139e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_NS_BUF_MMAP, 140e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_RW_MMAP, 141e29efeb1SAntonio Nino Diaz ARM_SPM_BUF_EL0_MMAP, 142e29efeb1SAntonio Nino Diaz {0} 143e29efeb1SAntonio Nino Diaz }; 144e29efeb1SAntonio Nino Diaz #endif 1453e4b8fdcSSoby Mathew #endif 1463d8256b2SMasahiro Yamada #ifdef IMAGE_BL32 1473e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 148877cf3ffSSoby Mathew #ifdef AARCH32 149877cf3ffSSoby Mathew ARM_MAP_SHARED_RAM, 150950c6956SJoel Hutton ARM_V2M_MAP_MEM_PROTECT, 151877cf3ffSSoby Mathew #endif 1523e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1533e4b8fdcSSoby Mathew MAP_DEVICE0, 1543e4b8fdcSSoby Mathew MAP_DEVICE1, 1553e4b8fdcSSoby Mathew {0} 1563e4b8fdcSSoby Mathew }; 1573e4b8fdcSSoby Mathew #endif 1583e4b8fdcSSoby Mathew 1593e4b8fdcSSoby Mathew ARM_CASSERT_MMAP 1603e4b8fdcSSoby Mathew 161955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER != FVP_CCN 162955242d8SJeenu Viswambharan static const int fvp_cci400_map[] = { 163955242d8SJeenu Viswambharan PLAT_FVP_CCI400_CLUS0_SL_PORT, 164955242d8SJeenu Viswambharan PLAT_FVP_CCI400_CLUS1_SL_PORT, 165955242d8SJeenu Viswambharan }; 166955242d8SJeenu Viswambharan 167955242d8SJeenu Viswambharan static const int fvp_cci5xx_map[] = { 168955242d8SJeenu Viswambharan PLAT_FVP_CCI5XX_CLUS0_SL_PORT, 169955242d8SJeenu Viswambharan PLAT_FVP_CCI5XX_CLUS1_SL_PORT, 170955242d8SJeenu Viswambharan }; 171955242d8SJeenu Viswambharan 172955242d8SJeenu Viswambharan static unsigned int get_interconnect_master(void) 173955242d8SJeenu Viswambharan { 174955242d8SJeenu Viswambharan unsigned int master; 175955242d8SJeenu Viswambharan u_register_t mpidr; 176955242d8SJeenu Viswambharan 177955242d8SJeenu Viswambharan mpidr = read_mpidr_el1(); 178955242d8SJeenu Viswambharan master = (arm_config.flags & ARM_CONFIG_FVP_SHIFTED_AFF) ? 179955242d8SJeenu Viswambharan MPIDR_AFFLVL2_VAL(mpidr) : MPIDR_AFFLVL1_VAL(mpidr); 180955242d8SJeenu Viswambharan 181955242d8SJeenu Viswambharan assert(master < FVP_CLUSTER_COUNT); 182955242d8SJeenu Viswambharan return master; 183955242d8SJeenu Viswambharan } 184955242d8SJeenu Viswambharan #endif 1853e4b8fdcSSoby Mathew 186e29efeb1SAntonio Nino Diaz #if ENABLE_SPM && defined(IMAGE_BL31) 187e29efeb1SAntonio Nino Diaz /* 188e29efeb1SAntonio Nino Diaz * Boot information passed to a secure partition during initialisation. Linear 189e29efeb1SAntonio Nino Diaz * indices in MP information will be filled at runtime. 190e29efeb1SAntonio Nino Diaz */ 191e29efeb1SAntonio Nino Diaz static secure_partition_mp_info_t sp_mp_info[] = { 192e29efeb1SAntonio Nino Diaz [0] = {0x80000000, 0}, 193e29efeb1SAntonio Nino Diaz [1] = {0x80000001, 0}, 194e29efeb1SAntonio Nino Diaz [2] = {0x80000002, 0}, 195e29efeb1SAntonio Nino Diaz [3] = {0x80000003, 0}, 196e29efeb1SAntonio Nino Diaz [4] = {0x80000100, 0}, 197e29efeb1SAntonio Nino Diaz [5] = {0x80000101, 0}, 198e29efeb1SAntonio Nino Diaz [6] = {0x80000102, 0}, 199e29efeb1SAntonio Nino Diaz [7] = {0x80000103, 0}, 200e29efeb1SAntonio Nino Diaz }; 201e29efeb1SAntonio Nino Diaz 202e29efeb1SAntonio Nino Diaz const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = { 203e29efeb1SAntonio Nino Diaz .h.type = PARAM_SP_IMAGE_BOOT_INFO, 204e29efeb1SAntonio Nino Diaz .h.version = VERSION_1, 205e29efeb1SAntonio Nino Diaz .h.size = sizeof(secure_partition_boot_info_t), 206e29efeb1SAntonio Nino Diaz .h.attr = 0, 207e29efeb1SAntonio Nino Diaz .sp_mem_base = ARM_SP_IMAGE_BASE, 208e29efeb1SAntonio Nino Diaz .sp_mem_limit = ARM_SP_IMAGE_LIMIT, 209e29efeb1SAntonio Nino Diaz .sp_image_base = ARM_SP_IMAGE_BASE, 210e29efeb1SAntonio Nino Diaz .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, 211e29efeb1SAntonio Nino Diaz .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, 212e29efeb1SAntonio Nino Diaz .sp_ns_comm_buf_base = ARM_SP_IMAGE_NS_BUF_BASE, 213e29efeb1SAntonio Nino Diaz .sp_shared_buf_base = PLAT_SPM_BUF_BASE, 214e29efeb1SAntonio Nino Diaz .sp_image_size = ARM_SP_IMAGE_SIZE, 215e29efeb1SAntonio Nino Diaz .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, 216e29efeb1SAntonio Nino Diaz .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, 217e29efeb1SAntonio Nino Diaz .sp_ns_comm_buf_size = ARM_SP_IMAGE_NS_BUF_SIZE, 218e29efeb1SAntonio Nino Diaz .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, 219e29efeb1SAntonio Nino Diaz .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, 220e29efeb1SAntonio Nino Diaz .num_cpus = PLATFORM_CORE_COUNT, 221e29efeb1SAntonio Nino Diaz .mp_info = &sp_mp_info[0], 222e29efeb1SAntonio Nino Diaz }; 223e29efeb1SAntonio Nino Diaz 224e29efeb1SAntonio Nino Diaz const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) 225e29efeb1SAntonio Nino Diaz { 226e29efeb1SAntonio Nino Diaz return plat_arm_secure_partition_mmap; 227e29efeb1SAntonio Nino Diaz } 228e29efeb1SAntonio Nino Diaz 229e29efeb1SAntonio Nino Diaz const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( 230e29efeb1SAntonio Nino Diaz void *cookie) 231e29efeb1SAntonio Nino Diaz { 232e29efeb1SAntonio Nino Diaz return &plat_arm_secure_partition_boot_info; 233e29efeb1SAntonio Nino Diaz } 234e29efeb1SAntonio Nino Diaz 235e29efeb1SAntonio Nino Diaz #endif 236e29efeb1SAntonio Nino Diaz 2373e4b8fdcSSoby Mathew /******************************************************************************* 2383e4b8fdcSSoby Mathew * A single boot loader stack is expected to work on both the Foundation FVP 2393e4b8fdcSSoby Mathew * models and the two flavours of the Base FVP models (AEMv8 & Cortex). The 2403e4b8fdcSSoby Mathew * SYS_ID register provides a mechanism for detecting the differences between 2413e4b8fdcSSoby Mathew * these platforms. This information is stored in a per-BL array to allow the 2423e4b8fdcSSoby Mathew * code to take the correct path.Per BL platform configuration. 2433e4b8fdcSSoby Mathew ******************************************************************************/ 244*4d010d0dSDaniel Boulby void __init fvp_config_setup(void) 2453e4b8fdcSSoby Mathew { 2463e4b8fdcSSoby Mathew unsigned int rev, hbi, bld, arch, sys_id; 2473e4b8fdcSSoby Mathew 2483e4b8fdcSSoby Mathew sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); 2493e4b8fdcSSoby Mathew rev = (sys_id >> V2M_SYS_ID_REV_SHIFT) & V2M_SYS_ID_REV_MASK; 2503e4b8fdcSSoby Mathew hbi = (sys_id >> V2M_SYS_ID_HBI_SHIFT) & V2M_SYS_ID_HBI_MASK; 2513e4b8fdcSSoby Mathew bld = (sys_id >> V2M_SYS_ID_BLD_SHIFT) & V2M_SYS_ID_BLD_MASK; 2523e4b8fdcSSoby Mathew arch = (sys_id >> V2M_SYS_ID_ARCH_SHIFT) & V2M_SYS_ID_ARCH_MASK; 2533e4b8fdcSSoby Mathew 2543e4b8fdcSSoby Mathew if (arch != ARCH_MODEL) { 2553e4b8fdcSSoby Mathew ERROR("This firmware is for FVP models\n"); 2563e4b8fdcSSoby Mathew panic(); 2573e4b8fdcSSoby Mathew } 2583e4b8fdcSSoby Mathew 2593e4b8fdcSSoby Mathew /* 2603e4b8fdcSSoby Mathew * The build field in the SYS_ID tells which variant of the GIC 2613e4b8fdcSSoby Mathew * memory is implemented by the model. 2623e4b8fdcSSoby Mathew */ 2633e4b8fdcSSoby Mathew switch (bld) { 2643e4b8fdcSSoby Mathew case BLD_GIC_VE_MMAP: 26521a3973dSSoby Mathew ERROR("Legacy Versatile Express memory map for GIC peripheral" 26621a3973dSSoby Mathew " is not supported\n"); 2673e4b8fdcSSoby Mathew panic(); 2683e4b8fdcSSoby Mathew break; 2693e4b8fdcSSoby Mathew case BLD_GIC_A53A57_MMAP: 2703e4b8fdcSSoby Mathew break; 2713e4b8fdcSSoby Mathew default: 2723e4b8fdcSSoby Mathew ERROR("Unsupported board build %x\n", bld); 2733e4b8fdcSSoby Mathew panic(); 2743e4b8fdcSSoby Mathew } 2753e4b8fdcSSoby Mathew 2763e4b8fdcSSoby Mathew /* 2773e4b8fdcSSoby Mathew * The hbi field in the SYS_ID is 0x020 for the Base FVP & 0x010 2783e4b8fdcSSoby Mathew * for the Foundation FVP. 2793e4b8fdcSSoby Mathew */ 2803e4b8fdcSSoby Mathew switch (hbi) { 2813e4b8fdcSSoby Mathew case HBI_FOUNDATION_FVP: 2823e4b8fdcSSoby Mathew arm_config.flags = 0; 2833e4b8fdcSSoby Mathew 2843e4b8fdcSSoby Mathew /* 2853e4b8fdcSSoby Mathew * Check for supported revisions of Foundation FVP 2863e4b8fdcSSoby Mathew * Allow future revisions to run but emit warning diagnostic 2873e4b8fdcSSoby Mathew */ 2883e4b8fdcSSoby Mathew switch (rev) { 2893e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_V2_0: 2903e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_V2_1: 2913e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_v9_1: 2924faa4a1dSSandrine Bailleux case REV_FOUNDATION_FVP_v9_6: 2933e4b8fdcSSoby Mathew break; 2943e4b8fdcSSoby Mathew default: 2953e4b8fdcSSoby Mathew WARN("Unrecognized Foundation FVP revision %x\n", rev); 2963e4b8fdcSSoby Mathew break; 2973e4b8fdcSSoby Mathew } 2983e4b8fdcSSoby Mathew break; 2993e4b8fdcSSoby Mathew case HBI_BASE_FVP: 300955242d8SJeenu Viswambharan arm_config.flags |= (ARM_CONFIG_BASE_MMAP | ARM_CONFIG_HAS_TZC); 3013e4b8fdcSSoby Mathew 3023e4b8fdcSSoby Mathew /* 3033e4b8fdcSSoby Mathew * Check for supported revisions 3043e4b8fdcSSoby Mathew * Allow future revisions to run but emit warning diagnostic 3053e4b8fdcSSoby Mathew */ 3063e4b8fdcSSoby Mathew switch (rev) { 3073e4b8fdcSSoby Mathew case REV_BASE_FVP_V0: 308955242d8SJeenu Viswambharan arm_config.flags |= ARM_CONFIG_FVP_HAS_CCI400; 309955242d8SJeenu Viswambharan break; 310955242d8SJeenu Viswambharan case REV_BASE_FVP_REVC: 3118431635bSIsla Mitchell arm_config.flags |= (ARM_CONFIG_FVP_HAS_SMMUV3 | 312955242d8SJeenu Viswambharan ARM_CONFIG_FVP_HAS_CCI5XX); 3133e4b8fdcSSoby Mathew break; 3143e4b8fdcSSoby Mathew default: 3153e4b8fdcSSoby Mathew WARN("Unrecognized Base FVP revision %x\n", rev); 3163e4b8fdcSSoby Mathew break; 3173e4b8fdcSSoby Mathew } 3183e4b8fdcSSoby Mathew break; 3193e4b8fdcSSoby Mathew default: 3203e4b8fdcSSoby Mathew ERROR("Unsupported board HBI number 0x%x\n", hbi); 3213e4b8fdcSSoby Mathew panic(); 3223e4b8fdcSSoby Mathew } 3238431635bSIsla Mitchell 3248431635bSIsla Mitchell /* 3258431635bSIsla Mitchell * We assume that the presence of MT bit, and therefore shifted 3268431635bSIsla Mitchell * affinities, is uniform across the platform: either all CPUs, or no 3278431635bSIsla Mitchell * CPUs implement it. 3288431635bSIsla Mitchell */ 3298431635bSIsla Mitchell if (read_mpidr_el1() & MPIDR_MT_MASK) 3308431635bSIsla Mitchell arm_config.flags |= ARM_CONFIG_FVP_SHIFTED_AFF; 3313e4b8fdcSSoby Mathew } 3323e4b8fdcSSoby Mathew 3333e4b8fdcSSoby Mathew 334*4d010d0dSDaniel Boulby void __init fvp_interconnect_init(void) 3353e4b8fdcSSoby Mathew { 33671237876SSoby Mathew #if FVP_INTERCONNECT_DRIVER == FVP_CCN 33771237876SSoby Mathew if (ccn_get_part0_id(PLAT_ARM_CCN_BASE) != CCN_502_PART0_ID) { 33871237876SSoby Mathew ERROR("Unrecognized CCN variant detected. Only CCN-502" 33971237876SSoby Mathew " is supported"); 34071237876SSoby Mathew panic(); 34171237876SSoby Mathew } 342955242d8SJeenu Viswambharan 3433e4b8fdcSSoby Mathew plat_arm_interconnect_init(); 344955242d8SJeenu Viswambharan #else 345955242d8SJeenu Viswambharan uintptr_t cci_base = 0; 346955242d8SJeenu Viswambharan const int *cci_map = 0; 347955242d8SJeenu Viswambharan unsigned int map_size = 0; 348955242d8SJeenu Viswambharan 349955242d8SJeenu Viswambharan if (!(arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | 350955242d8SJeenu Viswambharan ARM_CONFIG_FVP_HAS_CCI5XX))) { 351955242d8SJeenu Viswambharan return; 3523e4b8fdcSSoby Mathew } 353955242d8SJeenu Viswambharan 354955242d8SJeenu Viswambharan /* Initialize the right interconnect */ 355955242d8SJeenu Viswambharan if (arm_config.flags & ARM_CONFIG_FVP_HAS_CCI5XX) { 356955242d8SJeenu Viswambharan cci_base = PLAT_FVP_CCI5XX_BASE; 357955242d8SJeenu Viswambharan cci_map = fvp_cci5xx_map; 358955242d8SJeenu Viswambharan map_size = ARRAY_SIZE(fvp_cci5xx_map); 359955242d8SJeenu Viswambharan } else if (arm_config.flags & ARM_CONFIG_FVP_HAS_CCI400) { 360955242d8SJeenu Viswambharan cci_base = PLAT_FVP_CCI400_BASE; 361955242d8SJeenu Viswambharan cci_map = fvp_cci400_map; 362955242d8SJeenu Viswambharan map_size = ARRAY_SIZE(fvp_cci400_map); 363955242d8SJeenu Viswambharan } 364955242d8SJeenu Viswambharan 365955242d8SJeenu Viswambharan assert(cci_base); 366955242d8SJeenu Viswambharan assert(cci_map); 367955242d8SJeenu Viswambharan cci_init(cci_base, cci_map, map_size); 368955242d8SJeenu Viswambharan #endif 36971237876SSoby Mathew } 3703e4b8fdcSSoby Mathew 3713e4b8fdcSSoby Mathew void fvp_interconnect_enable(void) 3723e4b8fdcSSoby Mathew { 373955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN 3743e4b8fdcSSoby Mathew plat_arm_interconnect_enter_coherency(); 375955242d8SJeenu Viswambharan #else 376955242d8SJeenu Viswambharan unsigned int master; 377955242d8SJeenu Viswambharan 378955242d8SJeenu Viswambharan if (arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | 379955242d8SJeenu Viswambharan ARM_CONFIG_FVP_HAS_CCI5XX)) { 380955242d8SJeenu Viswambharan master = get_interconnect_master(); 381955242d8SJeenu Viswambharan cci_enable_snoop_dvm_reqs(master); 382955242d8SJeenu Viswambharan } 383955242d8SJeenu Viswambharan #endif 3843e4b8fdcSSoby Mathew } 3853e4b8fdcSSoby Mathew 3863e4b8fdcSSoby Mathew void fvp_interconnect_disable(void) 3873e4b8fdcSSoby Mathew { 388955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN 3893e4b8fdcSSoby Mathew plat_arm_interconnect_exit_coherency(); 390955242d8SJeenu Viswambharan #else 391955242d8SJeenu Viswambharan unsigned int master; 392955242d8SJeenu Viswambharan 393955242d8SJeenu Viswambharan if (arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | 394955242d8SJeenu Viswambharan ARM_CONFIG_FVP_HAS_CCI5XX)) { 395955242d8SJeenu Viswambharan master = get_interconnect_master(); 396955242d8SJeenu Viswambharan cci_disable_snoop_dvm_reqs(master); 397955242d8SJeenu Viswambharan } 398955242d8SJeenu Viswambharan #endif 3993e4b8fdcSSoby Mathew } 400ba597da7SJohn Tsichritzis 40160e19f57SAntonio Nino Diaz #if TRUSTED_BOARD_BOOT 402ba597da7SJohn Tsichritzis int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) 403ba597da7SJohn Tsichritzis { 404ba597da7SJohn Tsichritzis assert(heap_addr != NULL); 405ba597da7SJohn Tsichritzis assert(heap_size != NULL); 406ba597da7SJohn Tsichritzis 407ba597da7SJohn Tsichritzis return arm_get_mbedtls_heap(heap_addr, heap_size); 408ba597da7SJohn Tsichritzis } 409ba597da7SJohn Tsichritzis #endif 410