13e4b8fdcSSoby Mathew /* 288c51c3fSManish V Badarkhe * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. 33e4b8fdcSSoby Mathew * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 53e4b8fdcSSoby Mathew */ 63e4b8fdcSSoby Mathew 709d40e0eSAntonio Nino Diaz #include <assert.h> 809d40e0eSAntonio Nino Diaz 909d40e0eSAntonio Nino Diaz #include <common/debug.h> 1009d40e0eSAntonio Nino Diaz #include <drivers/arm/cci.h> 1109d40e0eSAntonio Nino Diaz #include <drivers/arm/ccn.h> 1209d40e0eSAntonio Nino Diaz #include <drivers/arm/gicv2.h> 131b597c22SAlexei Fedorov #include <drivers/arm/sp804_delay_timer.h> 141b597c22SAlexei Fedorov #include <drivers/generic_delay_timer.h> 1509d40e0eSAntonio Nino Diaz #include <lib/mmio.h> 16ed9653ffSManish V Badarkhe #include <lib/smccc.h> 1709d40e0eSAntonio Nino Diaz #include <lib/xlat_tables/xlat_tables_compat.h> 18234bc7f8SAntonio Nino Diaz #include <platform_def.h> 19ed9653ffSManish V Badarkhe #include <services/arm_arch_svc.h> 20*1d0ca40eSJavier Almansa Sobrino #if ENABLE_RME 21*1d0ca40eSJavier Almansa Sobrino #include <services/rmm_core_manifest.h> 22*1d0ca40eSJavier Almansa Sobrino #endif 239d9ae976SOlivier Deprez #if SPM_MM 24aeaa225cSPaul Beesley #include <services/spm_mm_partition.h> 259d9ae976SOlivier Deprez #endif 2609d40e0eSAntonio Nino Diaz 27ed9653ffSManish V Badarkhe #include <plat/arm/common/arm_config.h> 28ed9653ffSManish V Badarkhe #include <plat/arm/common/plat_arm.h> 29ed9653ffSManish V Badarkhe #include <plat/common/platform.h> 30ed9653ffSManish V Badarkhe 311af540efSRoberto Vargas #include "fvp_private.h" 323e4b8fdcSSoby Mathew 333e4b8fdcSSoby Mathew /* Defines for GIC Driver build time selection */ 343e4b8fdcSSoby Mathew #define FVP_GICV2 1 353e4b8fdcSSoby Mathew #define FVP_GICV3 2 363e4b8fdcSSoby Mathew 373e4b8fdcSSoby Mathew /******************************************************************************* 383e4b8fdcSSoby Mathew * arm_config holds the characteristics of the differences between the three FVP 393e4b8fdcSSoby Mathew * platforms (Base, A53_A57 & Foundation). It will be populated during cold boot 403e4b8fdcSSoby Mathew * at each boot stage by the primary before enabling the MMU (to allow 413e4b8fdcSSoby Mathew * interconnect configuration) & used thereafter. Each BL will have its own copy 423e4b8fdcSSoby Mathew * to allow independent operation. 433e4b8fdcSSoby Mathew ******************************************************************************/ 443e4b8fdcSSoby Mathew arm_config_t arm_config; 453e4b8fdcSSoby Mathew 463e4b8fdcSSoby Mathew #define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \ 473e4b8fdcSSoby Mathew DEVICE0_SIZE, \ 483e4b8fdcSSoby Mathew MT_DEVICE | MT_RW | MT_SECURE) 493e4b8fdcSSoby Mathew 503e4b8fdcSSoby Mathew #define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \ 513e4b8fdcSSoby Mathew DEVICE1_SIZE, \ 523e4b8fdcSSoby Mathew MT_DEVICE | MT_RW | MT_SECURE) 533e4b8fdcSSoby Mathew 54f98630fbSManish V Badarkhe #if FVP_GICR_REGION_PROTECTION 55f98630fbSManish V Badarkhe #define MAP_GICD_MEM MAP_REGION_FLAT(BASE_GICD_BASE, \ 56f98630fbSManish V Badarkhe BASE_GICD_SIZE, \ 57f98630fbSManish V Badarkhe MT_DEVICE | MT_RW | MT_SECURE) 58f98630fbSManish V Badarkhe 59f98630fbSManish V Badarkhe /* Map all core's redistributor memory as read-only. After boots up, 60f98630fbSManish V Badarkhe * per-core map its redistributor memory as read-write */ 61f98630fbSManish V Badarkhe #define MAP_GICR_MEM MAP_REGION_FLAT(BASE_GICR_BASE, \ 62f98630fbSManish V Badarkhe (BASE_GICR_SIZE * PLATFORM_CORE_COUNT),\ 63f98630fbSManish V Badarkhe MT_DEVICE | MT_RO | MT_SECURE) 64f98630fbSManish V Badarkhe #endif /* FVP_GICR_REGION_PROTECTION */ 65f98630fbSManish V Badarkhe 66284c3d67SSandrine Bailleux /* 67284c3d67SSandrine Bailleux * Need to be mapped with write permissions in order to set a new non-volatile 68284c3d67SSandrine Bailleux * counter value. 69284c3d67SSandrine Bailleux */ 703e4b8fdcSSoby Mathew #define MAP_DEVICE2 MAP_REGION_FLAT(DEVICE2_BASE, \ 713e4b8fdcSSoby Mathew DEVICE2_SIZE, \ 72fe7de035SAntonio Nino Diaz MT_DEVICE | MT_RW | MT_SECURE) 733e4b8fdcSSoby Mathew 743e4b8fdcSSoby Mathew /* 75b5fa6563SSandrine Bailleux * Table of memory regions for various BL stages to map using the MMU. 760916c38dSRoberto Vargas * This doesn't include Trusted SRAM as setup_page_tables() already takes care 770916c38dSRoberto Vargas * of mapping it. 783e4b8fdcSSoby Mathew */ 793d8256b2SMasahiro Yamada #ifdef IMAGE_BL1 803e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 813e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 8279d8be3cSManish V Badarkhe V2M_MAP_FLASH0_RO, 833e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 843e4b8fdcSSoby Mathew MAP_DEVICE0, 85e0cea783SManish V Badarkhe #if FVP_INTERCONNECT_DRIVER == FVP_CCN 863e4b8fdcSSoby Mathew MAP_DEVICE1, 87e0cea783SManish V Badarkhe #endif 883e4b8fdcSSoby Mathew #if TRUSTED_BOARD_BOOT 89284c3d67SSandrine Bailleux /* To access the Root of Trust Public Key registers. */ 90284c3d67SSandrine Bailleux MAP_DEVICE2, 91284c3d67SSandrine Bailleux /* Map DRAM to authenticate NS_BL2U image. */ 923e4b8fdcSSoby Mathew ARM_MAP_NS_DRAM1, 933e4b8fdcSSoby Mathew #endif 943e4b8fdcSSoby Mathew {0} 953e4b8fdcSSoby Mathew }; 963e4b8fdcSSoby Mathew #endif 973d8256b2SMasahiro Yamada #ifdef IMAGE_BL2 983e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 993e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 1003e4b8fdcSSoby Mathew V2M_MAP_FLASH0_RW, 1013e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1023e4b8fdcSSoby Mathew MAP_DEVICE0, 103e0cea783SManish V Badarkhe #if FVP_INTERCONNECT_DRIVER == FVP_CCN 1043e4b8fdcSSoby Mathew MAP_DEVICE1, 105e0cea783SManish V Badarkhe #endif 1063e4b8fdcSSoby Mathew ARM_MAP_NS_DRAM1, 107402b3cf8SJulius Werner #ifdef __aarch64__ 108b09ba056SRoberto Vargas ARM_MAP_DRAM2, 109b09ba056SRoberto Vargas #endif 11039f0b86aSManish V Badarkhe /* 11139f0b86aSManish V Badarkhe * Required to load HW_CONFIG, SPMC and SPs to trusted DRAM. 11239f0b86aSManish V Badarkhe */ 11364758c97SAchin Gupta ARM_MAP_TRUSTED_DRAM, 114c8720729SZelalem Aweke #if ENABLE_RME 115c8720729SZelalem Aweke ARM_MAP_RMM_DRAM, 116c8720729SZelalem Aweke ARM_MAP_GPT_L1_DRAM, 117c8720729SZelalem Aweke #endif /* ENABLE_RME */ 1183eb2d672SSandrine Bailleux #ifdef SPD_tspd 1193e4b8fdcSSoby Mathew ARM_MAP_TSP_SEC_MEM, 1203eb2d672SSandrine Bailleux #endif 121284c3d67SSandrine Bailleux #if TRUSTED_BOARD_BOOT 122284c3d67SSandrine Bailleux /* To access the Root of Trust Public Key registers. */ 123284c3d67SSandrine Bailleux MAP_DEVICE2, 124ba597da7SJohn Tsichritzis #endif /* TRUSTED_BOARD_BOOT */ 12588c51c3fSManish V Badarkhe 12688c51c3fSManish V Badarkhe #if CRYPTO_SUPPORT && !BL2_AT_EL3 12788c51c3fSManish V Badarkhe /* 12888c51c3fSManish V Badarkhe * To access shared the Mbed TLS heap while booting the 12988c51c3fSManish V Badarkhe * system with Crypto support 13088c51c3fSManish V Badarkhe */ 13188c51c3fSManish V Badarkhe ARM_MAP_BL1_RW, 13288c51c3fSManish V Badarkhe #endif /* CRYPTO_SUPPORT && !BL2_AT_EL3 */ 13344639ab7SMarc Bonnici #if SPM_MM || SPMC_AT_EL3 134e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_MMAP, 135e29efeb1SAntonio Nino Diaz #endif 1363e4b8fdcSSoby Mathew #if ARM_BL31_IN_DRAM 1373e4b8fdcSSoby Mathew ARM_MAP_BL31_SEC_DRAM, 1383e4b8fdcSSoby Mathew #endif 139810d9213SJens Wiklander #ifdef SPD_opteed 140b3ba6fdaSSoby Mathew ARM_MAP_OPTEE_CORE_MEM, 141810d9213SJens Wiklander ARM_OPTEE_PAGEABLE_LOAD_MEM, 142810d9213SJens Wiklander #endif 1433e4b8fdcSSoby Mathew {0} 1443e4b8fdcSSoby Mathew }; 1453e4b8fdcSSoby Mathew #endif 1463d8256b2SMasahiro Yamada #ifdef IMAGE_BL2U 1473e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 1483e4b8fdcSSoby Mathew MAP_DEVICE0, 1493e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1503e4b8fdcSSoby Mathew {0} 1513e4b8fdcSSoby Mathew }; 1523e4b8fdcSSoby Mathew #endif 1533d8256b2SMasahiro Yamada #ifdef IMAGE_BL31 1543e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 1553e4b8fdcSSoby Mathew ARM_MAP_SHARED_RAM, 156992f091bSAmbroise Vincent #if USE_DEBUGFS 157992f091bSAmbroise Vincent /* Required by devfip, can be removed if devfip is not used */ 158992f091bSAmbroise Vincent V2M_MAP_FLASH0_RW, 159992f091bSAmbroise Vincent #endif /* USE_DEBUGFS */ 160e35a3fb5SSoby Mathew ARM_MAP_EL3_TZC_DRAM, 1613e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 1623e4b8fdcSSoby Mathew MAP_DEVICE0, 163f98630fbSManish V Badarkhe #if FVP_GICR_REGION_PROTECTION 164f98630fbSManish V Badarkhe MAP_GICD_MEM, 165f98630fbSManish V Badarkhe MAP_GICR_MEM, 166f98630fbSManish V Badarkhe #else 1673e4b8fdcSSoby Mathew MAP_DEVICE1, 168f98630fbSManish V Badarkhe #endif /* FVP_GICR_REGION_PROTECTION */ 169f145403cSRoberto Vargas ARM_V2M_MAP_MEM_PROTECT, 1703f3c341aSPaul Beesley #if SPM_MM 171e29efeb1SAntonio Nino Diaz ARM_SPM_BUF_EL3_MMAP, 172e29efeb1SAntonio Nino Diaz #endif 173c8720729SZelalem Aweke #if ENABLE_RME 174c8720729SZelalem Aweke ARM_MAP_GPT_L1_DRAM, 1758c980a4aSJavier Almansa Sobrino ARM_MAP_EL3_RMM_SHARED_MEM, 176c8720729SZelalem Aweke #endif 1773e4b8fdcSSoby Mathew {0} 1783e4b8fdcSSoby Mathew }; 179e29efeb1SAntonio Nino Diaz 1803f3c341aSPaul Beesley #if defined(IMAGE_BL31) && SPM_MM 181e29efeb1SAntonio Nino Diaz const mmap_region_t plat_arm_secure_partition_mmap[] = { 182e29efeb1SAntonio Nino Diaz V2M_MAP_IOFPGA_EL0, /* for the UART */ 183c4fa1739SSandrine Bailleux MAP_REGION_FLAT(DEVICE0_BASE, \ 184c4fa1739SSandrine Bailleux DEVICE0_SIZE, \ 185c4fa1739SSandrine Bailleux MT_DEVICE | MT_RO | MT_SECURE | MT_USER), 186e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_MMAP, 187e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_NS_BUF_MMAP, 188e29efeb1SAntonio Nino Diaz ARM_SP_IMAGE_RW_MMAP, 189e29efeb1SAntonio Nino Diaz ARM_SPM_BUF_EL0_MMAP, 190e29efeb1SAntonio Nino Diaz {0} 191e29efeb1SAntonio Nino Diaz }; 192e29efeb1SAntonio Nino Diaz #endif 1933e4b8fdcSSoby Mathew #endif 1943d8256b2SMasahiro Yamada #ifdef IMAGE_BL32 1953e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = { 196402b3cf8SJulius Werner #ifndef __aarch64__ 197877cf3ffSSoby Mathew ARM_MAP_SHARED_RAM, 198950c6956SJoel Hutton ARM_V2M_MAP_MEM_PROTECT, 199877cf3ffSSoby Mathew #endif 2003e4b8fdcSSoby Mathew V2M_MAP_IOFPGA, 2013e4b8fdcSSoby Mathew MAP_DEVICE0, 2023e4b8fdcSSoby Mathew MAP_DEVICE1, 2033e4b8fdcSSoby Mathew {0} 2043e4b8fdcSSoby Mathew }; 2053e4b8fdcSSoby Mathew #endif 2063e4b8fdcSSoby Mathew 2079d870b79SZelalem Aweke #ifdef IMAGE_RMM 2089d870b79SZelalem Aweke const mmap_region_t plat_arm_mmap[] = { 2099d870b79SZelalem Aweke V2M_MAP_IOFPGA, 2109d870b79SZelalem Aweke MAP_DEVICE0, 2119d870b79SZelalem Aweke MAP_DEVICE1, 2129d870b79SZelalem Aweke {0} 2139d870b79SZelalem Aweke }; 2149d870b79SZelalem Aweke #endif 2159d870b79SZelalem Aweke 2163e4b8fdcSSoby Mathew ARM_CASSERT_MMAP 2173e4b8fdcSSoby Mathew 218955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER != FVP_CCN 219955242d8SJeenu Viswambharan static const int fvp_cci400_map[] = { 220955242d8SJeenu Viswambharan PLAT_FVP_CCI400_CLUS0_SL_PORT, 221955242d8SJeenu Viswambharan PLAT_FVP_CCI400_CLUS1_SL_PORT, 222955242d8SJeenu Viswambharan }; 223955242d8SJeenu Viswambharan 224955242d8SJeenu Viswambharan static const int fvp_cci5xx_map[] = { 225955242d8SJeenu Viswambharan PLAT_FVP_CCI5XX_CLUS0_SL_PORT, 226955242d8SJeenu Viswambharan PLAT_FVP_CCI5XX_CLUS1_SL_PORT, 227955242d8SJeenu Viswambharan }; 228955242d8SJeenu Viswambharan 229955242d8SJeenu Viswambharan static unsigned int get_interconnect_master(void) 230955242d8SJeenu Viswambharan { 231955242d8SJeenu Viswambharan unsigned int master; 232955242d8SJeenu Viswambharan u_register_t mpidr; 233955242d8SJeenu Viswambharan 234955242d8SJeenu Viswambharan mpidr = read_mpidr_el1(); 235583e0791SAntonio Nino Diaz master = ((arm_config.flags & ARM_CONFIG_FVP_SHIFTED_AFF) != 0U) ? 236955242d8SJeenu Viswambharan MPIDR_AFFLVL2_VAL(mpidr) : MPIDR_AFFLVL1_VAL(mpidr); 237955242d8SJeenu Viswambharan 238955242d8SJeenu Viswambharan assert(master < FVP_CLUSTER_COUNT); 239955242d8SJeenu Viswambharan return master; 240955242d8SJeenu Viswambharan } 241955242d8SJeenu Viswambharan #endif 2423e4b8fdcSSoby Mathew 2433f3c341aSPaul Beesley #if defined(IMAGE_BL31) && SPM_MM 244e29efeb1SAntonio Nino Diaz /* 245e29efeb1SAntonio Nino Diaz * Boot information passed to a secure partition during initialisation. Linear 246e29efeb1SAntonio Nino Diaz * indices in MP information will be filled at runtime. 247e29efeb1SAntonio Nino Diaz */ 248aeaa225cSPaul Beesley static spm_mm_mp_info_t sp_mp_info[] = { 249e29efeb1SAntonio Nino Diaz [0] = {0x80000000, 0}, 250e29efeb1SAntonio Nino Diaz [1] = {0x80000001, 0}, 251e29efeb1SAntonio Nino Diaz [2] = {0x80000002, 0}, 252e29efeb1SAntonio Nino Diaz [3] = {0x80000003, 0}, 253e29efeb1SAntonio Nino Diaz [4] = {0x80000100, 0}, 254e29efeb1SAntonio Nino Diaz [5] = {0x80000101, 0}, 255e29efeb1SAntonio Nino Diaz [6] = {0x80000102, 0}, 256e29efeb1SAntonio Nino Diaz [7] = {0x80000103, 0}, 257e29efeb1SAntonio Nino Diaz }; 258e29efeb1SAntonio Nino Diaz 259aeaa225cSPaul Beesley const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { 260e29efeb1SAntonio Nino Diaz .h.type = PARAM_SP_IMAGE_BOOT_INFO, 261e29efeb1SAntonio Nino Diaz .h.version = VERSION_1, 262aeaa225cSPaul Beesley .h.size = sizeof(spm_mm_boot_info_t), 263e29efeb1SAntonio Nino Diaz .h.attr = 0, 264e29efeb1SAntonio Nino Diaz .sp_mem_base = ARM_SP_IMAGE_BASE, 265e29efeb1SAntonio Nino Diaz .sp_mem_limit = ARM_SP_IMAGE_LIMIT, 266e29efeb1SAntonio Nino Diaz .sp_image_base = ARM_SP_IMAGE_BASE, 267e29efeb1SAntonio Nino Diaz .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, 268e29efeb1SAntonio Nino Diaz .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, 2690560efb9SArd Biesheuvel .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE, 270e29efeb1SAntonio Nino Diaz .sp_shared_buf_base = PLAT_SPM_BUF_BASE, 271e29efeb1SAntonio Nino Diaz .sp_image_size = ARM_SP_IMAGE_SIZE, 272e29efeb1SAntonio Nino Diaz .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, 273e29efeb1SAntonio Nino Diaz .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, 2740560efb9SArd Biesheuvel .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE, 275e29efeb1SAntonio Nino Diaz .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, 276e29efeb1SAntonio Nino Diaz .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, 277e29efeb1SAntonio Nino Diaz .num_cpus = PLATFORM_CORE_COUNT, 278e29efeb1SAntonio Nino Diaz .mp_info = &sp_mp_info[0], 279e29efeb1SAntonio Nino Diaz }; 280e29efeb1SAntonio Nino Diaz 281e29efeb1SAntonio Nino Diaz const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) 282e29efeb1SAntonio Nino Diaz { 283e29efeb1SAntonio Nino Diaz return plat_arm_secure_partition_mmap; 284e29efeb1SAntonio Nino Diaz } 285e29efeb1SAntonio Nino Diaz 286aeaa225cSPaul Beesley const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( 287e29efeb1SAntonio Nino Diaz void *cookie) 288e29efeb1SAntonio Nino Diaz { 289e29efeb1SAntonio Nino Diaz return &plat_arm_secure_partition_boot_info; 290e29efeb1SAntonio Nino Diaz } 291e29efeb1SAntonio Nino Diaz #endif 292e29efeb1SAntonio Nino Diaz 2933e4b8fdcSSoby Mathew /******************************************************************************* 2943e4b8fdcSSoby Mathew * A single boot loader stack is expected to work on both the Foundation FVP 2953e4b8fdcSSoby Mathew * models and the two flavours of the Base FVP models (AEMv8 & Cortex). The 2963e4b8fdcSSoby Mathew * SYS_ID register provides a mechanism for detecting the differences between 2973e4b8fdcSSoby Mathew * these platforms. This information is stored in a per-BL array to allow the 2983e4b8fdcSSoby Mathew * code to take the correct path.Per BL platform configuration. 2993e4b8fdcSSoby Mathew ******************************************************************************/ 3004d010d0dSDaniel Boulby void __init fvp_config_setup(void) 3013e4b8fdcSSoby Mathew { 3023e4b8fdcSSoby Mathew unsigned int rev, hbi, bld, arch, sys_id; 3033e4b8fdcSSoby Mathew 3043e4b8fdcSSoby Mathew sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); 3053e4b8fdcSSoby Mathew rev = (sys_id >> V2M_SYS_ID_REV_SHIFT) & V2M_SYS_ID_REV_MASK; 3063e4b8fdcSSoby Mathew hbi = (sys_id >> V2M_SYS_ID_HBI_SHIFT) & V2M_SYS_ID_HBI_MASK; 3073e4b8fdcSSoby Mathew bld = (sys_id >> V2M_SYS_ID_BLD_SHIFT) & V2M_SYS_ID_BLD_MASK; 3083e4b8fdcSSoby Mathew arch = (sys_id >> V2M_SYS_ID_ARCH_SHIFT) & V2M_SYS_ID_ARCH_MASK; 3093e4b8fdcSSoby Mathew 3103e4b8fdcSSoby Mathew if (arch != ARCH_MODEL) { 3113e4b8fdcSSoby Mathew ERROR("This firmware is for FVP models\n"); 3123e4b8fdcSSoby Mathew panic(); 3133e4b8fdcSSoby Mathew } 3143e4b8fdcSSoby Mathew 3153e4b8fdcSSoby Mathew /* 3163e4b8fdcSSoby Mathew * The build field in the SYS_ID tells which variant of the GIC 3173e4b8fdcSSoby Mathew * memory is implemented by the model. 3183e4b8fdcSSoby Mathew */ 3193e4b8fdcSSoby Mathew switch (bld) { 3203e4b8fdcSSoby Mathew case BLD_GIC_VE_MMAP: 32121a3973dSSoby Mathew ERROR("Legacy Versatile Express memory map for GIC peripheral" 32221a3973dSSoby Mathew " is not supported\n"); 3233e4b8fdcSSoby Mathew panic(); 3243e4b8fdcSSoby Mathew break; 3253e4b8fdcSSoby Mathew case BLD_GIC_A53A57_MMAP: 3263e4b8fdcSSoby Mathew break; 3273e4b8fdcSSoby Mathew default: 3283e4b8fdcSSoby Mathew ERROR("Unsupported board build %x\n", bld); 3293e4b8fdcSSoby Mathew panic(); 3303e4b8fdcSSoby Mathew } 3313e4b8fdcSSoby Mathew 3323e4b8fdcSSoby Mathew /* 3333e4b8fdcSSoby Mathew * The hbi field in the SYS_ID is 0x020 for the Base FVP & 0x010 3343e4b8fdcSSoby Mathew * for the Foundation FVP. 3353e4b8fdcSSoby Mathew */ 3363e4b8fdcSSoby Mathew switch (hbi) { 3373e4b8fdcSSoby Mathew case HBI_FOUNDATION_FVP: 3383e4b8fdcSSoby Mathew arm_config.flags = 0; 3393e4b8fdcSSoby Mathew 3403e4b8fdcSSoby Mathew /* 3413e4b8fdcSSoby Mathew * Check for supported revisions of Foundation FVP 3423e4b8fdcSSoby Mathew * Allow future revisions to run but emit warning diagnostic 3433e4b8fdcSSoby Mathew */ 3443e4b8fdcSSoby Mathew switch (rev) { 3453e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_V2_0: 3463e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_V2_1: 3473e4b8fdcSSoby Mathew case REV_FOUNDATION_FVP_v9_1: 3484faa4a1dSSandrine Bailleux case REV_FOUNDATION_FVP_v9_6: 3493e4b8fdcSSoby Mathew break; 3503e4b8fdcSSoby Mathew default: 3513e4b8fdcSSoby Mathew WARN("Unrecognized Foundation FVP revision %x\n", rev); 3523e4b8fdcSSoby Mathew break; 3533e4b8fdcSSoby Mathew } 3543e4b8fdcSSoby Mathew break; 3553e4b8fdcSSoby Mathew case HBI_BASE_FVP: 356955242d8SJeenu Viswambharan arm_config.flags |= (ARM_CONFIG_BASE_MMAP | ARM_CONFIG_HAS_TZC); 3573e4b8fdcSSoby Mathew 3583e4b8fdcSSoby Mathew /* 3593e4b8fdcSSoby Mathew * Check for supported revisions 3603e4b8fdcSSoby Mathew * Allow future revisions to run but emit warning diagnostic 3613e4b8fdcSSoby Mathew */ 3623e4b8fdcSSoby Mathew switch (rev) { 3633e4b8fdcSSoby Mathew case REV_BASE_FVP_V0: 364955242d8SJeenu Viswambharan arm_config.flags |= ARM_CONFIG_FVP_HAS_CCI400; 365955242d8SJeenu Viswambharan break; 366955242d8SJeenu Viswambharan case REV_BASE_FVP_REVC: 3678431635bSIsla Mitchell arm_config.flags |= (ARM_CONFIG_FVP_HAS_SMMUV3 | 368955242d8SJeenu Viswambharan ARM_CONFIG_FVP_HAS_CCI5XX); 3693e4b8fdcSSoby Mathew break; 3703e4b8fdcSSoby Mathew default: 3713e4b8fdcSSoby Mathew WARN("Unrecognized Base FVP revision %x\n", rev); 3723e4b8fdcSSoby Mathew break; 3733e4b8fdcSSoby Mathew } 3743e4b8fdcSSoby Mathew break; 3753e4b8fdcSSoby Mathew default: 3763e4b8fdcSSoby Mathew ERROR("Unsupported board HBI number 0x%x\n", hbi); 3773e4b8fdcSSoby Mathew panic(); 3783e4b8fdcSSoby Mathew } 3798431635bSIsla Mitchell 3808431635bSIsla Mitchell /* 3818431635bSIsla Mitchell * We assume that the presence of MT bit, and therefore shifted 3828431635bSIsla Mitchell * affinities, is uniform across the platform: either all CPUs, or no 3838431635bSIsla Mitchell * CPUs implement it. 3848431635bSIsla Mitchell */ 385583e0791SAntonio Nino Diaz if ((read_mpidr_el1() & MPIDR_MT_MASK) != 0U) 3868431635bSIsla Mitchell arm_config.flags |= ARM_CONFIG_FVP_SHIFTED_AFF; 3873e4b8fdcSSoby Mathew } 3883e4b8fdcSSoby Mathew 3893e4b8fdcSSoby Mathew 3904d010d0dSDaniel Boulby void __init fvp_interconnect_init(void) 3913e4b8fdcSSoby Mathew { 39271237876SSoby Mathew #if FVP_INTERCONNECT_DRIVER == FVP_CCN 39371237876SSoby Mathew if (ccn_get_part0_id(PLAT_ARM_CCN_BASE) != CCN_502_PART0_ID) { 394583e0791SAntonio Nino Diaz ERROR("Unrecognized CCN variant detected. Only CCN-502 is supported"); 39571237876SSoby Mathew panic(); 39671237876SSoby Mathew } 397955242d8SJeenu Viswambharan 3983e4b8fdcSSoby Mathew plat_arm_interconnect_init(); 399955242d8SJeenu Viswambharan #else 400583e0791SAntonio Nino Diaz uintptr_t cci_base = 0U; 401583e0791SAntonio Nino Diaz const int *cci_map = NULL; 402583e0791SAntonio Nino Diaz unsigned int map_size = 0U; 403955242d8SJeenu Viswambharan 404955242d8SJeenu Viswambharan /* Initialize the right interconnect */ 405583e0791SAntonio Nino Diaz if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI5XX) != 0U) { 406955242d8SJeenu Viswambharan cci_base = PLAT_FVP_CCI5XX_BASE; 407955242d8SJeenu Viswambharan cci_map = fvp_cci5xx_map; 408955242d8SJeenu Viswambharan map_size = ARRAY_SIZE(fvp_cci5xx_map); 409583e0791SAntonio Nino Diaz } else if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI400) != 0U) { 410955242d8SJeenu Viswambharan cci_base = PLAT_FVP_CCI400_BASE; 411955242d8SJeenu Viswambharan cci_map = fvp_cci400_map; 412955242d8SJeenu Viswambharan map_size = ARRAY_SIZE(fvp_cci400_map); 413583e0791SAntonio Nino Diaz } else { 414583e0791SAntonio Nino Diaz return; 415955242d8SJeenu Viswambharan } 416955242d8SJeenu Viswambharan 417583e0791SAntonio Nino Diaz assert(cci_base != 0U); 418583e0791SAntonio Nino Diaz assert(cci_map != NULL); 419955242d8SJeenu Viswambharan cci_init(cci_base, cci_map, map_size); 420955242d8SJeenu Viswambharan #endif 42171237876SSoby Mathew } 4223e4b8fdcSSoby Mathew 4233e4b8fdcSSoby Mathew void fvp_interconnect_enable(void) 4243e4b8fdcSSoby Mathew { 425955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN 4263e4b8fdcSSoby Mathew plat_arm_interconnect_enter_coherency(); 427955242d8SJeenu Viswambharan #else 428955242d8SJeenu Viswambharan unsigned int master; 429955242d8SJeenu Viswambharan 430583e0791SAntonio Nino Diaz if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | 431583e0791SAntonio Nino Diaz ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { 432955242d8SJeenu Viswambharan master = get_interconnect_master(); 433955242d8SJeenu Viswambharan cci_enable_snoop_dvm_reqs(master); 434955242d8SJeenu Viswambharan } 435955242d8SJeenu Viswambharan #endif 4363e4b8fdcSSoby Mathew } 4373e4b8fdcSSoby Mathew 4383e4b8fdcSSoby Mathew void fvp_interconnect_disable(void) 4393e4b8fdcSSoby Mathew { 440955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN 4413e4b8fdcSSoby Mathew plat_arm_interconnect_exit_coherency(); 442955242d8SJeenu Viswambharan #else 443955242d8SJeenu Viswambharan unsigned int master; 444955242d8SJeenu Viswambharan 445583e0791SAntonio Nino Diaz if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | 446583e0791SAntonio Nino Diaz ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { 447955242d8SJeenu Viswambharan master = get_interconnect_master(); 448955242d8SJeenu Viswambharan cci_disable_snoop_dvm_reqs(master); 449955242d8SJeenu Viswambharan } 450955242d8SJeenu Viswambharan #endif 4513e4b8fdcSSoby Mathew } 452ba597da7SJohn Tsichritzis 45388c51c3fSManish V Badarkhe #if CRYPTO_SUPPORT 454ba597da7SJohn Tsichritzis int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) 455ba597da7SJohn Tsichritzis { 456ba597da7SJohn Tsichritzis assert(heap_addr != NULL); 457ba597da7SJohn Tsichritzis assert(heap_size != NULL); 458ba597da7SJohn Tsichritzis 459ba597da7SJohn Tsichritzis return arm_get_mbedtls_heap(heap_addr, heap_size); 460ba597da7SJohn Tsichritzis } 46188c51c3fSManish V Badarkhe #endif /* CRYPTO_SUPPORT */ 4621b597c22SAlexei Fedorov 4631b597c22SAlexei Fedorov void fvp_timer_init(void) 4641b597c22SAlexei Fedorov { 465fddfb3baSMadhukar Pappireddy #if USE_SP804_TIMER 4661b597c22SAlexei Fedorov /* Enable the clock override for SP804 timer 0, which means that no 4671b597c22SAlexei Fedorov * clock dividers are applied and the raw (35MHz) clock will be used. 4681b597c22SAlexei Fedorov */ 4691b597c22SAlexei Fedorov mmio_write_32(V2M_SP810_BASE, FVP_SP810_CTRL_TIM0_OV); 4701b597c22SAlexei Fedorov 4711b597c22SAlexei Fedorov /* Initialize delay timer driver using SP804 dual timer 0 */ 4721b597c22SAlexei Fedorov sp804_timer_init(V2M_SP804_TIMER0_BASE, 4731b597c22SAlexei Fedorov SP804_TIMER_CLKMULT, SP804_TIMER_CLKDIV); 4741b597c22SAlexei Fedorov #else 4751b597c22SAlexei Fedorov generic_delay_timer_init(); 4761b597c22SAlexei Fedorov 4771b597c22SAlexei Fedorov /* Enable System level generic timer */ 4781b597c22SAlexei Fedorov mmio_write_32(ARM_SYS_CNTCTL_BASE + CNTCR_OFF, 4791b597c22SAlexei Fedorov CNTCR_FCREQ(0U) | CNTCR_EN); 480fddfb3baSMadhukar Pappireddy #endif /* USE_SP804_TIMER */ 4811b597c22SAlexei Fedorov } 482ed9653ffSManish V Badarkhe 483ed9653ffSManish V Badarkhe /***************************************************************************** 484ed9653ffSManish V Badarkhe * plat_is_smccc_feature_available() - This function checks whether SMCCC 485ed9653ffSManish V Badarkhe * feature is availabile for platform. 486ed9653ffSManish V Badarkhe * @fid: SMCCC function id 487ed9653ffSManish V Badarkhe * 488ed9653ffSManish V Badarkhe * Return SMC_ARCH_CALL_SUCCESS if SMCCC feature is available and 489ed9653ffSManish V Badarkhe * SMC_ARCH_CALL_NOT_SUPPORTED otherwise. 490ed9653ffSManish V Badarkhe *****************************************************************************/ 491ed9653ffSManish V Badarkhe int32_t plat_is_smccc_feature_available(u_register_t fid) 492ed9653ffSManish V Badarkhe { 493ed9653ffSManish V Badarkhe switch (fid) { 494ed9653ffSManish V Badarkhe case SMCCC_ARCH_SOC_ID: 495ed9653ffSManish V Badarkhe return SMC_ARCH_CALL_SUCCESS; 496ed9653ffSManish V Badarkhe default: 497ed9653ffSManish V Badarkhe return SMC_ARCH_CALL_NOT_SUPPORTED; 498ed9653ffSManish V Badarkhe } 499ed9653ffSManish V Badarkhe } 500ed9653ffSManish V Badarkhe 501ed9653ffSManish V Badarkhe /* Get SOC version */ 502ed9653ffSManish V Badarkhe int32_t plat_get_soc_version(void) 503ed9653ffSManish V Badarkhe { 504ed9653ffSManish V Badarkhe return (int32_t) 505dfff4686SYann Gautier (SOC_ID_SET_JEP_106(ARM_SOC_CONTINUATION_CODE, 506dfff4686SYann Gautier ARM_SOC_IDENTIFICATION_CODE) | 507dfff4686SYann Gautier (FVP_SOC_ID & SOC_ID_IMPL_DEF_MASK)); 508ed9653ffSManish V Badarkhe } 509ed9653ffSManish V Badarkhe 510ed9653ffSManish V Badarkhe /* Get SOC revision */ 511ed9653ffSManish V Badarkhe int32_t plat_get_soc_revision(void) 512ed9653ffSManish V Badarkhe { 513ed9653ffSManish V Badarkhe unsigned int sys_id; 514ed9653ffSManish V Badarkhe 515ed9653ffSManish V Badarkhe sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); 516dfff4686SYann Gautier return (int32_t)(((sys_id >> V2M_SYS_ID_REV_SHIFT) & 517dfff4686SYann Gautier V2M_SYS_ID_REV_MASK) & SOC_ID_REV_MASK); 518ed9653ffSManish V Badarkhe } 5198c980a4aSJavier Almansa Sobrino 5208c980a4aSJavier Almansa Sobrino #if ENABLE_RME 5218c980a4aSJavier Almansa Sobrino /* 5228c980a4aSJavier Almansa Sobrino * Get a pointer to the RMM-EL3 Shared buffer and return it 5238c980a4aSJavier Almansa Sobrino * through the pointer passed as parameter. 5248c980a4aSJavier Almansa Sobrino * 5258c980a4aSJavier Almansa Sobrino * This function returns the size of the shared buffer. 5268c980a4aSJavier Almansa Sobrino */ 5278c980a4aSJavier Almansa Sobrino size_t plat_rmmd_get_el3_rmm_shared_mem(uintptr_t *shared) 5288c980a4aSJavier Almansa Sobrino { 5298c980a4aSJavier Almansa Sobrino *shared = (uintptr_t)RMM_SHARED_BASE; 5308c980a4aSJavier Almansa Sobrino 5318c980a4aSJavier Almansa Sobrino return (size_t)RMM_SHARED_SIZE; 5328c980a4aSJavier Almansa Sobrino } 533*1d0ca40eSJavier Almansa Sobrino 534*1d0ca40eSJavier Almansa Sobrino int plat_rmmd_load_manifest(rmm_manifest_t *manifest) 535*1d0ca40eSJavier Almansa Sobrino { 536*1d0ca40eSJavier Almansa Sobrino assert(manifest != NULL); 537*1d0ca40eSJavier Almansa Sobrino 538*1d0ca40eSJavier Almansa Sobrino manifest->version = RMMD_MANIFEST_VERSION; 539*1d0ca40eSJavier Almansa Sobrino manifest->plat_data = (uintptr_t)NULL; 540*1d0ca40eSJavier Almansa Sobrino 541*1d0ca40eSJavier Almansa Sobrino return 0; 542*1d0ca40eSJavier Almansa Sobrino } 543*1d0ca40eSJavier Almansa Sobrino 5448c980a4aSJavier Almansa Sobrino #endif 545