blob: 03a71246b6b3d2ae474ef44d5396b1a0f0c9a25b [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/*******************************************************************************
74 * Base address and size for non-trusted SRAM.
75 ******************************************************************************/
76#define NSRAM_BASE (0x2e000000)
77#define NSRAM_SIZE (0x00008000)
78
79/*******************************************************************************
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020080 * NS_BL1U specific defines.
81 * NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we
82 * need 2 sets of addresses.
83 ******************************************************************************/
Ambroise Vincentee3e7cd2019-07-03 16:44:49 +010084#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
85#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020086
87/*******************************************************************************
88 * Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is
89 * calculated using the current NS_BL1U RW debug size plus a little space
90 * for growth.
91 ******************************************************************************/
92#define NS_BL1U_RW_SIZE (0x7000)
93#define NS_BL1U_RW_BASE (NSRAM_BASE)
94#define NS_BL1U_RW_LIMIT (NS_BL1U_RW_BASE + NS_BL1U_RW_SIZE)
95
96/*******************************************************************************
97 * Base address and limit for NS_BL2U image.
98 ******************************************************************************/
99#define NS_BL2U_BASE DRAM_BASE
100#define NS_BL2U_LIMIT (NS_BL2U_BASE + 0x4D000)
101
102/*******************************************************************************
103 * Generic platform constants
104 ******************************************************************************/
105
106/* Size of cacheable stacks */
107#if IMAGE_NS_BL1U
108#define PLATFORM_STACK_SIZE 0x1000
109#elif IMAGE_NS_BL2U
110#define PLATFORM_STACK_SIZE 0x1000
111#elif IMAGE_TFTF
112#define PLATFORM_STACK_SIZE 0x1400
113#endif
114
115/* Size of coherent stacks for debug and release builds */
116#if DEBUG
117#define PCPU_DV_MEM_STACK_SIZE 0x600
118#else
119#define PCPU_DV_MEM_STACK_SIZE 0x500
120#endif
121
122#define PLATFORM_SYSTEM_COUNT 1
123#define PLATFORM_CLUSTER_COUNT 2
124#define PLATFORM_CLUSTER1_CORE_COUNT 4 /* Cortex-A53 Cluster */
125#define PLATFORM_CLUSTER0_CORE_COUNT 2 /* Cortex-A57 Cluster */
126#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
127 PLATFORM_CLUSTER0_CORE_COUNT)
128#define PLATFORM_NUM_AFFS (PLATFORM_SYSTEM_COUNT + \
129 PLATFORM_CLUSTER_COUNT + \
130 PLATFORM_CORE_COUNT)
131#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
132#define PLAT_MAX_PWR_LEVEL PLATFORM_MAX_AFFLVL
133#define PLAT_MAX_PWR_STATES_PER_LVL 2
134
135/* Local state bit width for each level in the state-ID field of power state */
136#define PLAT_LOCAL_PSTATE_WIDTH 4
137
138#if IMAGE_NS_BL1U
139#define MAX_IO_DEVICES 2
140#define MAX_IO_HANDLES 2
141#else
142#define MAX_IO_DEVICES 1
143#define MAX_IO_HANDLES 1
144#endif
145
146#if USE_NVM
147/*
148 * The Flash memory is used to store TFTF data on Juno.
149 * However, it might contain other data that must not be overwritten.
150 * For example, when using the Trusted Firmware-A, the FIP image
151 * (containing the bootloader images) is also stored in Flash.
152 * Hence, consider the first 40MB of Flash as reserved for firmware usage.
153 * The TFTF can use the rest of the Flash memory.
154 */
155#define TFTF_NVM_OFFSET 0x2800000 /* 40MB */
156#define TFTF_NVM_SIZE (FLASH_SIZE - TFTF_NVM_OFFSET)
157#else
158/*
159 * If you want to run without support for non-volatile memory (due to e.g.
160 * unavailability of a flash driver), DRAM can be used instead as workaround.
161 * The TFTF binary itself is loaded at 0xE0000000 so we have plenty of free
162 * memory at the beginning of the DRAM. Let's use the first 128MB.
163 *
164 * Please note that this won't be suitable for all test scenarios and
165 * for this reason some tests will be disabled in this configuration.
166 */
167#define TFTF_NVM_OFFSET 0x0
168#define TFTF_NVM_SIZE 0x8000000 /* 128 MB */
169#endif
170
171/*******************************************************************************
172 * Platform specific page table and MMU setup constants
173 ******************************************************************************/
Deepika Bhavnanic249d5e2020-02-06 16:29:45 -0600174#ifdef __aarch64__
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100175#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 34)
176#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 34)
177#else
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000178#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
179#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
Antonio Nino Diazf00940b2018-08-13 09:54:26 +0100180#endif
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000181
182#if IMAGE_TFTF
183/* For testing xlat tables lib v2 */
184#define MAX_XLAT_TABLES 20
185#define MAX_MMAP_REGIONS 50
186#else
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200187#define MAX_XLAT_TABLES 5
188#define MAX_MMAP_REGIONS 16
Antonio Nino Diaz54959b02019-03-29 12:59:35 +0000189#endif
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200190
191/*******************************************************************************
192 * Used to align variables on the biggest cache line size in the platform.
193 * This is known only to the platform as it might have a combination of
194 * integrated and external caches.
195 ******************************************************************************/
196#define CACHE_WRITEBACK_SHIFT 6
197#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
198
199/*******************************************************************************
200 * Non-Secure Software Generated Interupts IDs
201 ******************************************************************************/
202#define IRQ_NS_SGI_0 0
203#define IRQ_NS_SGI_1 1
204#define IRQ_NS_SGI_2 2
205#define IRQ_NS_SGI_3 3
206#define IRQ_NS_SGI_4 4
207#define IRQ_NS_SGI_5 5
208#define IRQ_NS_SGI_6 6
209#define IRQ_NS_SGI_7 7
210
211#define PLAT_MAX_SPI_OFFSET_ID 220
212
213/* The IRQ generated by Ethernet controller */
214#define IRQ_ETHERNET 192
215
216#define IRQ_CNTPSIRQ1 92
217/* Per-CPU Hypervisor Timer Interrupt ID */
218#define IRQ_PCPU_HP_TIMER 26
219/* Per-CPU Non-Secure Timer Interrupt ID */
220#define IRQ_PCPU_NS_TIMER 30
221
222/*
223 * Times(in ms) used by test code for completion of different events.
224 * Suspend entry time for debug build is high due to the time taken
225 * by the VERBOSE/INFO prints. The value considers the worst case scenario
226 * where all CPUs are going and coming out of suspend continuously.
227 */
228#if DEBUG
229#define PLAT_SUSPEND_ENTRY_TIME 0x100
230#define PLAT_SUSPEND_ENTRY_EXIT_TIME 0x200
231#else
232#define PLAT_SUSPEND_ENTRY_TIME 10
233#define PLAT_SUSPEND_ENTRY_EXIT_TIME 20
234#endif
235
236#endif /* __PLATFORM_DEF_H__ */