xref: /rk3399_ARM-atf/plat/arm/board/fvp/fvp_common.c (revision e29efeb1b40a3ac364fc0bf1e15928b400a57e72)
13e4b8fdcSSoby Mathew /*
2955242d8SJeenu Viswambharan  * Copyright (c) 2013-2017, 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>
9*e29efeb1SAntonio Nino Diaz #include <arm_spm_def.h>
10955242d8SJeenu Viswambharan #include <assert.h>
11955242d8SJeenu Viswambharan #include <cci.h>
1271237876SSoby Mathew #include <ccn.h>
133e4b8fdcSSoby Mathew #include <debug.h>
143e4b8fdcSSoby Mathew #include <gicv2.h>
153e4b8fdcSSoby Mathew #include <mmio.h>
163e4b8fdcSSoby Mathew #include <plat_arm.h>
17*e29efeb1SAntonio Nino Diaz #include <secure_partition.h>
183e4b8fdcSSoby Mathew #include <v2m_def.h>
193e4b8fdcSSoby Mathew #include "../fvp_def.h"
203e4b8fdcSSoby Mathew 
213e4b8fdcSSoby Mathew /* Defines for GIC Driver build time selection */
223e4b8fdcSSoby Mathew #define FVP_GICV2		1
233e4b8fdcSSoby Mathew #define FVP_GICV3		2
243e4b8fdcSSoby Mathew #define FVP_GICV3_LEGACY	3
253e4b8fdcSSoby Mathew 
263e4b8fdcSSoby Mathew /*******************************************************************************
273e4b8fdcSSoby Mathew  * arm_config holds the characteristics of the differences between the three FVP
283e4b8fdcSSoby Mathew  * platforms (Base, A53_A57 & Foundation). It will be populated during cold boot
293e4b8fdcSSoby Mathew  * at each boot stage by the primary before enabling the MMU (to allow
303e4b8fdcSSoby Mathew  * interconnect configuration) & used thereafter. Each BL will have its own copy
313e4b8fdcSSoby Mathew  * to allow independent operation.
323e4b8fdcSSoby Mathew  ******************************************************************************/
333e4b8fdcSSoby Mathew arm_config_t arm_config;
343e4b8fdcSSoby Mathew 
353e4b8fdcSSoby Mathew #define MAP_DEVICE0	MAP_REGION_FLAT(DEVICE0_BASE,			\
363e4b8fdcSSoby Mathew 					DEVICE0_SIZE,			\
373e4b8fdcSSoby Mathew 					MT_DEVICE | MT_RW | MT_SECURE)
383e4b8fdcSSoby Mathew 
393e4b8fdcSSoby Mathew #define MAP_DEVICE1	MAP_REGION_FLAT(DEVICE1_BASE,			\
403e4b8fdcSSoby Mathew 					DEVICE1_SIZE,			\
413e4b8fdcSSoby Mathew 					MT_DEVICE | MT_RW | MT_SECURE)
423e4b8fdcSSoby Mathew 
43284c3d67SSandrine Bailleux /*
44284c3d67SSandrine Bailleux  * Need to be mapped with write permissions in order to set a new non-volatile
45284c3d67SSandrine Bailleux  * counter value.
46284c3d67SSandrine Bailleux  */
473e4b8fdcSSoby Mathew #define MAP_DEVICE2	MAP_REGION_FLAT(DEVICE2_BASE,			\
483e4b8fdcSSoby Mathew 					DEVICE2_SIZE,			\
49fe7de035SAntonio Nino Diaz 					MT_DEVICE | MT_RW | MT_SECURE)
503e4b8fdcSSoby Mathew 
513e4b8fdcSSoby Mathew 
523e4b8fdcSSoby Mathew /*
53b5fa6563SSandrine Bailleux  * Table of memory regions for various BL stages to map using the MMU.
54b5fa6563SSandrine Bailleux  * This doesn't include Trusted SRAM as arm_setup_page_tables() already
55b5fa6563SSandrine Bailleux  * takes care of mapping it.
5691fad655SSandrine Bailleux  *
5791fad655SSandrine Bailleux  * The flash needs to be mapped as writable in order to erase the FIP's Table of
5891fad655SSandrine Bailleux  * Contents in case of unrecoverable error (see plat_error_handler()).
593e4b8fdcSSoby Mathew  */
603d8256b2SMasahiro Yamada #ifdef IMAGE_BL1
613e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = {
623e4b8fdcSSoby Mathew 	ARM_MAP_SHARED_RAM,
633e4b8fdcSSoby Mathew 	V2M_MAP_FLASH0_RW,
643e4b8fdcSSoby Mathew 	V2M_MAP_IOFPGA,
653e4b8fdcSSoby Mathew 	MAP_DEVICE0,
663e4b8fdcSSoby Mathew 	MAP_DEVICE1,
673e4b8fdcSSoby Mathew #if TRUSTED_BOARD_BOOT
68284c3d67SSandrine Bailleux 	/* To access the Root of Trust Public Key registers. */
69284c3d67SSandrine Bailleux 	MAP_DEVICE2,
70284c3d67SSandrine Bailleux 	/* Map DRAM to authenticate NS_BL2U image. */
713e4b8fdcSSoby Mathew 	ARM_MAP_NS_DRAM1,
723e4b8fdcSSoby Mathew #endif
733e4b8fdcSSoby Mathew 	{0}
743e4b8fdcSSoby Mathew };
753e4b8fdcSSoby Mathew #endif
763d8256b2SMasahiro Yamada #ifdef IMAGE_BL2
773e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = {
783e4b8fdcSSoby Mathew 	ARM_MAP_SHARED_RAM,
793e4b8fdcSSoby Mathew 	V2M_MAP_FLASH0_RW,
803e4b8fdcSSoby Mathew 	V2M_MAP_IOFPGA,
813e4b8fdcSSoby Mathew 	MAP_DEVICE0,
823e4b8fdcSSoby Mathew 	MAP_DEVICE1,
833e4b8fdcSSoby Mathew 	ARM_MAP_NS_DRAM1,
84b09ba056SRoberto Vargas #ifdef AARCH64
85b09ba056SRoberto Vargas 	ARM_MAP_DRAM2,
86b09ba056SRoberto Vargas #endif
873eb2d672SSandrine Bailleux #ifdef SPD_tspd
883e4b8fdcSSoby Mathew 	ARM_MAP_TSP_SEC_MEM,
893eb2d672SSandrine Bailleux #endif
90284c3d67SSandrine Bailleux #if TRUSTED_BOARD_BOOT
91284c3d67SSandrine Bailleux 	/* To access the Root of Trust Public Key registers. */
92284c3d67SSandrine Bailleux 	MAP_DEVICE2,
93284c3d67SSandrine Bailleux #endif
94*e29efeb1SAntonio Nino Diaz #if ENABLE_SPM
95*e29efeb1SAntonio Nino Diaz 	ARM_SP_IMAGE_MMAP,
96*e29efeb1SAntonio Nino Diaz #endif
973e4b8fdcSSoby Mathew #if ARM_BL31_IN_DRAM
983e4b8fdcSSoby Mathew 	ARM_MAP_BL31_SEC_DRAM,
993e4b8fdcSSoby Mathew #endif
100810d9213SJens Wiklander #ifdef SPD_opteed
101b3ba6fdaSSoby Mathew 	ARM_MAP_OPTEE_CORE_MEM,
102810d9213SJens Wiklander 	ARM_OPTEE_PAGEABLE_LOAD_MEM,
103810d9213SJens Wiklander #endif
1043e4b8fdcSSoby Mathew 	{0}
1053e4b8fdcSSoby Mathew };
1063e4b8fdcSSoby Mathew #endif
1073d8256b2SMasahiro Yamada #ifdef IMAGE_BL2U
1083e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = {
1093e4b8fdcSSoby Mathew 	MAP_DEVICE0,
1103e4b8fdcSSoby Mathew 	V2M_MAP_IOFPGA,
1113e4b8fdcSSoby Mathew 	{0}
1123e4b8fdcSSoby Mathew };
1133e4b8fdcSSoby Mathew #endif
1143d8256b2SMasahiro Yamada #ifdef IMAGE_BL31
1153e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = {
1163e4b8fdcSSoby Mathew 	ARM_MAP_SHARED_RAM,
117e35a3fb5SSoby Mathew 	ARM_MAP_EL3_TZC_DRAM,
1183e4b8fdcSSoby Mathew 	V2M_MAP_IOFPGA,
1193e4b8fdcSSoby Mathew 	MAP_DEVICE0,
1203e4b8fdcSSoby Mathew 	MAP_DEVICE1,
121f145403cSRoberto Vargas 	ARM_V2M_MAP_MEM_PROTECT,
122*e29efeb1SAntonio Nino Diaz #if ENABLE_SPM
123*e29efeb1SAntonio Nino Diaz 	ARM_SPM_BUF_EL3_MMAP,
124*e29efeb1SAntonio Nino Diaz #endif
1253e4b8fdcSSoby Mathew 	{0}
1263e4b8fdcSSoby Mathew };
127*e29efeb1SAntonio Nino Diaz 
128*e29efeb1SAntonio Nino Diaz #if ENABLE_SPM && defined(IMAGE_BL31)
129*e29efeb1SAntonio Nino Diaz const mmap_region_t plat_arm_secure_partition_mmap[] = {
130*e29efeb1SAntonio Nino Diaz 	V2M_MAP_IOFPGA_EL0, /* for the UART */
131*e29efeb1SAntonio Nino Diaz 	ARM_SP_IMAGE_MMAP,
132*e29efeb1SAntonio Nino Diaz 	ARM_SP_IMAGE_NS_BUF_MMAP,
133*e29efeb1SAntonio Nino Diaz 	ARM_SP_IMAGE_RW_MMAP,
134*e29efeb1SAntonio Nino Diaz 	ARM_SPM_BUF_EL0_MMAP,
135*e29efeb1SAntonio Nino Diaz 	{0}
136*e29efeb1SAntonio Nino Diaz };
137*e29efeb1SAntonio Nino Diaz #endif
1383e4b8fdcSSoby Mathew #endif
1393d8256b2SMasahiro Yamada #ifdef IMAGE_BL32
1403e4b8fdcSSoby Mathew const mmap_region_t plat_arm_mmap[] = {
141877cf3ffSSoby Mathew #ifdef AARCH32
142877cf3ffSSoby Mathew 	ARM_MAP_SHARED_RAM,
143877cf3ffSSoby Mathew #endif
1443e4b8fdcSSoby Mathew 	V2M_MAP_IOFPGA,
1453e4b8fdcSSoby Mathew 	MAP_DEVICE0,
1463e4b8fdcSSoby Mathew 	MAP_DEVICE1,
1473e4b8fdcSSoby Mathew 	{0}
1483e4b8fdcSSoby Mathew };
1493e4b8fdcSSoby Mathew #endif
1503e4b8fdcSSoby Mathew 
1513e4b8fdcSSoby Mathew ARM_CASSERT_MMAP
1523e4b8fdcSSoby Mathew 
153955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER != FVP_CCN
154955242d8SJeenu Viswambharan static const int fvp_cci400_map[] = {
155955242d8SJeenu Viswambharan 	PLAT_FVP_CCI400_CLUS0_SL_PORT,
156955242d8SJeenu Viswambharan 	PLAT_FVP_CCI400_CLUS1_SL_PORT,
157955242d8SJeenu Viswambharan };
158955242d8SJeenu Viswambharan 
159955242d8SJeenu Viswambharan static const int fvp_cci5xx_map[] = {
160955242d8SJeenu Viswambharan 	PLAT_FVP_CCI5XX_CLUS0_SL_PORT,
161955242d8SJeenu Viswambharan 	PLAT_FVP_CCI5XX_CLUS1_SL_PORT,
162955242d8SJeenu Viswambharan };
163955242d8SJeenu Viswambharan 
164955242d8SJeenu Viswambharan static unsigned int get_interconnect_master(void)
165955242d8SJeenu Viswambharan {
166955242d8SJeenu Viswambharan 	unsigned int master;
167955242d8SJeenu Viswambharan 	u_register_t mpidr;
168955242d8SJeenu Viswambharan 
169955242d8SJeenu Viswambharan 	mpidr = read_mpidr_el1();
170955242d8SJeenu Viswambharan 	master = (arm_config.flags & ARM_CONFIG_FVP_SHIFTED_AFF) ?
171955242d8SJeenu Viswambharan 		MPIDR_AFFLVL2_VAL(mpidr) : MPIDR_AFFLVL1_VAL(mpidr);
172955242d8SJeenu Viswambharan 
173955242d8SJeenu Viswambharan 	assert(master < FVP_CLUSTER_COUNT);
174955242d8SJeenu Viswambharan 	return master;
175955242d8SJeenu Viswambharan }
176955242d8SJeenu Viswambharan #endif
1773e4b8fdcSSoby Mathew 
178*e29efeb1SAntonio Nino Diaz #if ENABLE_SPM && defined(IMAGE_BL31)
179*e29efeb1SAntonio Nino Diaz /*
180*e29efeb1SAntonio Nino Diaz  * Boot information passed to a secure partition during initialisation. Linear
181*e29efeb1SAntonio Nino Diaz  * indices in MP information will be filled at runtime.
182*e29efeb1SAntonio Nino Diaz  */
183*e29efeb1SAntonio Nino Diaz static secure_partition_mp_info_t sp_mp_info[] = {
184*e29efeb1SAntonio Nino Diaz 	[0] = {0x80000000, 0},
185*e29efeb1SAntonio Nino Diaz 	[1] = {0x80000001, 0},
186*e29efeb1SAntonio Nino Diaz 	[2] = {0x80000002, 0},
187*e29efeb1SAntonio Nino Diaz 	[3] = {0x80000003, 0},
188*e29efeb1SAntonio Nino Diaz 	[4] = {0x80000100, 0},
189*e29efeb1SAntonio Nino Diaz 	[5] = {0x80000101, 0},
190*e29efeb1SAntonio Nino Diaz 	[6] = {0x80000102, 0},
191*e29efeb1SAntonio Nino Diaz 	[7] = {0x80000103, 0},
192*e29efeb1SAntonio Nino Diaz };
193*e29efeb1SAntonio Nino Diaz 
194*e29efeb1SAntonio Nino Diaz const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = {
195*e29efeb1SAntonio Nino Diaz 	.h.type              = PARAM_SP_IMAGE_BOOT_INFO,
196*e29efeb1SAntonio Nino Diaz 	.h.version           = VERSION_1,
197*e29efeb1SAntonio Nino Diaz 	.h.size              = sizeof(secure_partition_boot_info_t),
198*e29efeb1SAntonio Nino Diaz 	.h.attr              = 0,
199*e29efeb1SAntonio Nino Diaz 	.sp_mem_base         = ARM_SP_IMAGE_BASE,
200*e29efeb1SAntonio Nino Diaz 	.sp_mem_limit        = ARM_SP_IMAGE_LIMIT,
201*e29efeb1SAntonio Nino Diaz 	.sp_image_base       = ARM_SP_IMAGE_BASE,
202*e29efeb1SAntonio Nino Diaz 	.sp_stack_base       = PLAT_SP_IMAGE_STACK_BASE,
203*e29efeb1SAntonio Nino Diaz 	.sp_heap_base        = ARM_SP_IMAGE_HEAP_BASE,
204*e29efeb1SAntonio Nino Diaz 	.sp_ns_comm_buf_base = ARM_SP_IMAGE_NS_BUF_BASE,
205*e29efeb1SAntonio Nino Diaz 	.sp_shared_buf_base  = PLAT_SPM_BUF_BASE,
206*e29efeb1SAntonio Nino Diaz 	.sp_image_size       = ARM_SP_IMAGE_SIZE,
207*e29efeb1SAntonio Nino Diaz 	.sp_pcpu_stack_size  = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
208*e29efeb1SAntonio Nino Diaz 	.sp_heap_size        = ARM_SP_IMAGE_HEAP_SIZE,
209*e29efeb1SAntonio Nino Diaz 	.sp_ns_comm_buf_size = ARM_SP_IMAGE_NS_BUF_SIZE,
210*e29efeb1SAntonio Nino Diaz 	.sp_shared_buf_size  = PLAT_SPM_BUF_SIZE,
211*e29efeb1SAntonio Nino Diaz 	.num_sp_mem_regions  = ARM_SP_IMAGE_NUM_MEM_REGIONS,
212*e29efeb1SAntonio Nino Diaz 	.num_cpus            = PLATFORM_CORE_COUNT,
213*e29efeb1SAntonio Nino Diaz 	.mp_info             = &sp_mp_info[0],
214*e29efeb1SAntonio Nino Diaz };
215*e29efeb1SAntonio Nino Diaz 
216*e29efeb1SAntonio Nino Diaz const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
217*e29efeb1SAntonio Nino Diaz {
218*e29efeb1SAntonio Nino Diaz 	return plat_arm_secure_partition_mmap;
219*e29efeb1SAntonio Nino Diaz }
220*e29efeb1SAntonio Nino Diaz 
221*e29efeb1SAntonio Nino Diaz const struct secure_partition_boot_info *plat_get_secure_partition_boot_info(
222*e29efeb1SAntonio Nino Diaz 		void *cookie)
223*e29efeb1SAntonio Nino Diaz {
224*e29efeb1SAntonio Nino Diaz 	return &plat_arm_secure_partition_boot_info;
225*e29efeb1SAntonio Nino Diaz }
226*e29efeb1SAntonio Nino Diaz 
227*e29efeb1SAntonio Nino Diaz #endif
228*e29efeb1SAntonio Nino Diaz 
2293e4b8fdcSSoby Mathew /*******************************************************************************
2303e4b8fdcSSoby Mathew  * A single boot loader stack is expected to work on both the Foundation FVP
2313e4b8fdcSSoby Mathew  * models and the two flavours of the Base FVP models (AEMv8 & Cortex). The
2323e4b8fdcSSoby Mathew  * SYS_ID register provides a mechanism for detecting the differences between
2333e4b8fdcSSoby Mathew  * these platforms. This information is stored in a per-BL array to allow the
2343e4b8fdcSSoby Mathew  * code to take the correct path.Per BL platform configuration.
2353e4b8fdcSSoby Mathew  ******************************************************************************/
2363e4b8fdcSSoby Mathew void fvp_config_setup(void)
2373e4b8fdcSSoby Mathew {
2383e4b8fdcSSoby Mathew 	unsigned int rev, hbi, bld, arch, sys_id;
2393e4b8fdcSSoby Mathew 
2403e4b8fdcSSoby Mathew 	sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID);
2413e4b8fdcSSoby Mathew 	rev = (sys_id >> V2M_SYS_ID_REV_SHIFT) & V2M_SYS_ID_REV_MASK;
2423e4b8fdcSSoby Mathew 	hbi = (sys_id >> V2M_SYS_ID_HBI_SHIFT) & V2M_SYS_ID_HBI_MASK;
2433e4b8fdcSSoby Mathew 	bld = (sys_id >> V2M_SYS_ID_BLD_SHIFT) & V2M_SYS_ID_BLD_MASK;
2443e4b8fdcSSoby Mathew 	arch = (sys_id >> V2M_SYS_ID_ARCH_SHIFT) & V2M_SYS_ID_ARCH_MASK;
2453e4b8fdcSSoby Mathew 
2463e4b8fdcSSoby Mathew 	if (arch != ARCH_MODEL) {
2473e4b8fdcSSoby Mathew 		ERROR("This firmware is for FVP models\n");
2483e4b8fdcSSoby Mathew 		panic();
2493e4b8fdcSSoby Mathew 	}
2503e4b8fdcSSoby Mathew 
2513e4b8fdcSSoby Mathew 	/*
2523e4b8fdcSSoby Mathew 	 * The build field in the SYS_ID tells which variant of the GIC
2533e4b8fdcSSoby Mathew 	 * memory is implemented by the model.
2543e4b8fdcSSoby Mathew 	 */
2553e4b8fdcSSoby Mathew 	switch (bld) {
2563e4b8fdcSSoby Mathew 	case BLD_GIC_VE_MMAP:
25721a3973dSSoby Mathew 		ERROR("Legacy Versatile Express memory map for GIC peripheral"
25821a3973dSSoby Mathew 				" is not supported\n");
2593e4b8fdcSSoby Mathew 		panic();
2603e4b8fdcSSoby Mathew 		break;
2613e4b8fdcSSoby Mathew 	case BLD_GIC_A53A57_MMAP:
2623e4b8fdcSSoby Mathew 		break;
2633e4b8fdcSSoby Mathew 	default:
2643e4b8fdcSSoby Mathew 		ERROR("Unsupported board build %x\n", bld);
2653e4b8fdcSSoby Mathew 		panic();
2663e4b8fdcSSoby Mathew 	}
2673e4b8fdcSSoby Mathew 
2683e4b8fdcSSoby Mathew 	/*
2693e4b8fdcSSoby Mathew 	 * The hbi field in the SYS_ID is 0x020 for the Base FVP & 0x010
2703e4b8fdcSSoby Mathew 	 * for the Foundation FVP.
2713e4b8fdcSSoby Mathew 	 */
2723e4b8fdcSSoby Mathew 	switch (hbi) {
2733e4b8fdcSSoby Mathew 	case HBI_FOUNDATION_FVP:
2743e4b8fdcSSoby Mathew 		arm_config.flags = 0;
2753e4b8fdcSSoby Mathew 
2763e4b8fdcSSoby Mathew 		/*
2773e4b8fdcSSoby Mathew 		 * Check for supported revisions of Foundation FVP
2783e4b8fdcSSoby Mathew 		 * Allow future revisions to run but emit warning diagnostic
2793e4b8fdcSSoby Mathew 		 */
2803e4b8fdcSSoby Mathew 		switch (rev) {
2813e4b8fdcSSoby Mathew 		case REV_FOUNDATION_FVP_V2_0:
2823e4b8fdcSSoby Mathew 		case REV_FOUNDATION_FVP_V2_1:
2833e4b8fdcSSoby Mathew 		case REV_FOUNDATION_FVP_v9_1:
2844faa4a1dSSandrine Bailleux 		case REV_FOUNDATION_FVP_v9_6:
2853e4b8fdcSSoby Mathew 			break;
2863e4b8fdcSSoby Mathew 		default:
2873e4b8fdcSSoby Mathew 			WARN("Unrecognized Foundation FVP revision %x\n", rev);
2883e4b8fdcSSoby Mathew 			break;
2893e4b8fdcSSoby Mathew 		}
2903e4b8fdcSSoby Mathew 		break;
2913e4b8fdcSSoby Mathew 	case HBI_BASE_FVP:
292955242d8SJeenu Viswambharan 		arm_config.flags |= (ARM_CONFIG_BASE_MMAP | ARM_CONFIG_HAS_TZC);
2933e4b8fdcSSoby Mathew 
2943e4b8fdcSSoby Mathew 		/*
2953e4b8fdcSSoby Mathew 		 * Check for supported revisions
2963e4b8fdcSSoby Mathew 		 * Allow future revisions to run but emit warning diagnostic
2973e4b8fdcSSoby Mathew 		 */
2983e4b8fdcSSoby Mathew 		switch (rev) {
2993e4b8fdcSSoby Mathew 		case REV_BASE_FVP_V0:
300955242d8SJeenu Viswambharan 			arm_config.flags |= ARM_CONFIG_FVP_HAS_CCI400;
301955242d8SJeenu Viswambharan 			break;
302955242d8SJeenu Viswambharan 		case REV_BASE_FVP_REVC:
3038431635bSIsla Mitchell 			arm_config.flags |= (ARM_CONFIG_FVP_HAS_SMMUV3 |
304955242d8SJeenu Viswambharan 					ARM_CONFIG_FVP_HAS_CCI5XX);
3053e4b8fdcSSoby Mathew 			break;
3063e4b8fdcSSoby Mathew 		default:
3073e4b8fdcSSoby Mathew 			WARN("Unrecognized Base FVP revision %x\n", rev);
3083e4b8fdcSSoby Mathew 			break;
3093e4b8fdcSSoby Mathew 		}
3103e4b8fdcSSoby Mathew 		break;
3113e4b8fdcSSoby Mathew 	default:
3123e4b8fdcSSoby Mathew 		ERROR("Unsupported board HBI number 0x%x\n", hbi);
3133e4b8fdcSSoby Mathew 		panic();
3143e4b8fdcSSoby Mathew 	}
3158431635bSIsla Mitchell 
3168431635bSIsla Mitchell 	/*
3178431635bSIsla Mitchell 	 * We assume that the presence of MT bit, and therefore shifted
3188431635bSIsla Mitchell 	 * affinities, is uniform across the platform: either all CPUs, or no
3198431635bSIsla Mitchell 	 * CPUs implement it.
3208431635bSIsla Mitchell 	 */
3218431635bSIsla Mitchell 	if (read_mpidr_el1() & MPIDR_MT_MASK)
3228431635bSIsla Mitchell 		arm_config.flags |= ARM_CONFIG_FVP_SHIFTED_AFF;
3233e4b8fdcSSoby Mathew }
3243e4b8fdcSSoby Mathew 
3253e4b8fdcSSoby Mathew 
3263e4b8fdcSSoby Mathew void fvp_interconnect_init(void)
3273e4b8fdcSSoby Mathew {
32871237876SSoby Mathew #if FVP_INTERCONNECT_DRIVER == FVP_CCN
32971237876SSoby Mathew 	if (ccn_get_part0_id(PLAT_ARM_CCN_BASE) != CCN_502_PART0_ID) {
33071237876SSoby Mathew 		ERROR("Unrecognized CCN variant detected. Only CCN-502"
33171237876SSoby Mathew 				" is supported");
33271237876SSoby Mathew 		panic();
33371237876SSoby Mathew 	}
334955242d8SJeenu Viswambharan 
3353e4b8fdcSSoby Mathew 	plat_arm_interconnect_init();
336955242d8SJeenu Viswambharan #else
337955242d8SJeenu Viswambharan 	uintptr_t cci_base = 0;
338955242d8SJeenu Viswambharan 	const int *cci_map = 0;
339955242d8SJeenu Viswambharan 	unsigned int map_size = 0;
340955242d8SJeenu Viswambharan 
341955242d8SJeenu Viswambharan 	if (!(arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 |
342955242d8SJeenu Viswambharan 				ARM_CONFIG_FVP_HAS_CCI5XX))) {
343955242d8SJeenu Viswambharan 		return;
3443e4b8fdcSSoby Mathew 	}
345955242d8SJeenu Viswambharan 
346955242d8SJeenu Viswambharan 	/* Initialize the right interconnect */
347955242d8SJeenu Viswambharan 	if (arm_config.flags & ARM_CONFIG_FVP_HAS_CCI5XX) {
348955242d8SJeenu Viswambharan 		cci_base = PLAT_FVP_CCI5XX_BASE;
349955242d8SJeenu Viswambharan 		cci_map = fvp_cci5xx_map;
350955242d8SJeenu Viswambharan 		map_size = ARRAY_SIZE(fvp_cci5xx_map);
351955242d8SJeenu Viswambharan 	} else if (arm_config.flags & ARM_CONFIG_FVP_HAS_CCI400) {
352955242d8SJeenu Viswambharan 		cci_base = PLAT_FVP_CCI400_BASE;
353955242d8SJeenu Viswambharan 		cci_map = fvp_cci400_map;
354955242d8SJeenu Viswambharan 		map_size = ARRAY_SIZE(fvp_cci400_map);
355955242d8SJeenu Viswambharan 	}
356955242d8SJeenu Viswambharan 
357955242d8SJeenu Viswambharan 	assert(cci_base);
358955242d8SJeenu Viswambharan 	assert(cci_map);
359955242d8SJeenu Viswambharan 	cci_init(cci_base, cci_map, map_size);
360955242d8SJeenu Viswambharan #endif
36171237876SSoby Mathew }
3623e4b8fdcSSoby Mathew 
3633e4b8fdcSSoby Mathew void fvp_interconnect_enable(void)
3643e4b8fdcSSoby Mathew {
365955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN
3663e4b8fdcSSoby Mathew 	plat_arm_interconnect_enter_coherency();
367955242d8SJeenu Viswambharan #else
368955242d8SJeenu Viswambharan 	unsigned int master;
369955242d8SJeenu Viswambharan 
370955242d8SJeenu Viswambharan 	if (arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 |
371955242d8SJeenu Viswambharan 				ARM_CONFIG_FVP_HAS_CCI5XX)) {
372955242d8SJeenu Viswambharan 		master = get_interconnect_master();
373955242d8SJeenu Viswambharan 		cci_enable_snoop_dvm_reqs(master);
374955242d8SJeenu Viswambharan 	}
375955242d8SJeenu Viswambharan #endif
3763e4b8fdcSSoby Mathew }
3773e4b8fdcSSoby Mathew 
3783e4b8fdcSSoby Mathew void fvp_interconnect_disable(void)
3793e4b8fdcSSoby Mathew {
380955242d8SJeenu Viswambharan #if FVP_INTERCONNECT_DRIVER == FVP_CCN
3813e4b8fdcSSoby Mathew 	plat_arm_interconnect_exit_coherency();
382955242d8SJeenu Viswambharan #else
383955242d8SJeenu Viswambharan 	unsigned int master;
384955242d8SJeenu Viswambharan 
385955242d8SJeenu Viswambharan 	if (arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 |
386955242d8SJeenu Viswambharan 				ARM_CONFIG_FVP_HAS_CCI5XX)) {
387955242d8SJeenu Viswambharan 		master = get_interconnect_master();
388955242d8SJeenu Viswambharan 		cci_disable_snoop_dvm_reqs(master);
389955242d8SJeenu Viswambharan 	}
390955242d8SJeenu Viswambharan #endif
3913e4b8fdcSSoby Mathew }
392