Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2013-2021, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | |
| 9 | #include <common/debug.h> |
| 10 | #include <drivers/arm/cci.h> |
| 11 | #include <drivers/arm/ccn.h> |
| 12 | #include <drivers/arm/gicv2.h> |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 13 | #include <drivers/arm/sp804_delay_timer.h> |
| 14 | #include <drivers/generic_delay_timer.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 15 | #include <lib/mmio.h> |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 16 | #include <lib/smccc.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 17 | #include <lib/xlat_tables/xlat_tables_compat.h> |
Antonio Nino Diaz | 234bc7f | 2019-01-15 14:19:50 +0000 | [diff] [blame] | 18 | #include <platform_def.h> |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 19 | #include <services/arm_arch_svc.h> |
Olivier Deprez | 9d9ae97 | 2020-07-30 17:18:33 +0200 | [diff] [blame] | 20 | #if SPM_MM |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 21 | #include <services/spm_mm_partition.h> |
Olivier Deprez | 9d9ae97 | 2020-07-30 17:18:33 +0200 | [diff] [blame] | 22 | #endif |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 23 | |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 24 | #include <plat/arm/common/arm_config.h> |
| 25 | #include <plat/arm/common/plat_arm.h> |
| 26 | #include <plat/common/platform.h> |
| 27 | |
Roberto Vargas | 1af540e | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 28 | #include "fvp_private.h" |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 29 | |
Achin Gupta | 27573c5 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 30 | /* Defines for GIC Driver build time selection */ |
| 31 | #define FVP_GICV2 1 |
| 32 | #define FVP_GICV3 2 |
Achin Gupta | 27573c5 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 33 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 34 | /******************************************************************************* |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 35 | * arm_config holds the characteristics of the differences between the three FVP |
| 36 | * platforms (Base, A53_A57 & Foundation). It will be populated during cold boot |
Vikram Kanigiri | 6355f23 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 37 | * at each boot stage by the primary before enabling the MMU (to allow |
| 38 | * interconnect configuration) & used thereafter. Each BL will have its own copy |
| 39 | * to allow independent operation. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 40 | ******************************************************************************/ |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 41 | arm_config_t arm_config; |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 42 | |
| 43 | #define MAP_DEVICE0 MAP_REGION_FLAT(DEVICE0_BASE, \ |
| 44 | DEVICE0_SIZE, \ |
| 45 | MT_DEVICE | MT_RW | MT_SECURE) |
| 46 | |
| 47 | #define MAP_DEVICE1 MAP_REGION_FLAT(DEVICE1_BASE, \ |
| 48 | DEVICE1_SIZE, \ |
| 49 | MT_DEVICE | MT_RW | MT_SECURE) |
| 50 | |
Sandrine Bailleux | 284c3d6 | 2017-05-26 15:48:10 +0100 | [diff] [blame] | 51 | /* |
| 52 | * Need to be mapped with write permissions in order to set a new non-volatile |
| 53 | * counter value. |
| 54 | */ |
Juan Castillo | 95cfd4a | 2015-04-14 12:49:03 +0100 | [diff] [blame] | 55 | #define MAP_DEVICE2 MAP_REGION_FLAT(DEVICE2_BASE, \ |
| 56 | DEVICE2_SIZE, \ |
Antonio Nino Diaz | fe7de03 | 2016-05-20 14:14:16 +0100 | [diff] [blame] | 57 | MT_DEVICE | MT_RW | MT_SECURE) |
Juan Castillo | 95cfd4a | 2015-04-14 12:49:03 +0100 | [diff] [blame] | 58 | |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 59 | /* |
Sandrine Bailleux | b5fa656 | 2016-05-18 16:11:47 +0100 | [diff] [blame] | 60 | * Table of memory regions for various BL stages to map using the MMU. |
Roberto Vargas | 0916c38 | 2018-10-19 16:44:18 +0100 | [diff] [blame] | 61 | * This doesn't include Trusted SRAM as setup_page_tables() already takes care |
| 62 | * of mapping it. |
Sandrine Bailleux | 91fad65 | 2016-06-14 17:01:00 +0100 | [diff] [blame] | 63 | * |
| 64 | * The flash needs to be mapped as writable in order to erase the FIP's Table of |
| 65 | * Contents in case of unrecoverable error (see plat_error_handler()). |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 66 | */ |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 67 | #ifdef IMAGE_BL1 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 68 | const mmap_region_t plat_arm_mmap[] = { |
| 69 | ARM_MAP_SHARED_RAM, |
Juan Castillo | 7b4c140 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 70 | V2M_MAP_FLASH0_RW, |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 71 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 72 | MAP_DEVICE0, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame^] | 73 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 74 | MAP_DEVICE1, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame^] | 75 | #endif |
Yatharth Kochar | 436223d | 2015-10-11 14:14:55 +0100 | [diff] [blame] | 76 | #if TRUSTED_BOARD_BOOT |
Sandrine Bailleux | 284c3d6 | 2017-05-26 15:48:10 +0100 | [diff] [blame] | 77 | /* To access the Root of Trust Public Key registers. */ |
| 78 | MAP_DEVICE2, |
| 79 | /* Map DRAM to authenticate NS_BL2U image. */ |
Yatharth Kochar | 436223d | 2015-10-11 14:14:55 +0100 | [diff] [blame] | 80 | ARM_MAP_NS_DRAM1, |
| 81 | #endif |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 82 | {0} |
| 83 | }; |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 84 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 85 | #ifdef IMAGE_BL2 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 86 | const mmap_region_t plat_arm_mmap[] = { |
| 87 | ARM_MAP_SHARED_RAM, |
Juan Castillo | 7b4c140 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 88 | V2M_MAP_FLASH0_RW, |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 89 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 90 | MAP_DEVICE0, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame^] | 91 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 92 | MAP_DEVICE1, |
Manish V Badarkhe | e0cea78 | 2021-01-23 10:55:12 +0000 | [diff] [blame^] | 93 | #endif |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 94 | ARM_MAP_NS_DRAM1, |
Julius Werner | 402b3cf | 2019-07-09 14:02:43 -0700 | [diff] [blame] | 95 | #ifdef __aarch64__ |
Roberto Vargas | b09ba05 | 2017-08-08 11:27:20 +0100 | [diff] [blame] | 96 | ARM_MAP_DRAM2, |
| 97 | #endif |
Achin Gupta | 64758c9 | 2019-10-11 15:15:19 +0100 | [diff] [blame] | 98 | #if defined(SPD_spmd) |
| 99 | ARM_MAP_TRUSTED_DRAM, |
| 100 | #endif |
Sandrine Bailleux | 3eb2d67 | 2017-08-30 10:59:22 +0100 | [diff] [blame] | 101 | #ifdef SPD_tspd |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 102 | ARM_MAP_TSP_SEC_MEM, |
Sandrine Bailleux | 3eb2d67 | 2017-08-30 10:59:22 +0100 | [diff] [blame] | 103 | #endif |
Sandrine Bailleux | 284c3d6 | 2017-05-26 15:48:10 +0100 | [diff] [blame] | 104 | #if TRUSTED_BOARD_BOOT |
| 105 | /* To access the Root of Trust Public Key registers. */ |
| 106 | MAP_DEVICE2, |
Antonio Nino Diaz | 60e19f5 | 2018-09-25 11:37:23 +0100 | [diff] [blame] | 107 | #if !BL2_AT_EL3 |
John Tsichritzis | ba597da | 2018-07-30 13:41:52 +0100 | [diff] [blame] | 108 | ARM_MAP_BL1_RW, |
Antonio Nino Diaz | 60e19f5 | 2018-09-25 11:37:23 +0100 | [diff] [blame] | 109 | #endif |
John Tsichritzis | ba597da | 2018-07-30 13:41:52 +0100 | [diff] [blame] | 110 | #endif /* TRUSTED_BOARD_BOOT */ |
Paul Beesley | 3f3c341 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 111 | #if SPM_MM |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 112 | ARM_SP_IMAGE_MMAP, |
| 113 | #endif |
David Wang | 4518dd9 | 2016-03-07 11:02:57 +0800 | [diff] [blame] | 114 | #if ARM_BL31_IN_DRAM |
| 115 | ARM_MAP_BL31_SEC_DRAM, |
| 116 | #endif |
Jens Wiklander | 810d921 | 2017-08-25 10:07:20 +0200 | [diff] [blame] | 117 | #ifdef SPD_opteed |
Soby Mathew | b3ba6fd | 2017-09-01 13:43:50 +0100 | [diff] [blame] | 118 | ARM_MAP_OPTEE_CORE_MEM, |
Jens Wiklander | 810d921 | 2017-08-25 10:07:20 +0200 | [diff] [blame] | 119 | ARM_OPTEE_PAGEABLE_LOAD_MEM, |
| 120 | #endif |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 121 | {0} |
| 122 | }; |
| 123 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 124 | #ifdef IMAGE_BL2U |
Yatharth Kochar | dcda29f | 2015-10-14 15:28:11 +0100 | [diff] [blame] | 125 | const mmap_region_t plat_arm_mmap[] = { |
| 126 | MAP_DEVICE0, |
| 127 | V2M_MAP_IOFPGA, |
| 128 | {0} |
| 129 | }; |
| 130 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 131 | #ifdef IMAGE_BL31 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 132 | const mmap_region_t plat_arm_mmap[] = { |
| 133 | ARM_MAP_SHARED_RAM, |
Ambroise Vincent | 992f091 | 2019-07-12 13:47:03 +0100 | [diff] [blame] | 134 | #if USE_DEBUGFS |
| 135 | /* Required by devfip, can be removed if devfip is not used */ |
| 136 | V2M_MAP_FLASH0_RW, |
| 137 | #endif /* USE_DEBUGFS */ |
Soby Mathew | e35a3fb | 2017-10-11 16:08:58 +0100 | [diff] [blame] | 138 | ARM_MAP_EL3_TZC_DRAM, |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 139 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 140 | MAP_DEVICE0, |
| 141 | MAP_DEVICE1, |
Roberto Vargas | f145403 | 2017-08-03 09:16:43 +0100 | [diff] [blame] | 142 | ARM_V2M_MAP_MEM_PROTECT, |
Paul Beesley | 3f3c341 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 143 | #if SPM_MM |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 144 | ARM_SPM_BUF_EL3_MMAP, |
| 145 | #endif |
Madhukar Pappireddy | 26d1e0c | 2020-01-27 13:37:51 -0600 | [diff] [blame] | 146 | /* Required by fconf APIs to read HW_CONFIG dtb loaded into DRAM */ |
Madhukar Pappireddy | 493545b | 2020-03-13 13:00:17 -0500 | [diff] [blame] | 147 | ARM_DTB_DRAM_NS, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 148 | {0} |
| 149 | }; |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 150 | |
Paul Beesley | 3f3c341 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 151 | #if defined(IMAGE_BL31) && SPM_MM |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 152 | const mmap_region_t plat_arm_secure_partition_mmap[] = { |
| 153 | V2M_MAP_IOFPGA_EL0, /* for the UART */ |
Sandrine Bailleux | c4fa173 | 2018-01-12 15:50:12 +0100 | [diff] [blame] | 154 | MAP_REGION_FLAT(DEVICE0_BASE, \ |
| 155 | DEVICE0_SIZE, \ |
| 156 | MT_DEVICE | MT_RO | MT_SECURE | MT_USER), |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 157 | ARM_SP_IMAGE_MMAP, |
| 158 | ARM_SP_IMAGE_NS_BUF_MMAP, |
| 159 | ARM_SP_IMAGE_RW_MMAP, |
| 160 | ARM_SPM_BUF_EL0_MMAP, |
| 161 | {0} |
| 162 | }; |
| 163 | #endif |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 164 | #endif |
Masahiro Yamada | 3d8256b | 2016-12-25 23:36:24 +0900 | [diff] [blame] | 165 | #ifdef IMAGE_BL32 |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 166 | const mmap_region_t plat_arm_mmap[] = { |
Julius Werner | 402b3cf | 2019-07-09 14:02:43 -0700 | [diff] [blame] | 167 | #ifndef __aarch64__ |
Soby Mathew | 877cf3f | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 168 | ARM_MAP_SHARED_RAM, |
Joel Hutton | 950c695 | 2018-03-15 11:33:44 +0000 | [diff] [blame] | 169 | ARM_V2M_MAP_MEM_PROTECT, |
Soby Mathew | 877cf3f | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 170 | #endif |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 171 | V2M_MAP_IOFPGA, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 172 | MAP_DEVICE0, |
| 173 | MAP_DEVICE1, |
Madhukar Pappireddy | 26d1e0c | 2020-01-27 13:37:51 -0600 | [diff] [blame] | 174 | /* Required by fconf APIs to read HW_CONFIG dtb loaded into DRAM */ |
Madhukar Pappireddy | 493545b | 2020-03-13 13:00:17 -0500 | [diff] [blame] | 175 | ARM_DTB_DRAM_NS, |
Soby Mathew | d0ecd97 | 2014-09-03 17:48:44 +0100 | [diff] [blame] | 176 | {0} |
| 177 | }; |
| 178 | #endif |
Jon Medhurst | 38aa76a | 2014-02-26 16:27:53 +0000 | [diff] [blame] | 179 | |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 180 | ARM_CASSERT_MMAP |
Soby Mathew | ce41250 | 2015-01-22 11:22:22 +0000 | [diff] [blame] | 181 | |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 182 | #if FVP_INTERCONNECT_DRIVER != FVP_CCN |
| 183 | static const int fvp_cci400_map[] = { |
| 184 | PLAT_FVP_CCI400_CLUS0_SL_PORT, |
| 185 | PLAT_FVP_CCI400_CLUS1_SL_PORT, |
| 186 | }; |
| 187 | |
| 188 | static const int fvp_cci5xx_map[] = { |
| 189 | PLAT_FVP_CCI5XX_CLUS0_SL_PORT, |
| 190 | PLAT_FVP_CCI5XX_CLUS1_SL_PORT, |
| 191 | }; |
| 192 | |
| 193 | static unsigned int get_interconnect_master(void) |
| 194 | { |
| 195 | unsigned int master; |
| 196 | u_register_t mpidr; |
| 197 | |
| 198 | mpidr = read_mpidr_el1(); |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 199 | master = ((arm_config.flags & ARM_CONFIG_FVP_SHIFTED_AFF) != 0U) ? |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 200 | MPIDR_AFFLVL2_VAL(mpidr) : MPIDR_AFFLVL1_VAL(mpidr); |
| 201 | |
| 202 | assert(master < FVP_CLUSTER_COUNT); |
| 203 | return master; |
| 204 | } |
| 205 | #endif |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 206 | |
Paul Beesley | 3f3c341 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 207 | #if defined(IMAGE_BL31) && SPM_MM |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 208 | /* |
| 209 | * Boot information passed to a secure partition during initialisation. Linear |
| 210 | * indices in MP information will be filled at runtime. |
| 211 | */ |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 212 | static spm_mm_mp_info_t sp_mp_info[] = { |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 213 | [0] = {0x80000000, 0}, |
| 214 | [1] = {0x80000001, 0}, |
| 215 | [2] = {0x80000002, 0}, |
| 216 | [3] = {0x80000003, 0}, |
| 217 | [4] = {0x80000100, 0}, |
| 218 | [5] = {0x80000101, 0}, |
| 219 | [6] = {0x80000102, 0}, |
| 220 | [7] = {0x80000103, 0}, |
| 221 | }; |
| 222 | |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 223 | const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 224 | .h.type = PARAM_SP_IMAGE_BOOT_INFO, |
| 225 | .h.version = VERSION_1, |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 226 | .h.size = sizeof(spm_mm_boot_info_t), |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 227 | .h.attr = 0, |
| 228 | .sp_mem_base = ARM_SP_IMAGE_BASE, |
| 229 | .sp_mem_limit = ARM_SP_IMAGE_LIMIT, |
| 230 | .sp_image_base = ARM_SP_IMAGE_BASE, |
| 231 | .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, |
| 232 | .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, |
Ard Biesheuvel | 0560efb | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 233 | .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE, |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 234 | .sp_shared_buf_base = PLAT_SPM_BUF_BASE, |
| 235 | .sp_image_size = ARM_SP_IMAGE_SIZE, |
| 236 | .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, |
| 237 | .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, |
Ard Biesheuvel | 0560efb | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 238 | .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE, |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 239 | .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, |
| 240 | .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, |
| 241 | .num_cpus = PLATFORM_CORE_COUNT, |
| 242 | .mp_info = &sp_mp_info[0], |
| 243 | }; |
| 244 | |
| 245 | const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) |
| 246 | { |
| 247 | return plat_arm_secure_partition_mmap; |
| 248 | } |
| 249 | |
Paul Beesley | aeaa225 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 250 | const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 251 | void *cookie) |
| 252 | { |
| 253 | return &plat_arm_secure_partition_boot_info; |
| 254 | } |
Antonio Nino Diaz | e29efeb | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 255 | #endif |
| 256 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 257 | /******************************************************************************* |
| 258 | * A single boot loader stack is expected to work on both the Foundation FVP |
| 259 | * models and the two flavours of the Base FVP models (AEMv8 & Cortex). The |
| 260 | * SYS_ID register provides a mechanism for detecting the differences between |
| 261 | * these platforms. This information is stored in a per-BL array to allow the |
| 262 | * code to take the correct path.Per BL platform configuration. |
| 263 | ******************************************************************************/ |
Daniel Boulby | 4d010d0 | 2018-09-18 13:26:03 +0100 | [diff] [blame] | 264 | void __init fvp_config_setup(void) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 265 | { |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 266 | unsigned int rev, hbi, bld, arch, sys_id; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 267 | |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 268 | sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); |
| 269 | rev = (sys_id >> V2M_SYS_ID_REV_SHIFT) & V2M_SYS_ID_REV_MASK; |
| 270 | hbi = (sys_id >> V2M_SYS_ID_HBI_SHIFT) & V2M_SYS_ID_HBI_MASK; |
| 271 | bld = (sys_id >> V2M_SYS_ID_BLD_SHIFT) & V2M_SYS_ID_BLD_MASK; |
| 272 | arch = (sys_id >> V2M_SYS_ID_ARCH_SHIFT) & V2M_SYS_ID_ARCH_MASK; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 273 | |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 274 | if (arch != ARCH_MODEL) { |
| 275 | ERROR("This firmware is for FVP models\n"); |
James Morrissey | 40a6f64 | 2014-02-10 14:24:36 +0000 | [diff] [blame] | 276 | panic(); |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 277 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 278 | |
| 279 | /* |
| 280 | * The build field in the SYS_ID tells which variant of the GIC |
| 281 | * memory is implemented by the model. |
| 282 | */ |
| 283 | switch (bld) { |
| 284 | case BLD_GIC_VE_MMAP: |
Soby Mathew | 21a3973 | 2016-01-13 17:06:00 +0000 | [diff] [blame] | 285 | ERROR("Legacy Versatile Express memory map for GIC peripheral" |
| 286 | " is not supported\n"); |
Achin Gupta | 27573c5 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 287 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 288 | break; |
| 289 | case BLD_GIC_A53A57_MMAP: |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 290 | break; |
| 291 | default: |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 292 | ERROR("Unsupported board build %x\n", bld); |
| 293 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | /* |
| 297 | * The hbi field in the SYS_ID is 0x020 for the Base FVP & 0x010 |
| 298 | * for the Foundation FVP. |
| 299 | */ |
| 300 | switch (hbi) { |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 301 | case HBI_FOUNDATION_FVP: |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 302 | arm_config.flags = 0; |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 303 | |
| 304 | /* |
| 305 | * Check for supported revisions of Foundation FVP |
| 306 | * Allow future revisions to run but emit warning diagnostic |
| 307 | */ |
| 308 | switch (rev) { |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 309 | case REV_FOUNDATION_FVP_V2_0: |
| 310 | case REV_FOUNDATION_FVP_V2_1: |
| 311 | case REV_FOUNDATION_FVP_v9_1: |
Sandrine Bailleux | 4faa4a1 | 2016-09-22 09:46:50 +0100 | [diff] [blame] | 312 | case REV_FOUNDATION_FVP_v9_6: |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 313 | break; |
| 314 | default: |
| 315 | WARN("Unrecognized Foundation FVP revision %x\n", rev); |
| 316 | break; |
| 317 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 318 | break; |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 319 | case HBI_BASE_FVP: |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 320 | arm_config.flags |= (ARM_CONFIG_BASE_MMAP | ARM_CONFIG_HAS_TZC); |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * Check for supported revisions |
| 324 | * Allow future revisions to run but emit warning diagnostic |
| 325 | */ |
| 326 | switch (rev) { |
Dan Handley | 60eea55 | 2015-03-19 19:17:53 +0000 | [diff] [blame] | 327 | case REV_BASE_FVP_V0: |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 328 | arm_config.flags |= ARM_CONFIG_FVP_HAS_CCI400; |
| 329 | break; |
| 330 | case REV_BASE_FVP_REVC: |
Isla Mitchell | 8431635 | 2017-08-17 12:25:34 +0100 | [diff] [blame] | 331 | arm_config.flags |= (ARM_CONFIG_FVP_HAS_SMMUV3 | |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 332 | ARM_CONFIG_FVP_HAS_CCI5XX); |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 333 | break; |
| 334 | default: |
| 335 | WARN("Unrecognized Base FVP revision %x\n", rev); |
| 336 | break; |
| 337 | } |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 338 | break; |
| 339 | default: |
Andrew Thoelke | 90e3147 | 2014-06-26 14:27:26 +0100 | [diff] [blame] | 340 | ERROR("Unsupported board HBI number 0x%x\n", hbi); |
| 341 | panic(); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 342 | } |
Isla Mitchell | 8431635 | 2017-08-17 12:25:34 +0100 | [diff] [blame] | 343 | |
| 344 | /* |
| 345 | * We assume that the presence of MT bit, and therefore shifted |
| 346 | * affinities, is uniform across the platform: either all CPUs, or no |
| 347 | * CPUs implement it. |
| 348 | */ |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 349 | if ((read_mpidr_el1() & MPIDR_MT_MASK) != 0U) |
Isla Mitchell | 8431635 | 2017-08-17 12:25:34 +0100 | [diff] [blame] | 350 | arm_config.flags |= ARM_CONFIG_FVP_SHIFTED_AFF; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 351 | } |
| 352 | |
Vikram Kanigiri | 4991ecd | 2015-02-26 15:25:58 +0000 | [diff] [blame] | 353 | |
Daniel Boulby | 4d010d0 | 2018-09-18 13:26:03 +0100 | [diff] [blame] | 354 | void __init fvp_interconnect_init(void) |
Vikram Kanigiri | dbad1ba | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 355 | { |
Soby Mathew | 7123787 | 2016-03-24 10:12:42 +0000 | [diff] [blame] | 356 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 357 | if (ccn_get_part0_id(PLAT_ARM_CCN_BASE) != CCN_502_PART0_ID) { |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 358 | ERROR("Unrecognized CCN variant detected. Only CCN-502 is supported"); |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 359 | panic(); |
Soby Mathew | 7123787 | 2016-03-24 10:12:42 +0000 | [diff] [blame] | 360 | } |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 361 | |
| 362 | plat_arm_interconnect_init(); |
| 363 | #else |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 364 | uintptr_t cci_base = 0U; |
| 365 | const int *cci_map = NULL; |
| 366 | unsigned int map_size = 0U; |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 367 | |
| 368 | /* Initialize the right interconnect */ |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 369 | if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI5XX) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 370 | cci_base = PLAT_FVP_CCI5XX_BASE; |
| 371 | cci_map = fvp_cci5xx_map; |
| 372 | map_size = ARRAY_SIZE(fvp_cci5xx_map); |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 373 | } else if ((arm_config.flags & ARM_CONFIG_FVP_HAS_CCI400) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 374 | cci_base = PLAT_FVP_CCI400_BASE; |
| 375 | cci_map = fvp_cci400_map; |
| 376 | map_size = ARRAY_SIZE(fvp_cci400_map); |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 377 | } else { |
| 378 | return; |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 379 | } |
| 380 | |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 381 | assert(cci_base != 0U); |
| 382 | assert(cci_map != NULL); |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 383 | cci_init(cci_base, cci_map, map_size); |
| 384 | #endif |
Dan Handley | cae3ef9 | 2014-08-04 16:11:15 +0100 | [diff] [blame] | 385 | } |
| 386 | |
Vikram Kanigiri | 6355f23 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 387 | void fvp_interconnect_enable(void) |
Dan Handley | cae3ef9 | 2014-08-04 16:11:15 +0100 | [diff] [blame] | 388 | { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 389 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
| 390 | plat_arm_interconnect_enter_coherency(); |
| 391 | #else |
| 392 | unsigned int master; |
| 393 | |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 394 | if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | |
| 395 | ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 396 | master = get_interconnect_master(); |
| 397 | cci_enable_snoop_dvm_reqs(master); |
| 398 | } |
| 399 | #endif |
Vikram Kanigiri | 4991ecd | 2015-02-26 15:25:58 +0000 | [diff] [blame] | 400 | } |
| 401 | |
Vikram Kanigiri | 6355f23 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 402 | void fvp_interconnect_disable(void) |
Vikram Kanigiri | 4991ecd | 2015-02-26 15:25:58 +0000 | [diff] [blame] | 403 | { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 404 | #if FVP_INTERCONNECT_DRIVER == FVP_CCN |
| 405 | plat_arm_interconnect_exit_coherency(); |
| 406 | #else |
| 407 | unsigned int master; |
| 408 | |
Antonio Nino Diaz | 583e079 | 2018-11-06 13:14:21 +0000 | [diff] [blame] | 409 | if ((arm_config.flags & (ARM_CONFIG_FVP_HAS_CCI400 | |
| 410 | ARM_CONFIG_FVP_HAS_CCI5XX)) != 0U) { |
Jeenu Viswambharan | 955242d | 2017-07-18 15:42:50 +0100 | [diff] [blame] | 411 | master = get_interconnect_master(); |
| 412 | cci_disable_snoop_dvm_reqs(master); |
| 413 | } |
| 414 | #endif |
Vikram Kanigiri | dbad1ba | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 415 | } |
John Tsichritzis | ba597da | 2018-07-30 13:41:52 +0100 | [diff] [blame] | 416 | |
Antonio Nino Diaz | 60e19f5 | 2018-09-25 11:37:23 +0100 | [diff] [blame] | 417 | #if TRUSTED_BOARD_BOOT |
John Tsichritzis | ba597da | 2018-07-30 13:41:52 +0100 | [diff] [blame] | 418 | int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) |
| 419 | { |
| 420 | assert(heap_addr != NULL); |
| 421 | assert(heap_size != NULL); |
| 422 | |
| 423 | return arm_get_mbedtls_heap(heap_addr, heap_size); |
| 424 | } |
| 425 | #endif |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 426 | |
| 427 | void fvp_timer_init(void) |
| 428 | { |
Madhukar Pappireddy | fddfb3b | 2020-08-12 13:18:19 -0500 | [diff] [blame] | 429 | #if USE_SP804_TIMER |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 430 | /* Enable the clock override for SP804 timer 0, which means that no |
| 431 | * clock dividers are applied and the raw (35MHz) clock will be used. |
| 432 | */ |
| 433 | mmio_write_32(V2M_SP810_BASE, FVP_SP810_CTRL_TIM0_OV); |
| 434 | |
| 435 | /* Initialize delay timer driver using SP804 dual timer 0 */ |
| 436 | sp804_timer_init(V2M_SP804_TIMER0_BASE, |
| 437 | SP804_TIMER_CLKMULT, SP804_TIMER_CLKDIV); |
| 438 | #else |
| 439 | generic_delay_timer_init(); |
| 440 | |
| 441 | /* Enable System level generic timer */ |
| 442 | mmio_write_32(ARM_SYS_CNTCTL_BASE + CNTCR_OFF, |
| 443 | CNTCR_FCREQ(0U) | CNTCR_EN); |
Madhukar Pappireddy | fddfb3b | 2020-08-12 13:18:19 -0500 | [diff] [blame] | 444 | #endif /* USE_SP804_TIMER */ |
Alexei Fedorov | 1b597c2 | 2019-08-16 14:15:59 +0100 | [diff] [blame] | 445 | } |
Manish V Badarkhe | ed9653f | 2020-08-04 17:09:10 +0100 | [diff] [blame] | 446 | |
| 447 | /***************************************************************************** |
| 448 | * plat_is_smccc_feature_available() - This function checks whether SMCCC |
| 449 | * feature is availabile for platform. |
| 450 | * @fid: SMCCC function id |
| 451 | * |
| 452 | * Return SMC_ARCH_CALL_SUCCESS if SMCCC feature is available and |
| 453 | * SMC_ARCH_CALL_NOT_SUPPORTED otherwise. |
| 454 | *****************************************************************************/ |
| 455 | int32_t plat_is_smccc_feature_available(u_register_t fid) |
| 456 | { |
| 457 | switch (fid) { |
| 458 | case SMCCC_ARCH_SOC_ID: |
| 459 | return SMC_ARCH_CALL_SUCCESS; |
| 460 | default: |
| 461 | return SMC_ARCH_CALL_NOT_SUPPORTED; |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | /* Get SOC version */ |
| 466 | int32_t plat_get_soc_version(void) |
| 467 | { |
| 468 | return (int32_t) |
| 469 | ((ARM_SOC_IDENTIFICATION_CODE << ARM_SOC_IDENTIFICATION_SHIFT) |
| 470 | | (ARM_SOC_CONTINUATION_CODE << ARM_SOC_CONTINUATION_SHIFT) |
| 471 | | FVP_SOC_ID); |
| 472 | } |
| 473 | |
| 474 | /* Get SOC revision */ |
| 475 | int32_t plat_get_soc_revision(void) |
| 476 | { |
| 477 | unsigned int sys_id; |
| 478 | |
| 479 | sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID); |
| 480 | return (int32_t)((sys_id >> V2M_SYS_ID_REV_SHIFT) & |
| 481 | V2M_SYS_ID_REV_MASK); |
| 482 | } |