blob: 2de11fd366175758f776cf04cf1ddec3975cfdd1 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -06002 * Copyright (c) 2018-2020, 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 "../juno_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 0xE0000000
36
37#define JUNO_DRAM1_BASE 0x80000000
38#define JUNO_DRAM2_BASE 0x880000000
39#define DRAM_BASE JUNO_DRAM1_BASE
40#define DRAM_SIZE 0x80000000
41
42/* Base address of non-trusted watchdog (SP805) */
43#define SP805_WDOG_BASE 0x1C0F0000
44
Madhukar Pappireddydd7db242021-08-05 14:14:15 -050045/* Base address of trusted watchdog (SP805) */
46#define SP805_TWDOG_BASE 0x2A4A0000
47#define IRQ_TWDOG_INTID 86
48
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020049/* Memory mapped Generic timer interfaces */
50#define SYS_CNT_BASE1 0x2a830000
51
52/* V2M motherboard system registers & offsets */
53#define VE_SYSREGS_BASE 0x1c010000
54#define V2M_SYS_LED 0x8
55
56/*******************************************************************************
57 * Base address and size of external NVM flash
58 ******************************************************************************/
59#define FLASH_BASE 0x08000000
60
61/*
62 * The flash chip on Juno is a SCSP package of 2-die's and of a total size of
63 * 512Mb, we are using only the main blocks of size 128KB for storing results.
64 * The SMC controller performs data striping and splits the word into half to
65 * each flash die's which leads to a virtual block size of 256KB to software.
66 */
67#define NOR_FLASH_BLOCK_SIZE 0x40000
68#define NOR_FLASH_BLOCKS_COUNT 255
69#define FLASH_SIZE (NOR_FLASH_BLOCK_SIZE * NOR_FLASH_BLOCKS_COUNT)
70
71/*******************************************************************************
72 * Base address and size for the FIP that contains FWU images.
73 ******************************************************************************/
74#define PLAT_ARM_FWU_FIP_BASE (FLASH_BASE + 0x400000)
75#define PLAT_ARM_FWU_FIP_SIZE (0x100000)
76
77/*******************************************************************************
Manish V Badarkheef507e42020-06-05 08:41:42 +010078 * This is the temporary DDR address for loading backup fip.bin
79 * image from NVM which is used for replacing original fip.bin
80 * This address is chosen such that the NS_BL2U can be expanded
81 * in future and also considering the large size of fip.bin.
82 ******************************************************************************/
83#define FIP_IMAGE_TMP_DDR_ADDRESS (DRAM_BASE + 0x100000)
84
85/*******************************************************************************
86 * This offset is used to corrupt data in fip.bin
87 * The offset is from the base where fip.bin is
88 * located in NVM. This particular value is chosen
89 * to make sure the corruption is done beyond fip header.
90 ******************************************************************************/
91#define FIP_CORRUPT_OFFSET (0x400)
92
93/*******************************************************************************
94 * This offset is used to corrupt data in fip.bin
95 * This is the base address for backup fip.bin image in NVM
96 * which is used for replacing original fip.bin
97 * This address is chosen such that it can stay with all
98 * the other images in the NVM.
99 ******************************************************************************/
100#define FIP_BKP_ADDRESS (FLASH_BASE + 0x1000000)
101
102/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200103 * Base address and size for non-trusted SRAM.
104 ******************************************************************************/
105#define NSRAM_BASE (0x2e000000)
106#define NSRAM_SIZE (0x00008000)
107
108/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200109 * NS_BL1U specific defines.
110 * NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we
111 * need 2 sets of addresses.
112 ******************************************************************************/
Ambroise Vincentee3e7cd2019-07-03 16:44:49 +0100113#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
114#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200115
116/*******************************************************************************
117 * Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is
118 * calculated using the current NS_BL1U RW debug size plus a little space
119 * for growth.
120 ******************************************************************************/
121#define NS_BL1U_RW_SIZE (0x7000)
122#define NS_BL1U_RW_BASE (NSRAM_BASE)
123#define NS_BL1U_RW_LIMIT (NS_BL1U_RW_BASE + NS_BL1U_RW_SIZE)
124
125/*******************************************************************************
126 * Base address and limit for NS_BL2U image.
127 ******************************************************************************/
128#define NS_BL2U_BASE DRAM_BASE
129#define NS_BL2U_LIMIT (NS_BL2U_BASE + 0x4D000)
130
131/*******************************************************************************
132 * Generic platform constants
133 ******************************************************************************/
134
135/* Size of cacheable stacks */
136#if IMAGE_NS_BL1U
137#define PLATFORM_STACK_SIZE 0x1000
138#elif IMAGE_NS_BL2U
139#define PLATFORM_STACK_SIZE 0x1000
140#elif IMAGE_TFTF
141#define PLATFORM_STACK_SIZE 0x1400
142#endif
143
144/* Size of coherent stacks for debug and release builds */
145#if DEBUG
146#define PCPU_DV_MEM_STACK_SIZE 0x600
147#else
148#define PCPU_DV_MEM_STACK_SIZE 0x500
149#endif
150
151#define PLATFORM_SYSTEM_COUNT 1
152#define PLATFORM_CLUSTER_COUNT 2
153#define PLATFORM_CLUSTER1_CORE_COUNT 4 /* Cortex-A53 Cluster */
154#define PLATFORM_CLUSTER0_CORE_COUNT 2 /* Cortex-A57 Cluster */
155#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
156 PLATFORM_CLUSTER0_CORE_COUNT)
157#define PLATFORM_NUM_AFFS (PLATFORM_SYSTEM_COUNT + \
158 PLATFORM_CLUSTER_COUNT + \
159 PLATFORM_CORE_COUNT)
160#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
161#define PLAT_MAX_PWR_LEVEL PLATFORM_MAX_AFFLVL
162#define PLAT_MAX_PWR_STATES_PER_LVL 2
163
164/* Local state bit width for each level in the state-ID field of power state */
165#define PLAT_LOCAL_PSTATE_WIDTH 4
166
167#if IMAGE_NS_BL1U
168#define MAX_IO_DEVICES 2
169#define MAX_IO_HANDLES 2
170#else
171#define MAX_IO_DEVICES 1
172#define MAX_IO_HANDLES 1
173#endif
174
175#if USE_NVM
176/*
177 * The Flash memory is used to store TFTF data on Juno.
178 * However, it might contain other data that must not be overwritten.
179 * For example, when using the Trusted Firmware-A, the FIP image
180 * (containing the bootloader images) is also stored in Flash.
181 * Hence, consider the first 40MB of Flash as reserved for firmware usage.
182 * The TFTF can use the rest of the Flash memory.
183 */
184#define TFTF_NVM_OFFSET 0x2800000 /* 40MB */
185#define TFTF_NVM_SIZE (FLASH_SIZE - TFTF_NVM_OFFSET)
186#else
187/*
188 * If you want to run without support for non-volatile memory (due to e.g.
189 * unavailability of a flash driver), DRAM can be used instead as workaround.
190 * The TFTF binary itself is loaded at 0xE0000000 so we have plenty of free
191 * memory at the beginning of the DRAM. Let's use the first 128MB.
192 *
193 * Please note that this won't be suitable for all test scenarios and
194 * for this reason some tests will be disabled in this configuration.
195 */
196#define TFTF_NVM_OFFSET 0x0
197#define TFTF_NVM_SIZE 0x8000000 /* 128 MB */
198#endif
199
200/*******************************************************************************
201 * Platform specific page table and MMU setup constants
202 ******************************************************************************/
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -0600203#ifdef __aarch64__
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100204#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 34)
205#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 34)
206#else
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000207#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
208#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100209#endif
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000210
211#if IMAGE_TFTF
212/* For testing xlat tables lib v2 */
213#define MAX_XLAT_TABLES 20
214#define MAX_MMAP_REGIONS 50
215#else
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200216#define MAX_XLAT_TABLES 5
217#define MAX_MMAP_REGIONS 16
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000218#endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200219
220/*******************************************************************************
221 * Used to align variables on the biggest cache line size in the platform.
222 * This is known only to the platform as it might have a combination of
223 * integrated and external caches.
224 ******************************************************************************/
225#define CACHE_WRITEBACK_SHIFT 6
226#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
227
228/*******************************************************************************
229 * Non-Secure Software Generated Interupts IDs
230 ******************************************************************************/
231#define IRQ_NS_SGI_0 0
232#define IRQ_NS_SGI_1 1
233#define IRQ_NS_SGI_2 2
234#define IRQ_NS_SGI_3 3
235#define IRQ_NS_SGI_4 4
236#define IRQ_NS_SGI_5 5
237#define IRQ_NS_SGI_6 6
238#define IRQ_NS_SGI_7 7
239
240#define PLAT_MAX_SPI_OFFSET_ID 220
241
242/* The IRQ generated by Ethernet controller */
243#define IRQ_ETHERNET 192
244
245#define IRQ_CNTPSIRQ1 92
246/* Per-CPU Hypervisor Timer Interrupt ID */
247#define IRQ_PCPU_HP_TIMER 26
248/* Per-CPU Non-Secure Timer Interrupt ID */
249#define IRQ_PCPU_NS_TIMER 30
250
251/*
252 * Times(in ms) used by test code for completion of different events.
253 * Suspend entry time for debug build is high due to the time taken
254 * by the VERBOSE/INFO prints. The value considers the worst case scenario
255 * where all CPUs are going and coming out of suspend continuously.
256 */
257#if DEBUG
258#define PLAT_SUSPEND_ENTRY_TIME 0x100
259#define PLAT_SUSPEND_ENTRY_EXIT_TIME 0x200
260#else
261#define PLAT_SUSPEND_ENTRY_TIME 10
262#define PLAT_SUSPEND_ENTRY_EXIT_TIME 20
263#endif
264
265#endif /* __PLATFORM_DEF_H__ */