Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Dan Handley | e83b0ca | 2014-01-14 18:17:09 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 31 | #include <arch.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 32 | #include <arch_helpers.h> |
Dan Handley | fb42b12 | 2014-06-20 09:43:15 +0100 | [diff] [blame] | 33 | #include <arm_gic.h> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 34 | #include <bl_common.h> |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 35 | #include <cci400.h> |
Dan Handley | 714a0d2 | 2014-04-09 13:13:04 +0100 | [diff] [blame] | 36 | #include <debug.h> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 37 | #include <mmio.h> |
Jon Medhurst | b1eb093 | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 38 | #include <platform.h> |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 39 | #include <platform_def.h> |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 40 | #include <plat_config.h> |
Jon Medhurst | b1eb093 | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 41 | #include <xlat_tables.h> |
Dan Handley | ed6ff95 | 2014-05-14 17:44:19 +0100 | [diff] [blame] | 42 | #include "../fvp_def.h" |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 43 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 44 | /******************************************************************************* |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 45 | * plat_config holds the characteristics of the differences between the three |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 46 | * FVP platforms (Base, A53_A57 & Foundation). It will be populated during cold |
| 47 | * boot at each boot stage by the primary before enabling the MMU (to allow cci |
| 48 | * configuration) & used thereafter. Each BL will have its own copy to allow |
| 49 | * independent operation. |
| 50 | ******************************************************************************/ |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 51 | plat_config_t plat_config; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 52 | |
Juan Castillo | 42a617d | 2014-09-24 10:00:06 +0100 | [diff] [blame] | 53 | #define MAP_SHARED_RAM MAP_REGION_FLAT(FVP_SHARED_MEM_BASE, \ |
| 54 | FVP_SHARED_MEM_SIZE, \ |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 55 | MT_MEMORY | MT_RW | MT_SECURE) |
| 56 | |
| 57 | #define MAP_FLASH0 MAP_REGION_FLAT(FLASH0_BASE, \ |
| 58 | FLASH0_SIZE, \ |
| 59 | MT_MEMORY | MT_RO | MT_SECURE) |
| 60 | |
| 61 | #define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \ |
| 62 | DEVICE0_SIZE, \ |
| 63 | MT_DEVICE | MT_RW | MT_SECURE) |
| 64 | |
| 65 | #define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \ |
| 66 | DEVICE1_SIZE, \ |
| 67 | MT_DEVICE | MT_RW | MT_SECURE) |
| 68 | |
Juan Castillo | f3e0218 | 2014-12-19 09:28:30 +0000 | [diff] [blame] | 69 | #define MAP_DRAM1_NS MAP_REGION_FLAT(DRAM1_NS_BASE, \ |
| 70 | DRAM1_NS_SIZE, \ |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 71 | MT_MEMORY | MT_RW | MT_NS) |
| 72 | |
| 73 | #define MAP_TSP_SEC_MEM MAP_REGION_FLAT(TSP_SEC_MEM_BASE, \ |
| 74 | TSP_SEC_MEM_SIZE, \ |
| 75 | MT_MEMORY | MT_RW | MT_SECURE) |
| 76 | |
Jon Medhurst | b1eb093 | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 77 | /* |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 78 | * Table of regions for various BL stages to map using the MMU. |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 79 | * This doesn't include TZRAM as the 'mem_layout' argument passed to |
| 80 | * configure_mmu_elx() will give the available subset of that, |
Jon Medhurst | b1eb093 | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 81 | */ |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 82 | #if IMAGE_BL1 |
| 83 | const mmap_region_t fvp_mmap[] = { |
| 84 | MAP_SHARED_RAM, |
| 85 | MAP_FLASH0, |
| 86 | MAP_DEVICE0, |
| 87 | MAP_DEVICE1, |
| 88 | {0} |
| 89 | }; |
| 90 | #endif |
| 91 | #if IMAGE_BL2 |
| 92 | const mmap_region_t fvp_mmap[] = { |
| 93 | MAP_SHARED_RAM, |
| 94 | MAP_FLASH0, |
| 95 | MAP_DEVICE0, |
| 96 | MAP_DEVICE1, |
Juan Castillo | f3e0218 | 2014-12-19 09:28:30 +0000 | [diff] [blame] | 97 | MAP_DRAM1_NS, |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 98 | MAP_TSP_SEC_MEM, |
| 99 | {0} |
| 100 | }; |
| 101 | #endif |
| 102 | #if IMAGE_BL31 |
| 103 | const mmap_region_t fvp_mmap[] = { |
| 104 | MAP_SHARED_RAM, |
| 105 | MAP_DEVICE0, |
| 106 | MAP_DEVICE1, |
| 107 | {0} |
| 108 | }; |
| 109 | #endif |
| 110 | #if IMAGE_BL32 |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 111 | const mmap_region_t fvp_mmap[] = { |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 112 | MAP_DEVICE0, |
| 113 | MAP_DEVICE1, |
Jon Medhurst | b1eb093 | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 114 | {0} |
| 115 | }; |
Soby Mathew | b08bc04 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 116 | #endif |
Jon Medhurst | b1eb093 | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 117 | |
Soby Mathew | 13ee968 | 2015-01-22 11:22:22 +0000 | [diff] [blame] | 118 | CASSERT((sizeof(fvp_mmap)/sizeof(fvp_mmap[0])) + FVP_BL_REGIONS \ |
| 119 | <= MAX_MMAP_REGIONS, assert_max_mmap_regions); |
| 120 | |
Dan Handley | fb42b12 | 2014-06-20 09:43:15 +0100 | [diff] [blame] | 121 | /* Array of secure interrupts to be configured by the gic driver */ |
| 122 | const unsigned int irq_sec_array[] = { |
| 123 | IRQ_TZ_WDOG, |
| 124 | IRQ_SEC_PHY_TIMER, |
| 125 | IRQ_SEC_SGI_0, |
| 126 | IRQ_SEC_SGI_1, |
| 127 | IRQ_SEC_SGI_2, |
| 128 | IRQ_SEC_SGI_3, |
| 129 | IRQ_SEC_SGI_4, |
| 130 | IRQ_SEC_SGI_5, |
| 131 | IRQ_SEC_SGI_6, |
| 132 | IRQ_SEC_SGI_7 |
| 133 | }; |
| 134 | |
| 135 | const unsigned int num_sec_irqs = sizeof(irq_sec_array) / |
| 136 | sizeof(irq_sec_array[0]); |
| 137 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 138 | /******************************************************************************* |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 139 | * Macro generating the code for the function setting up the pagetables as per |
| 140 | * the platform memory map & initialize the mmu, for the given exception level |
| 141 | ******************************************************************************/ |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 142 | #if USE_COHERENT_MEM |
| 143 | #define DEFINE_CONFIGURE_MMU_EL(_el) \ |
Lin Ma | 1359236 | 2014-06-02 11:45:36 -0700 | [diff] [blame] | 144 | void fvp_configure_mmu_el##_el(unsigned long total_base, \ |
Vikram Kanigiri | d8c9d26 | 2014-05-16 18:48:12 +0100 | [diff] [blame] | 145 | unsigned long total_size, \ |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 146 | unsigned long ro_start, \ |
| 147 | unsigned long ro_limit, \ |
| 148 | unsigned long coh_start, \ |
| 149 | unsigned long coh_limit) \ |
| 150 | { \ |
Lin Ma | 1359236 | 2014-06-02 11:45:36 -0700 | [diff] [blame] | 151 | mmap_add_region(total_base, total_base, \ |
Vikram Kanigiri | d8c9d26 | 2014-05-16 18:48:12 +0100 | [diff] [blame] | 152 | total_size, \ |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 153 | MT_MEMORY | MT_RW | MT_SECURE); \ |
Lin Ma | 1359236 | 2014-06-02 11:45:36 -0700 | [diff] [blame] | 154 | mmap_add_region(ro_start, ro_start, \ |
| 155 | ro_limit - ro_start, \ |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 156 | MT_MEMORY | MT_RO | MT_SECURE); \ |
Lin Ma | 1359236 | 2014-06-02 11:45:36 -0700 | [diff] [blame] | 157 | mmap_add_region(coh_start, coh_start, \ |
| 158 | coh_limit - coh_start, \ |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 159 | MT_DEVICE | MT_RW | MT_SECURE); \ |
| 160 | mmap_add(fvp_mmap); \ |
| 161 | init_xlat_tables(); \ |
| 162 | \ |
Achin Gupta | e998254 | 2014-06-26 08:59:07 +0100 | [diff] [blame] | 163 | enable_mmu_el##_el(0); \ |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 164 | } |
Soby Mathew | 2ae2043 | 2015-01-08 18:02:44 +0000 | [diff] [blame] | 165 | #else |
| 166 | #define DEFINE_CONFIGURE_MMU_EL(_el) \ |
| 167 | void fvp_configure_mmu_el##_el(unsigned long total_base, \ |
| 168 | unsigned long total_size, \ |
| 169 | unsigned long ro_start, \ |
| 170 | unsigned long ro_limit) \ |
| 171 | { \ |
| 172 | mmap_add_region(total_base, total_base, \ |
| 173 | total_size, \ |
| 174 | MT_MEMORY | MT_RW | MT_SECURE); \ |
| 175 | mmap_add_region(ro_start, ro_start, \ |
| 176 | ro_limit - ro_start, \ |
| 177 | MT_MEMORY | MT_RO | MT_SECURE); \ |
| 178 | mmap_add(fvp_mmap); \ |
| 179 | init_xlat_tables(); \ |
| 180 | \ |
| 181 | enable_mmu_el##_el(0); \ |
| 182 | } |
| 183 | #endif |
Sandrine Bailleux | 8d69a03 | 2013-11-27 09:38:52 +0000 | [diff] [blame] | 184 | |
Sandrine Bailleux | 74a62b3 | 2014-05-09 11:35:36 +0100 | [diff] [blame] | 185 | /* Define EL1 and EL3 variants of the function initialising the MMU */ |
| 186 | DEFINE_CONFIGURE_MMU_EL(1) |
| 187 | DEFINE_CONFIGURE_MMU_EL(3) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 188 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 189 | /******************************************************************************* |
| 190 | * A single boot loader stack is expected to work on both the Foundation FVP |
| 191 | * models and the two flavours of the Base FVP models (AEMv8 & Cortex). The |
| 192 | * SYS_ID register provides a mechanism for detecting the differences between |
| 193 | * these platforms. This information is stored in a per-BL array to allow the |
| 194 | * code to take the correct path.Per BL platform configuration. |
| 195 | ******************************************************************************/ |
Dan Handley | ea45157 | 2014-05-15 14:53:30 +0100 | [diff] [blame] | 196 | int fvp_config_setup(void) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 197 | { |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 198 | unsigned int rev, hbi, bld, arch, sys_id; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 199 | |
| 200 | sys_id = mmio_read_32(VE_SYSREGS_BASE + V2M_SYS_ID); |
| 201 | rev = (sys_id >> SYS_ID_REV_SHIFT) & SYS_ID_REV_MASK; |
| 202 | hbi = (sys_id >> SYS_ID_HBI_SHIFT) & SYS_ID_HBI_MASK; |
| 203 | bld = (sys_id >> SYS_ID_BLD_SHIFT) & SYS_ID_BLD_MASK; |
| 204 | arch = (sys_id >> SYS_ID_ARCH_SHIFT) & SYS_ID_ARCH_MASK; |
| 205 | |
Andrew Thoelke | 960347d | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 206 | if (arch != ARCH_MODEL) { |
| 207 | ERROR("This firmware is for FVP models\n"); |
James Morrissey | 40a6f64 | 2014-02-10 14:24:36 +0000 | [diff] [blame] | 208 | panic(); |
Andrew Thoelke | 960347d | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 209 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 210 | |
| 211 | /* |
| 212 | * The build field in the SYS_ID tells which variant of the GIC |
| 213 | * memory is implemented by the model. |
| 214 | */ |
| 215 | switch (bld) { |
| 216 | case BLD_GIC_VE_MMAP: |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 217 | plat_config.gicd_base = VE_GICD_BASE; |
| 218 | plat_config.gicc_base = VE_GICC_BASE; |
| 219 | plat_config.gich_base = VE_GICH_BASE; |
| 220 | plat_config.gicv_base = VE_GICV_BASE; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 221 | break; |
| 222 | case BLD_GIC_A53A57_MMAP: |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 223 | plat_config.gicd_base = BASE_GICD_BASE; |
| 224 | plat_config.gicc_base = BASE_GICC_BASE; |
| 225 | plat_config.gich_base = BASE_GICH_BASE; |
| 226 | plat_config.gicv_base = BASE_GICV_BASE; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 227 | break; |
| 228 | default: |
Andrew Thoelke | 960347d | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 229 | ERROR("Unsupported board build %x\n", bld); |
| 230 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /* |
| 234 | * The hbi field in the SYS_ID is 0x020 for the Base FVP & 0x010 |
| 235 | * for the Foundation FVP. |
| 236 | */ |
| 237 | switch (hbi) { |
| 238 | case HBI_FOUNDATION: |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 239 | plat_config.max_aff0 = 4; |
| 240 | plat_config.max_aff1 = 1; |
| 241 | plat_config.flags = 0; |
Andrew Thoelke | 960347d | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 242 | |
| 243 | /* |
| 244 | * Check for supported revisions of Foundation FVP |
| 245 | * Allow future revisions to run but emit warning diagnostic |
| 246 | */ |
| 247 | switch (rev) { |
| 248 | case REV_FOUNDATION_V2_0: |
| 249 | case REV_FOUNDATION_V2_1: |
| 250 | break; |
| 251 | default: |
| 252 | WARN("Unrecognized Foundation FVP revision %x\n", rev); |
| 253 | break; |
| 254 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 255 | break; |
| 256 | case HBI_FVP_BASE: |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 257 | plat_config.max_aff0 = 4; |
| 258 | plat_config.max_aff1 = 2; |
| 259 | plat_config.flags |= CONFIG_BASE_MMAP | CONFIG_HAS_CCI | |
| 260 | CONFIG_HAS_TZC; |
Andrew Thoelke | 960347d | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 261 | |
| 262 | /* |
| 263 | * Check for supported revisions |
| 264 | * Allow future revisions to run but emit warning diagnostic |
| 265 | */ |
| 266 | switch (rev) { |
| 267 | case REV_FVP_BASE_V0: |
| 268 | break; |
| 269 | default: |
| 270 | WARN("Unrecognized Base FVP revision %x\n", rev); |
| 271 | break; |
| 272 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 273 | break; |
| 274 | default: |
Andrew Thoelke | 960347d | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 275 | ERROR("Unsupported board HBI number 0x%x\n", hbi); |
| 276 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | return 0; |
| 280 | } |
| 281 | |
Ian Spray | 8468739 | 2014-01-02 16:57:12 +0000 | [diff] [blame] | 282 | unsigned long plat_get_ns_image_entrypoint(void) |
| 283 | { |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 284 | return NS_IMAGE_OFFSET; |
| 285 | } |
Sandrine Bailleux | 3fa9847 | 2014-03-31 11:25:18 +0100 | [diff] [blame] | 286 | |
| 287 | uint64_t plat_get_syscnt_freq(void) |
| 288 | { |
| 289 | uint64_t counter_base_frequency; |
| 290 | |
| 291 | /* Read the frequency from Frequency modes table */ |
| 292 | counter_base_frequency = mmio_read_32(SYS_CNTCTL_BASE + CNTFID_OFF); |
| 293 | |
| 294 | /* The first entry of the frequency modes table must not be 0 */ |
Juan Castillo | f558cac | 2014-06-05 09:45:36 +0100 | [diff] [blame] | 295 | if (counter_base_frequency == 0) |
| 296 | panic(); |
Sandrine Bailleux | 3fa9847 | 2014-03-31 11:25:18 +0100 | [diff] [blame] | 297 | |
| 298 | return counter_base_frequency; |
| 299 | } |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 300 | |
Dan Handley | be234f9 | 2014-08-04 16:11:15 +0100 | [diff] [blame] | 301 | void fvp_cci_init(void) |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 302 | { |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 303 | /* |
Dan Handley | be234f9 | 2014-08-04 16:11:15 +0100 | [diff] [blame] | 304 | * Initialize CCI-400 driver |
| 305 | */ |
| 306 | if (plat_config.flags & CONFIG_HAS_CCI) |
| 307 | cci_init(CCI400_BASE, |
| 308 | CCI400_SL_IFACE3_CLUSTER_IX, |
| 309 | CCI400_SL_IFACE4_CLUSTER_IX); |
| 310 | } |
| 311 | |
| 312 | void fvp_cci_enable(void) |
| 313 | { |
| 314 | /* |
| 315 | * Enable CCI-400 coherency for this cluster. No need |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 316 | * for locks as no other cpu is active at the |
| 317 | * moment |
| 318 | */ |
Dan Handley | 1c54d97 | 2014-06-20 12:02:01 +0100 | [diff] [blame] | 319 | if (plat_config.flags & CONFIG_HAS_CCI) |
Dan Handley | be234f9 | 2014-08-04 16:11:15 +0100 | [diff] [blame] | 320 | cci_enable_cluster_coherency(read_mpidr()); |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 321 | } |
| 322 | |
Dan Handley | fb42b12 | 2014-06-20 09:43:15 +0100 | [diff] [blame] | 323 | void fvp_gic_init(void) |
| 324 | { |
| 325 | arm_gic_init(plat_config.gicc_base, |
| 326 | plat_config.gicd_base, |
| 327 | BASE_GICR_BASE, |
| 328 | irq_sec_array, |
| 329 | num_sec_irqs); |
| 330 | } |
| 331 | |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 332 | |
| 333 | /******************************************************************************* |
Vikram Kanigiri | cf79bf5 | 2014-06-02 14:59:00 +0100 | [diff] [blame] | 334 | * Gets SPSR for BL32 entry |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 335 | ******************************************************************************/ |
Vikram Kanigiri | cf79bf5 | 2014-06-02 14:59:00 +0100 | [diff] [blame] | 336 | uint32_t fvp_get_spsr_for_bl32_entry(void) |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 337 | { |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 338 | /* |
| 339 | * The Secure Payload Dispatcher service is responsible for |
| 340 | * setting the SPSR prior to entry into the BL32 image. |
| 341 | */ |
Vikram Kanigiri | cf79bf5 | 2014-06-02 14:59:00 +0100 | [diff] [blame] | 342 | return 0; |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /******************************************************************************* |
Vikram Kanigiri | cf79bf5 | 2014-06-02 14:59:00 +0100 | [diff] [blame] | 346 | * Gets SPSR for BL33 entry |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 347 | ******************************************************************************/ |
Vikram Kanigiri | cf79bf5 | 2014-06-02 14:59:00 +0100 | [diff] [blame] | 348 | uint32_t fvp_get_spsr_for_bl33_entry(void) |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 349 | { |
| 350 | unsigned long el_status; |
| 351 | unsigned int mode; |
Vikram Kanigiri | cf79bf5 | 2014-06-02 14:59:00 +0100 | [diff] [blame] | 352 | uint32_t spsr; |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 353 | |
| 354 | /* Figure out what mode we enter the non-secure world in */ |
| 355 | el_status = read_id_aa64pfr0_el1() >> ID_AA64PFR0_EL2_SHIFT; |
| 356 | el_status &= ID_AA64PFR0_ELX_MASK; |
| 357 | |
| 358 | if (el_status) |
| 359 | mode = MODE_EL2; |
| 360 | else |
| 361 | mode = MODE_EL1; |
| 362 | |
| 363 | /* |
| 364 | * TODO: Consider the possibility of specifying the SPSR in |
| 365 | * the FIP ToC and allowing the platform to have a say as |
| 366 | * well. |
| 367 | */ |
Vikram Kanigiri | cf79bf5 | 2014-06-02 14:59:00 +0100 | [diff] [blame] | 368 | spsr = SPSR_64(mode, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS); |
| 369 | return spsr; |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 370 | } |