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