blob: 21a7912bf53ddbfa6fb280e344ea03c2af89968b [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
2 * Copyright (c) 2013, ARM Limited. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __PLATFORM_H__
32#define __PLATFORM_H__
33
34#include <arch.h>
35#include <mmio.h>
36#include <psci.h>
37#include <bl_common.h>
38
39
40/*******************************************************************************
41 * Platform binary types for linking
42 ******************************************************************************/
43#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
44#define PLATFORM_LINKER_ARCH aarch64
45
46/*******************************************************************************
47 * Generic platform constants
48 ******************************************************************************/
49#define PLATFORM_STACK_SIZE 0x800
50
51#define FIRMWARE_WELCOME_STR "Booting trusted firmware boot loader stage 1\n\r"
52#define BL2_IMAGE_NAME "bl2.bin"
53#define BL31_IMAGE_NAME "bl31.bin"
54#define NS_IMAGE_OFFSET FLASH0_BASE
55
56#define PLATFORM_CACHE_LINE_SIZE 64
57#define PLATFORM_CLUSTER_COUNT 2ull
58#define PLATFORM_CLUSTER0_CORE_COUNT 4
59#define PLATFORM_CLUSTER1_CORE_COUNT 4
60#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
61 PLATFORM_CLUSTER0_CORE_COUNT)
62#define PLATFORM_MAX_CPUS_PER_CLUSTER 4
63#define PRIMARY_CPU 0x0
64
65/* Constants for accessing platform configuration */
66#define CONFIG_GICD_ADDR 0
67#define CONFIG_GICC_ADDR 1
68#define CONFIG_GICH_ADDR 2
69#define CONFIG_GICV_ADDR 3
70#define CONFIG_MAX_AFF0 4
71#define CONFIG_MAX_AFF1 5
72/* Indicate whether the CPUECTLR SMP bit should be enabled. */
73#define CONFIG_CPU_SETUP 6
74#define CONFIG_BASE_MMAP 7
75#define CONFIG_LIMIT 8
76
77/*******************************************************************************
78 * Platform memory map related constants
79 ******************************************************************************/
80#define TZROM_BASE 0x00000000
81#define TZROM_SIZE 0x04000000
82
83#define TZRAM_BASE 0x04000000
84#define TZRAM_SIZE 0x40000
85
86#define FLASH0_BASE 0x08000000
87#define FLASH0_SIZE TZROM_SIZE
88
89#define FLASH1_BASE 0x0c000000
90#define FLASH1_SIZE 0x04000000
91
92#define PSRAM_BASE 0x14000000
93#define PSRAM_SIZE 0x04000000
94
95#define VRAM_BASE 0x18000000
96#define VRAM_SIZE 0x02000000
97
98/* Aggregate of all devices in the first GB */
99#define DEVICE0_BASE 0x1a000000
100#define DEVICE0_SIZE 0x12200000
101
102#define DEVICE1_BASE 0x2f000000
103#define DEVICE1_SIZE 0x200000
104
105#define NSRAM_BASE 0x2e000000
106#define NSRAM_SIZE 0x10000
107
108/* Location of trusted dram on the base fvp */
109#define TZDRAM_BASE 0x06000000
110#define TZDRAM_SIZE 0x02000000
111#define MBOX_OFF 0x1000
112#define AFFMAP_OFF 0x1200
113
114#define DRAM_BASE 0x80000000ull
115#define DRAM_SIZE 0x80000000ull
116
117#define PCIE_EXP_BASE 0x40000000
118#define TZRNG_BASE 0x7fe60000
119#define TZNVCTR_BASE 0x7fe70000
120#define TZROOTKEY_BASE 0x7fe80000
121
122/* Memory mapped Generic timer interfaces */
123#define SYS_CNTCTL_BASE 0x2a430000
124#define SYS_CNTREAD_BASE 0x2a800000
125#define SYS_TIMCTL_BASE 0x2a810000
126
127/* Counter timer module offsets */
128#define CNTNSAR 0x4
129#define CNTNSAR_NS_SHIFT(x) x
130
131#define CNTACR_BASE(x) (0x40 + (x << 2))
132#define CNTACR_RPCT_SHIFT 0x0
133#define CNTACR_RVCT_SHIFT 0x1
134#define CNTACR_RFRQ_SHIFT 0x2
135#define CNTACR_RVOFF_SHIFT 0x3
136#define CNTACR_RWVT_SHIFT 0x4
137#define CNTACR_RWPT_SHIFT 0x5
138
139/* V2M motherboard system registers & offsets */
140#define VE_SYSREGS_BASE 0x1c010000
141#define V2M_SYS_ID 0x0
142#define V2M_SYS_LED 0x8
143#define V2M_SYS_CFGDATA 0xa0
144#define V2M_SYS_CFGCTRL 0xa4
145
146/*
147 * V2M sysled bit definitions. The values written to this
148 * register are defined in arch.h & runtime_svc.h. Only
149 * used by the primary cpu to diagnose any cold boot issues.
150 *
151 * SYS_LED[0] - Security state (S=0/NS=1)
152 * SYS_LED[2:1] - Exception Level (EL3-EL0)
153 * SYS_LED[7:3] - Exception Class (Sync/Async & origin)
154 *
155 */
156#define SYS_LED_SS_SHIFT 0x0
157#define SYS_LED_EL_SHIFT 0x1
158#define SYS_LED_EC_SHIFT 0x3
159
160#define SYS_LED_SS_MASK 0x1
161#define SYS_LED_EL_MASK 0x3
162#define SYS_LED_EC_MASK 0x1f
163
164/* V2M sysid register bits */
165#define SYS_ID_REV_SHIFT 27
166#define SYS_ID_HBI_SHIFT 16
167#define SYS_ID_BLD_SHIFT 12
168#define SYS_ID_ARCH_SHIFT 8
169#define SYS_ID_FPGA_SHIFT 0
170
171#define SYS_ID_REV_MASK 0xf
172#define SYS_ID_HBI_MASK 0xfff
173#define SYS_ID_BLD_MASK 0xf
174#define SYS_ID_ARCH_MASK 0xf
175#define SYS_ID_FPGA_MASK 0xff
176
177#define SYS_ID_BLD_LENGTH 4
178
179#define REV_FVP 0x0
180#define HBI_FVP_BASE 0x020
181#define HBI_FOUNDATION 0x010
182
183#define BLD_GIC_VE_MMAP 0x0
184#define BLD_GIC_A53A57_MMAP 0x1
185
186#define ARCH_MODEL 0x1
187
188/* FVP Power controller base address*/
189#define PWRC_BASE 0x1c100000
190
191/*******************************************************************************
192 * Platform specific per affinity states. Distinction between off and suspend
193 * is made to allow reporting of a suspended cpu as still being on e.g. in the
194 * affinity_info psci call.
195 ******************************************************************************/
196#define PLATFORM_MAX_AFF0 4
197#define PLATFORM_MAX_AFF1 2
198#define PLAT_AFF_UNK 0xff
199
200#define PLAT_AFF0_OFF 0x0
201#define PLAT_AFF0_ONPENDING 0x1
202#define PLAT_AFF0_SUSPEND 0x2
203#define PLAT_AFF0_ON 0x3
204
205#define PLAT_AFF1_OFF 0x0
206#define PLAT_AFF1_ONPENDING 0x1
207#define PLAT_AFF1_SUSPEND 0x2
208#define PLAT_AFF1_ON 0x3
209
210/*******************************************************************************
211 * BL2 specific defines.
212 ******************************************************************************/
213#define BL2_BASE 0x0402D000
214
215/*******************************************************************************
216 * BL31 specific defines.
217 ******************************************************************************/
218#define BL31_BASE 0x0400E000
219
220/*******************************************************************************
221 * Platform specific page table and MMU setup constants
222 ******************************************************************************/
223#define EL3_ADDR_SPACE_SIZE (1ull << 32)
224#define EL3_NUM_PAGETABLES 2
225#define EL3_TROM_PAGETABLE 0
226#define EL3_TRAM_PAGETABLE 1
227
228#define ADDR_SPACE_SIZE (1ull << 32)
229
230#define NUM_L2_PAGETABLES 2
231#define GB1_L2_PAGETABLE 0
232#define GB2_L2_PAGETABLE 1
233
234#define NUM_L3_PAGETABLES 2
235#define TZRAM_PAGETABLE 0
236#define NSRAM_PAGETABLE 1
237
238/*******************************************************************************
239 * CCI-400 related constants
240 ******************************************************************************/
241#define CCI400_BASE 0x2c090000
242#define CCI400_SL_IFACE_CLUSTER0 3
243#define CCI400_SL_IFACE_CLUSTER1 4
244#define CCI400_SL_IFACE_INDEX(mpidr) (mpidr & MPIDR_CLUSTER_MASK ? \
245 CCI400_SL_IFACE_CLUSTER1 : \
246 CCI400_SL_IFACE_CLUSTER0)
247
248/*******************************************************************************
249 * GIC-400 & interrupt handling related constants
250 ******************************************************************************/
251/* VE compatible GIC memory map */
252#define VE_GICD_BASE 0x2c001000
253#define VE_GICC_BASE 0x2c002000
254#define VE_GICH_BASE 0x2c004000
255#define VE_GICV_BASE 0x2c006000
256
257/* Base FVP compatible GIC memory map */
258#define BASE_GICD_BASE 0x2f000000
259#define BASE_GICR_BASE 0x2f100000
260#define BASE_GICC_BASE 0x2c000000
261#define BASE_GICH_BASE 0x2c010000
262#define BASE_GICV_BASE 0x2c02f000
263
264#define IRQ_TZ_WDOG 56
265#define IRQ_SEC_PHY_TIMER 29
266#define IRQ_SEC_SGI_0 8
267#define IRQ_SEC_SGI_1 9
268#define IRQ_SEC_SGI_2 10
269#define IRQ_SEC_SGI_3 11
270#define IRQ_SEC_SGI_4 12
271#define IRQ_SEC_SGI_5 13
272#define IRQ_SEC_SGI_6 14
273#define IRQ_SEC_SGI_7 15
274#define IRQ_SEC_SGI_8 16
275
276/*******************************************************************************
277 * PL011 related constants
278 ******************************************************************************/
279#define PL011_BASE 0x1c090000
280
281/*******************************************************************************
282 * Declarations and constants to access the mailboxes safely. Each mailbox is
283 * aligned on the biggest cache line size in the platform. This is known only
284 * to the platform as it might have a combination of integrated and external
285 * caches. Such alignment ensures that two maiboxes do not sit on the same cache
286 * line at any cache level. They could belong to different cpus/clusters &
287 * get written while being protected by different locks causing corruption of
288 * a valid mailbox address.
289 ******************************************************************************/
290#define CACHE_WRITEBACK_SHIFT 6
291#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
292
293#ifndef __ASSEMBLY__
294
295typedef volatile struct {
296 unsigned long value
297 __attribute__((__aligned__(CACHE_WRITEBACK_GRANULE)));
298} mailbox;
299
300/*******************************************************************************
301 * Function and variable prototypes
302 ******************************************************************************/
303extern unsigned long *bl1_normal_ram_base;
304extern unsigned long *bl1_normal_ram_len;
305extern unsigned long *bl1_normal_ram_limit;
306extern unsigned long *bl1_normal_ram_zi_base;
307extern unsigned long *bl1_normal_ram_zi_len;
308
309extern unsigned long *bl1_coherent_ram_base;
310extern unsigned long *bl1_coherent_ram_len;
311extern unsigned long *bl1_coherent_ram_limit;
312extern unsigned long *bl1_coherent_ram_zi_base;
313extern unsigned long *bl1_coherent_ram_zi_len;
314extern unsigned long warm_boot_entrypoint;
315
316extern void bl1_plat_arch_setup(void);
317extern void bl2_plat_arch_setup(void);
318extern void bl31_plat_arch_setup(void);
319extern int platform_setup_pm(plat_pm_ops **);
320extern unsigned int platform_get_core_pos(unsigned long mpidr);
321extern void disable_mmu(void);
322extern void enable_mmu(void);
323extern void configure_mmu(meminfo *,
324 unsigned long,
325 unsigned long,
326 unsigned long,
327 unsigned long);
328extern unsigned long platform_get_cfgvar(unsigned int);
329extern int platform_config_setup(void);
330extern void plat_report_exception(unsigned long);
331extern unsigned long plat_get_ns_image_entrypoint(void);
332
333/* Declarations for fvp_topology.c */
334extern int plat_setup_topology(void);
335extern int plat_get_max_afflvl(void);
336extern unsigned int plat_get_aff_count(unsigned int, unsigned long);
337extern unsigned int plat_get_aff_state(unsigned int, unsigned long);
338
339#endif /*__ASSEMBLY__*/
340
341#endif /* __PLATFORM_H__ */