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