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