blob: 6a8c9886e1801b1beaf3d53403f36220bcb3103a [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
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>
James Morrissey9d72b4e2014-02-10 17:04:32 +000038#include "io_storage.h"
Achin Gupta4f6ad662013-10-25 09:08:21 +010039
40
41/*******************************************************************************
42 * Platform binary types for linking
43 ******************************************************************************/
44#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
45#define PLATFORM_LINKER_ARCH aarch64
46
47/*******************************************************************************
48 * Generic platform constants
49 ******************************************************************************/
50#define PLATFORM_STACK_SIZE 0x800
51
52#define FIRMWARE_WELCOME_STR "Booting trusted firmware boot loader stage 1\n\r"
Harry Liebel561cd332014-02-14 14:42:48 +000053
54/* Trusted Boot Firmware BL2 */
Achin Gupta4f6ad662013-10-25 09:08:21 +010055#define BL2_IMAGE_NAME "bl2.bin"
Achin Guptae4d084e2014-02-19 17:18:23 +000056
Harry Liebel561cd332014-02-14 14:42:48 +000057/* EL3 Runtime Firmware BL31 */
Achin Guptae4d084e2014-02-19 17:18:23 +000058#define BL31_IMAGE_NAME "bl31.bin"
59
Harry Liebel561cd332014-02-14 14:42:48 +000060/* Secure Payload BL32 (Trusted OS) */
Achin Guptae4d084e2014-02-19 17:18:23 +000061#define BL32_IMAGE_NAME "bl32.bin"
62
Harry Liebel561cd332014-02-14 14:42:48 +000063/* Non-Trusted Firmware BL33 and its load address */
Achin Guptae4d084e2014-02-19 17:18:23 +000064#define BL33_IMAGE_NAME "bl33.bin" /* e.g. UEFI */
65#define NS_IMAGE_OFFSET (DRAM_BASE + 0x8000000) /* DRAM + 128MB */
66
Harry Liebel561cd332014-02-14 14:42:48 +000067/* Firmware Image Package */
68#define FIP_IMAGE_NAME "fip.bin"
69
Achin Gupta4f6ad662013-10-25 09:08:21 +010070#define PLATFORM_CACHE_LINE_SIZE 64
71#define PLATFORM_CLUSTER_COUNT 2ull
72#define PLATFORM_CLUSTER0_CORE_COUNT 4
73#define PLATFORM_CLUSTER1_CORE_COUNT 4
Ian Spray84687392014-01-02 16:57:12 +000074#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
75 PLATFORM_CLUSTER0_CORE_COUNT)
Achin Gupta4f6ad662013-10-25 09:08:21 +010076#define PLATFORM_MAX_CPUS_PER_CLUSTER 4
77#define PRIMARY_CPU 0x0
Harry Liebel561cd332014-02-14 14:42:48 +000078#define MAX_IO_DEVICES 3
James Morrisseyf2f9bb52014-02-10 16:18:59 +000079#define MAX_IO_HANDLES 4
Achin Gupta4f6ad662013-10-25 09:08:21 +010080
81/* Constants for accessing platform configuration */
82#define CONFIG_GICD_ADDR 0
83#define CONFIG_GICC_ADDR 1
84#define CONFIG_GICH_ADDR 2
85#define CONFIG_GICV_ADDR 3
86#define CONFIG_MAX_AFF0 4
87#define CONFIG_MAX_AFF1 5
88/* Indicate whether the CPUECTLR SMP bit should be enabled. */
89#define CONFIG_CPU_SETUP 6
90#define CONFIG_BASE_MMAP 7
Harry Liebel30affd52013-10-30 17:41:48 +000091/* Indicates whether CCI should be enabled on the platform. */
92#define CONFIG_HAS_CCI 8
93#define CONFIG_LIMIT 9
Achin Gupta4f6ad662013-10-25 09:08:21 +010094
95/*******************************************************************************
96 * Platform memory map related constants
97 ******************************************************************************/
98#define TZROM_BASE 0x00000000
99#define TZROM_SIZE 0x04000000
100
101#define TZRAM_BASE 0x04000000
102#define TZRAM_SIZE 0x40000
103
104#define FLASH0_BASE 0x08000000
105#define FLASH0_SIZE TZROM_SIZE
106
107#define FLASH1_BASE 0x0c000000
108#define FLASH1_SIZE 0x04000000
109
110#define PSRAM_BASE 0x14000000
111#define PSRAM_SIZE 0x04000000
112
113#define VRAM_BASE 0x18000000
114#define VRAM_SIZE 0x02000000
115
116/* Aggregate of all devices in the first GB */
117#define DEVICE0_BASE 0x1a000000
118#define DEVICE0_SIZE 0x12200000
119
120#define DEVICE1_BASE 0x2f000000
121#define DEVICE1_SIZE 0x200000
122
123#define NSRAM_BASE 0x2e000000
124#define NSRAM_SIZE 0x10000
125
126/* Location of trusted dram on the base fvp */
127#define TZDRAM_BASE 0x06000000
128#define TZDRAM_SIZE 0x02000000
129#define MBOX_OFF 0x1000
130#define AFFMAP_OFF 0x1200
131
132#define DRAM_BASE 0x80000000ull
133#define DRAM_SIZE 0x80000000ull
134
135#define PCIE_EXP_BASE 0x40000000
136#define TZRNG_BASE 0x7fe60000
137#define TZNVCTR_BASE 0x7fe70000
138#define TZROOTKEY_BASE 0x7fe80000
139
140/* Memory mapped Generic timer interfaces */
141#define SYS_CNTCTL_BASE 0x2a430000
142#define SYS_CNTREAD_BASE 0x2a800000
143#define SYS_TIMCTL_BASE 0x2a810000
144
145/* Counter timer module offsets */
146#define CNTNSAR 0x4
147#define CNTNSAR_NS_SHIFT(x) x
148
149#define CNTACR_BASE(x) (0x40 + (x << 2))
150#define CNTACR_RPCT_SHIFT 0x0
151#define CNTACR_RVCT_SHIFT 0x1
152#define CNTACR_RFRQ_SHIFT 0x2
153#define CNTACR_RVOFF_SHIFT 0x3
154#define CNTACR_RWVT_SHIFT 0x4
155#define CNTACR_RWPT_SHIFT 0x5
156
157/* V2M motherboard system registers & offsets */
158#define VE_SYSREGS_BASE 0x1c010000
159#define V2M_SYS_ID 0x0
160#define V2M_SYS_LED 0x8
161#define V2M_SYS_CFGDATA 0xa0
162#define V2M_SYS_CFGCTRL 0xa4
163
164/*
165 * V2M sysled bit definitions. The values written to this
166 * register are defined in arch.h & runtime_svc.h. Only
167 * used by the primary cpu to diagnose any cold boot issues.
168 *
169 * SYS_LED[0] - Security state (S=0/NS=1)
170 * SYS_LED[2:1] - Exception Level (EL3-EL0)
171 * SYS_LED[7:3] - Exception Class (Sync/Async & origin)
172 *
173 */
174#define SYS_LED_SS_SHIFT 0x0
175#define SYS_LED_EL_SHIFT 0x1
176#define SYS_LED_EC_SHIFT 0x3
177
178#define SYS_LED_SS_MASK 0x1
179#define SYS_LED_EL_MASK 0x3
180#define SYS_LED_EC_MASK 0x1f
181
182/* V2M sysid register bits */
183#define SYS_ID_REV_SHIFT 27
184#define SYS_ID_HBI_SHIFT 16
185#define SYS_ID_BLD_SHIFT 12
186#define SYS_ID_ARCH_SHIFT 8
187#define SYS_ID_FPGA_SHIFT 0
188
189#define SYS_ID_REV_MASK 0xf
190#define SYS_ID_HBI_MASK 0xfff
191#define SYS_ID_BLD_MASK 0xf
192#define SYS_ID_ARCH_MASK 0xf
193#define SYS_ID_FPGA_MASK 0xff
194
195#define SYS_ID_BLD_LENGTH 4
196
197#define REV_FVP 0x0
198#define HBI_FVP_BASE 0x020
199#define HBI_FOUNDATION 0x010
200
201#define BLD_GIC_VE_MMAP 0x0
202#define BLD_GIC_A53A57_MMAP 0x1
203
204#define ARCH_MODEL 0x1
205
206/* FVP Power controller base address*/
207#define PWRC_BASE 0x1c100000
208
209/*******************************************************************************
210 * Platform specific per affinity states. Distinction between off and suspend
211 * is made to allow reporting of a suspended cpu as still being on e.g. in the
212 * affinity_info psci call.
213 ******************************************************************************/
214#define PLATFORM_MAX_AFF0 4
215#define PLATFORM_MAX_AFF1 2
216#define PLAT_AFF_UNK 0xff
217
218#define PLAT_AFF0_OFF 0x0
219#define PLAT_AFF0_ONPENDING 0x1
220#define PLAT_AFF0_SUSPEND 0x2
221#define PLAT_AFF0_ON 0x3
222
223#define PLAT_AFF1_OFF 0x0
224#define PLAT_AFF1_ONPENDING 0x1
225#define PLAT_AFF1_SUSPEND 0x2
226#define PLAT_AFF1_ON 0x3
227
228/*******************************************************************************
229 * BL2 specific defines.
230 ******************************************************************************/
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000231#define BL2_BASE 0x0402D000
Achin Gupta4f6ad662013-10-25 09:08:21 +0100232
233/*******************************************************************************
234 * BL31 specific defines.
235 ******************************************************************************/
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000236#define BL31_BASE 0x0400C000
Achin Gupta4f6ad662013-10-25 09:08:21 +0100237
238/*******************************************************************************
Achin Guptaa3050ed2014-02-19 17:52:35 +0000239 * BL32 specific defines.
240 ******************************************************************************/
241#define BL32_BASE (TZDRAM_BASE + 0x2000)
242
243/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +0100244 * Platform specific page table and MMU setup constants
245 ******************************************************************************/
246#define EL3_ADDR_SPACE_SIZE (1ull << 32)
247#define EL3_NUM_PAGETABLES 2
248#define EL3_TROM_PAGETABLE 0
249#define EL3_TRAM_PAGETABLE 1
250
251#define ADDR_SPACE_SIZE (1ull << 32)
252
253#define NUM_L2_PAGETABLES 2
254#define GB1_L2_PAGETABLE 0
255#define GB2_L2_PAGETABLE 1
256
257#define NUM_L3_PAGETABLES 2
258#define TZRAM_PAGETABLE 0
259#define NSRAM_PAGETABLE 1
260
261/*******************************************************************************
262 * CCI-400 related constants
263 ******************************************************************************/
264#define CCI400_BASE 0x2c090000
265#define CCI400_SL_IFACE_CLUSTER0 3
266#define CCI400_SL_IFACE_CLUSTER1 4
267#define CCI400_SL_IFACE_INDEX(mpidr) (mpidr & MPIDR_CLUSTER_MASK ? \
268 CCI400_SL_IFACE_CLUSTER1 : \
269 CCI400_SL_IFACE_CLUSTER0)
270
271/*******************************************************************************
272 * GIC-400 & interrupt handling related constants
273 ******************************************************************************/
274/* VE compatible GIC memory map */
275#define VE_GICD_BASE 0x2c001000
276#define VE_GICC_BASE 0x2c002000
277#define VE_GICH_BASE 0x2c004000
278#define VE_GICV_BASE 0x2c006000
279
280/* Base FVP compatible GIC memory map */
281#define BASE_GICD_BASE 0x2f000000
282#define BASE_GICR_BASE 0x2f100000
283#define BASE_GICC_BASE 0x2c000000
284#define BASE_GICH_BASE 0x2c010000
285#define BASE_GICV_BASE 0x2c02f000
286
287#define IRQ_TZ_WDOG 56
288#define IRQ_SEC_PHY_TIMER 29
289#define IRQ_SEC_SGI_0 8
290#define IRQ_SEC_SGI_1 9
291#define IRQ_SEC_SGI_2 10
292#define IRQ_SEC_SGI_3 11
293#define IRQ_SEC_SGI_4 12
294#define IRQ_SEC_SGI_5 13
295#define IRQ_SEC_SGI_6 14
296#define IRQ_SEC_SGI_7 15
297#define IRQ_SEC_SGI_8 16
298
299/*******************************************************************************
300 * PL011 related constants
301 ******************************************************************************/
302#define PL011_BASE 0x1c090000
303
304/*******************************************************************************
305 * Declarations and constants to access the mailboxes safely. Each mailbox is
306 * aligned on the biggest cache line size in the platform. This is known only
307 * to the platform as it might have a combination of integrated and external
308 * caches. Such alignment ensures that two maiboxes do not sit on the same cache
309 * line at any cache level. They could belong to different cpus/clusters &
310 * get written while being protected by different locks causing corruption of
311 * a valid mailbox address.
312 ******************************************************************************/
313#define CACHE_WRITEBACK_SHIFT 6
314#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
315
316#ifndef __ASSEMBLY__
317
318typedef volatile struct {
319 unsigned long value
320 __attribute__((__aligned__(CACHE_WRITEBACK_GRANULE)));
321} mailbox;
322
323/*******************************************************************************
324 * Function and variable prototypes
325 ******************************************************************************/
326extern unsigned long *bl1_normal_ram_base;
327extern unsigned long *bl1_normal_ram_len;
328extern unsigned long *bl1_normal_ram_limit;
329extern unsigned long *bl1_normal_ram_zi_base;
330extern unsigned long *bl1_normal_ram_zi_len;
331
332extern unsigned long *bl1_coherent_ram_base;
333extern unsigned long *bl1_coherent_ram_len;
334extern unsigned long *bl1_coherent_ram_limit;
335extern unsigned long *bl1_coherent_ram_zi_base;
336extern unsigned long *bl1_coherent_ram_zi_len;
337extern unsigned long warm_boot_entrypoint;
338
339extern void bl1_plat_arch_setup(void);
340extern void bl2_plat_arch_setup(void);
341extern void bl31_plat_arch_setup(void);
342extern int platform_setup_pm(plat_pm_ops **);
343extern unsigned int platform_get_core_pos(unsigned long mpidr);
Achin Guptaa0cd9892014-02-09 13:30:38 +0000344extern unsigned long fill_xlation_tables(meminfo *memory_layout,
345 unsigned long ro_start,
346 unsigned long ro_limit,
347 unsigned long coh_start,
348 unsigned long coh_limit);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100349extern void disable_mmu(void);
350extern void enable_mmu(void);
351extern void configure_mmu(meminfo *,
352 unsigned long,
353 unsigned long,
354 unsigned long,
355 unsigned long);
356extern unsigned long platform_get_cfgvar(unsigned int);
357extern int platform_config_setup(void);
358extern void plat_report_exception(unsigned long);
359extern unsigned long plat_get_ns_image_entrypoint(void);
Achin Guptac8afc782013-11-25 18:45:02 +0000360extern unsigned long platform_get_stack(unsigned long mpidr);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100361
Ian Spray84687392014-01-02 16:57:12 +0000362/* Declarations for fvp_gic.c */
363extern void gic_cpuif_deactivate(unsigned int);
364extern void gic_cpuif_setup(unsigned int);
365extern void gic_pcpu_distif_setup(unsigned int);
366extern void gic_setup(void);
367
Achin Gupta4f6ad662013-10-25 09:08:21 +0100368/* Declarations for fvp_topology.c */
369extern int plat_setup_topology(void);
370extern int plat_get_max_afflvl(void);
371extern unsigned int plat_get_aff_count(unsigned int, unsigned long);
372extern unsigned int plat_get_aff_state(unsigned int, unsigned long);
373
James Morrissey9d72b4e2014-02-10 17:04:32 +0000374/* Declarations for plat_io_storage.c */
375extern void io_setup(void);
376extern int plat_get_image_source(const char *image_name,
377 io_dev_handle *dev_handle, void **image_spec);
378
Achin Gupta4f6ad662013-10-25 09:08:21 +0100379#endif /*__ASSEMBLY__*/
380
381#endif /* __PLATFORM_H__ */