blob: 3afc9b8bb1929649dd9863f6054dcf9642f7bff4 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Madhukar Pappireddy172523b2020-12-31 19:25:33 -06002 * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
Antonio Nino Diaz54959b02019-03-29 12:59:35 +00008#include <utils_def.h>
9
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020010#include "../fvp_def.h"
11
12/*******************************************************************************
13 * Platform definitions used by common code
14 ******************************************************************************/
15
16#ifndef __PLATFORM_DEF_H__
17#define __PLATFORM_DEF_H__
18
19/*******************************************************************************
20 * Platform binary types for linking
21 ******************************************************************************/
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -060022#ifdef __aarch64__
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020023#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
24#define PLATFORM_LINKER_ARCH aarch64
25#else
26#define PLATFORM_LINKER_FORMAT "elf32-littlearm"
27#define PLATFORM_LINKER_ARCH arm
28#endif
29
30/*******************************************************************************
31 * Run-time address of the TFTF image.
32 * It has to match the location where the Trusted Firmware-A loads the BL33
33 * image.
34 ******************************************************************************/
35#define TFTF_BASE 0x88000000
36
37/* Base address of non-trusted watchdog (SP805) */
38#define SP805_WDOG_BASE 0x1C0F0000
39
40/*******************************************************************************
41 * Base address and size of external NVM flash
42 ******************************************************************************/
43#define FLASH_BASE 0x08000000
44
45/*
46 * The flash memory in FVP resembles as a SCSP package of 2-die's and
47 * of a total size of 512Mb, we are using only the main blocks of size
48 * 128KB for storing results. Also the FVP performs data striping and
49 * splits the word into half to each flash die's which leads to a
50 * virtual block size of 256KB to software.
51 */
52#define NOR_FLASH_BLOCK_SIZE 0x40000 /* 256KB */
53#define NOR_FLASH_BLOCKS_COUNT 255
54#define FLASH_SIZE (NOR_FLASH_BLOCK_SIZE * NOR_FLASH_BLOCKS_COUNT)
55
56/*******************************************************************************
57 * Base address and size for the FIP that contains FWU images.
58 ******************************************************************************/
59#define PLAT_ARM_FWU_FIP_BASE (FLASH_BASE + 0x400000)
60#define PLAT_ARM_FWU_FIP_SIZE (0x100000)
61
62/*******************************************************************************
Manish V Badarkheef507e42020-06-05 08:41:42 +010063 * This is the temporary DDR address for loading backup fip.bin
64 * image from NVM which is used for replacing original fip.bin
65 * This address is chosen such that the NS_BL2U can be expanded
66 * in future and also considering the large size of fip.bin.
67 ******************************************************************************/
68#define FIP_IMAGE_TMP_DDR_ADDRESS (DRAM_BASE + 0x100000)
69
70/*******************************************************************************
71 * This offset is used to corrupt data in fip.bin
72 * The offset is from the base where fip.bin is
73 * located in NVM. This particular value is chosen
74 * to make sure the corruption is done beyond fip header.
75 ******************************************************************************/
76#define FIP_CORRUPT_OFFSET (0x400)
77
78/*******************************************************************************
79 * This offset is used to corrupt data in fip.bin
80 * This is the base address for backup fip.bin image in NVM
81 * which is used for replacing original fip.bin
82 * This address is chosen such that it can stay with all
83 * the other images in the NVM.
84 ******************************************************************************/
85#define FIP_BKP_ADDRESS (FLASH_BASE + 0x1000000)
86
87/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020088 * Base address and size for non-trusted SRAM.
89 ******************************************************************************/
90#define NSRAM_BASE (0x2e000000)
91#define NSRAM_SIZE (0x00010000)
92
93/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020094 * NS_BL1U specific defines.
95 * NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we
96 * need 2 sets of addresses.
97 ******************************************************************************/
Ambroise Vincentee3e7cd2019-07-03 16:44:49 +010098#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
99#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200100
101/*******************************************************************************
102 * Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is
103 * calculated using the current NS_BL1U RW debug size plus a little space
104 * for growth.
105 ******************************************************************************/
106#define NS_BL1U_RW_SIZE (0x7000)
107#define NS_BL1U_RW_BASE (NSRAM_BASE)
108#define NS_BL1U_RW_LIMIT (NS_BL1U_RW_BASE + NS_BL1U_RW_SIZE)
109
110/*******************************************************************************
111 * Platform memory map related constants
112 ******************************************************************************/
113#define FVP_DRAM1_BASE 0x80000000
114#define FVP_DRAM2_BASE 0x880000000
115#define DRAM_BASE FVP_DRAM1_BASE
116#define DRAM_SIZE 0x80000000
117
118/*******************************************************************************
119 * Base address and limit for NS_BL2U image.
120 ******************************************************************************/
121#define NS_BL2U_BASE DRAM_BASE
122#define NS_BL2U_LIMIT (NS_BL2U_BASE + 0x4D000)
123
124/******************************************************************************
125 * Memory mapped Generic timer interfaces
126 ******************************************************************************/
127/* REFCLK CNTControl, Generic Timer. Secure Access only. */
128#define SYS_CNT_CONTROL_BASE 0x2a430000
129/* REFCLK CNTRead, Generic Timer. */
130#define SYS_CNT_READ_BASE 0x2a800000
131/* AP_REFCLK CNTBase1, Generic Timer. */
132#define SYS_CNT_BASE1 0x2a830000
133
134/* V2M motherboard system registers & offsets */
135#define VE_SYSREGS_BASE 0x1c010000
136#define V2M_SYS_LED 0x8
137
138/*******************************************************************************
139 * Generic platform constants
140 ******************************************************************************/
141
142/* Size of cacheable stacks */
143#if IMAGE_NS_BL1U || IMAGE_NS_BL2U
144#define PLATFORM_STACK_SIZE 0x1000
145#else
146#define PLATFORM_STACK_SIZE 0x1400
147#endif
148
149/* Size of coherent stacks for debug and release builds */
150#if DEBUG
151#define PCPU_DV_MEM_STACK_SIZE 0x600
152#else
153#define PCPU_DV_MEM_STACK_SIZE 0x500
154#endif
155
156#define PLATFORM_CORE_COUNT (FVP_CLUSTER_COUNT * \
Imre Kis8da87ad2019-12-17 17:41:34 +0100157 FVP_MAX_CPUS_PER_CLUSTER * \
158 FVP_MAX_PE_PER_CPU)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200159#define PLATFORM_NUM_AFFS (1 + FVP_CLUSTER_COUNT + \
160 PLATFORM_CORE_COUNT)
161#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
162
Javier Almansa Sobrino109d5c12020-09-04 12:52:23 +0100163#define PLAT_MAX_PE_PER_CPU FVP_MAX_PE_PER_CPU
164
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200165/* TODO : Migrate complete TFTF from affinity level to power levels */
166#define PLAT_MAX_PWR_LEVEL PLATFORM_MAX_AFFLVL
167#define PLAT_MAX_PWR_STATES_PER_LVL 2
168
169#if IMAGE_NS_BL1U
170#define MAX_IO_DEVICES 2
171#define MAX_IO_HANDLES 2
172#else
173#define MAX_IO_DEVICES 1
174#define MAX_IO_HANDLES 1
175#endif
176
177/* Local state bit width for each level in the state-ID field of power state */
178#define PLAT_LOCAL_PSTATE_WIDTH 4
179
180#if USE_NVM
181/*
182 * The Flash memory is used to store the TFTF data on FVP.
183 * However, it might contain other data that must not be overwritten.
184 * For example, when using the Trusted Firmware-A, the FIP image
185 * (containing the bootloader images) is also stored in Flash.
186 * Hence, consider the first 40MB of Flash as reserved for firmware usage.
187 * The TFTF can use the rest of the Flash memory.
188 */
189#define TFTF_NVM_OFFSET 0x2800000 /* 40 MB */
190#define TFTF_NVM_SIZE (FLASH_SIZE - TFTF_NVM_OFFSET)
191#else
192/*
193 * If you want to run without support for non-volatile memory (due to
194 * e.g. unavailability of a flash driver), DRAM can be used instead as
195 * a workaround. The TFTF binary itself is loaded at 0x88000000 so the
196 * first 128MB can be used
197 * Please note that this won't be suitable for all test scenarios and
198 * for this reason some tests will be disabled in this configuration.
199 */
200#define TFTF_NVM_OFFSET 0x0
201#define TFTF_NVM_SIZE (TFTF_BASE - DRAM_BASE - TFTF_NVM_OFFSET)
202#endif
203
204/*******************************************************************************
205 * Platform specific page table and MMU setup constants
206 ******************************************************************************/
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -0600207#ifdef __aarch64__
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100208#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 34)
209#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 34)
210#else
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000211#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
212#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100213#endif
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000214
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200215#if IMAGE_TFTF
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000216/* For testing xlat tables lib v2 */
217#define MAX_XLAT_TABLES 20
218#define MAX_MMAP_REGIONS 50
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200219#else
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600220#if IMAGE_CACTUS
221#define MAX_XLAT_TABLES 6
222#else
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200223#define MAX_XLAT_TABLES 5
Madhukar Pappireddy172523b2020-12-31 19:25:33 -0600224#endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200225#define MAX_MMAP_REGIONS 16
226#endif
227
228/*******************************************************************************
229 * Used to align variables on the biggest cache line size in the platform.
230 * This is known only to the platform as it might have a combination of
231 * integrated and external caches.
232 ******************************************************************************/
233#define CACHE_WRITEBACK_SHIFT 6
234#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
235
236/*******************************************************************************
237 * Non-Secure Software Generated Interupts IDs
238 ******************************************************************************/
239#define IRQ_NS_SGI_0 0
240#define IRQ_NS_SGI_1 1
241#define IRQ_NS_SGI_2 2
242#define IRQ_NS_SGI_3 3
243#define IRQ_NS_SGI_4 4
244#define IRQ_NS_SGI_5 5
245#define IRQ_NS_SGI_6 6
246#define IRQ_NS_SGI_7 7
247
248/*
249 * On FVP, consider that the last SPI is the Trusted Random Number Generator
250 * interrupt.
251 */
252#define PLAT_MAX_SPI_OFFSET_ID 107
253
254/* AP_REFCLK, Generic Timer, CNTPSIRQ1. */
255#define IRQ_CNTPSIRQ1 58
256/* Per-CPU Hypervisor Timer Interrupt ID */
257#define IRQ_PCPU_HP_TIMER 26
258/* Per-CPU Non-Secure Timer Interrupt ID */
259#define IRQ_PCPU_NS_TIMER 30
260
261
262/* Times(in ms) used by test code for completion of different events */
263#define PLAT_SUSPEND_ENTRY_TIME 15
264#define PLAT_SUSPEND_ENTRY_EXIT_TIME 30
265
Antonio Nino Diazf2218e72019-03-19 10:59:11 +0000266/*******************************************************************************
267 * Location of the memory buffer shared between Normal World (i.e. TFTF) and the
268 * Secure Partition (e.g. Cactus-MM) to pass data associated to secure service
269 * requests. This is only needed for SPM based on MM.
270 * Note: This address has to match the one used in TF (see ARM_SP_IMAGE_NS_BUF_*
271 * macros).
272 ******************************************************************************/
273#define ARM_SECURE_SERVICE_BUFFER_BASE 0xff600000ull
274#define ARM_SECURE_SERVICE_BUFFER_SIZE 0x10000ull
275
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200276#endif /* __PLATFORM_DEF_H__ */