blob: fa6e474c44604b3efc3fa05bd3013e93528eee2b [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001/*
2 * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef PLATFORM_DEF_H
8#define PLATFORM_DEF_H
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02009
10#include <arch.h>
11#ifndef __ASSEMBLY__
12#include <stdlib.h>
13#endif
14#include "rcar_def.h"
15
16/*******************************************************************************
17 * Platform binary types for linking
18 ******************************************************************************/
19#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
20#define PLATFORM_LINKER_ARCH aarch64
21
22/*******************************************************************************
23 * Generic platform constants
24 ******************************************************************************/
25 #define FIRMWARE_WELCOME_STR "Booting Rcar-gen3 Trusted Firmware\n"
26
27/* Size of cacheable stacks */
28#if IMAGE_BL1
29#if TRUSTED_BOARD_BOOT
30#define PLATFORM_STACK_SIZE U(0x1000)
31#else
32#define PLATFORM_STACK_SIZE U(0x440)
33#endif
34#elif IMAGE_BL2
35#if TRUSTED_BOARD_BOOT
36#define PLATFORM_STACK_SIZE U(0x1000)
37#else
38#define PLATFORM_STACK_SIZE U(0x400)
39#endif
40#elif IMAGE_BL31
41#define PLATFORM_STACK_SIZE U(0x400)
42#elif IMAGE_BL32
43#define PLATFORM_STACK_SIZE U(0x440)
44#endif
45
46#define BL332_IMAGE_ID (NS_BL2U_IMAGE_ID + 1)
47#define BL333_IMAGE_ID (NS_BL2U_IMAGE_ID + 2)
48#define BL334_IMAGE_ID (NS_BL2U_IMAGE_ID + 3)
49#define BL335_IMAGE_ID (NS_BL2U_IMAGE_ID + 4)
50#define BL336_IMAGE_ID (NS_BL2U_IMAGE_ID + 5)
51#define BL337_IMAGE_ID (NS_BL2U_IMAGE_ID + 6)
52#define BL338_IMAGE_ID (NS_BL2U_IMAGE_ID + 7)
53
54#define BL332_KEY_CERT_ID (NS_BL2U_IMAGE_ID + 8)
55#define BL333_KEY_CERT_ID (NS_BL2U_IMAGE_ID + 9)
56#define BL334_KEY_CERT_ID (NS_BL2U_IMAGE_ID + 10)
57#define BL335_KEY_CERT_ID (NS_BL2U_IMAGE_ID + 11)
58#define BL336_KEY_CERT_ID (NS_BL2U_IMAGE_ID + 12)
59#define BL337_KEY_CERT_ID (NS_BL2U_IMAGE_ID + 13)
60#define BL338_KEY_CERT_ID (NS_BL2U_IMAGE_ID + 14)
61
62#define BL332_CERT_ID (NS_BL2U_IMAGE_ID + 15)
63#define BL333_CERT_ID (NS_BL2U_IMAGE_ID + 16)
64#define BL334_CERT_ID (NS_BL2U_IMAGE_ID + 17)
65#define BL335_CERT_ID (NS_BL2U_IMAGE_ID + 18)
66#define BL336_CERT_ID (NS_BL2U_IMAGE_ID + 19)
67#define BL337_CERT_ID (NS_BL2U_IMAGE_ID + 20)
68#define BL338_CERT_ID (NS_BL2U_IMAGE_ID + 21)
69
70/* io drivers id */
71#define FLASH_DEV_ID U(0)
72#define EMMC_DEV_ID U(1)
73
74/*
75 * R-Car H3 Cortex-A57
76 * L1:I/48KB(16KBx3way) D/32KB(16KBx2way) L2:2MB(128KBx16way)
77 * Cortex-A53
78 * L1:I/32KB(16KBx2way) D/32KB(8KBx4way) L2:512KB(32KBx16way)
79 */
80#define PLATFORM_CACHE_LINE_SIZE 128
81#define PLATFORM_CLUSTER_COUNT U(2)
82#define PLATFORM_CLUSTER0_CORE_COUNT U(4)
83#define PLATFORM_CLUSTER1_CORE_COUNT U(4)
84#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
85 PLATFORM_CLUSTER0_CORE_COUNT)
86#define PLATFORM_MAX_CPUS_PER_CLUSTER U(4)
87
88#define PLAT_MAX_PWR_LVL MPIDR_AFFLVL2
89#define PLAT_NUM_PWR_DOMAINS (PLATFORM_CORE_COUNT + \
90 PLATFORM_CLUSTER_COUNT + 1)
91
92#define PLAT_MAX_RET_STATE U(1)
93#define PLAT_MAX_OFF_STATE U(2)
94
95#define MAX_IO_DEVICES U(3)
96#define MAX_IO_HANDLES U(4)
97
98/*******************************************************************************
99 * BL2 specific defines.
100 ******************************************************************************/
101/* Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug
102 * size plus a little space for growth. */
103#define RCAR_SYSRAM_BASE U(0xE6300000)
104#if RCAR_LSI == RCAR_E3
105#define RCAR_SYSRAM_LIMIT U(0xE6320000)
106#else
107#define RCAR_SYSRAM_LIMIT U(0xE6360000)
108#endif
109
110#define BL2_BASE U(0xE6304000)
111#if RCAR_LSI == RCAR_E3
112#define BL2_LIMIT U(0xE6318000)
113#else
114#define BL2_LIMIT U(0xE632E800)
115#endif
116#define RCAR_SYSRAM_SIZE (BL2_BASE - RCAR_SYSRAM_BASE)
117
118/*******************************************************************************
119 * BL31 specific defines.
120 ******************************************************************************/
121/* Put BL3-1 at the top of the Trusted SRAM. BL31_BASE is calculated using the
122 * current BL3-1 debug size plus a little space for growth. */
123#define BL31_BASE (RCAR_TRUSTED_SRAM_BASE)
124#define BL31_LIMIT (RCAR_TRUSTED_SRAM_BASE + \
125 RCAR_TRUSTED_SRAM_SIZE)
126#define RCAR_BL31_LOG_BASE (0x44040000)
127#define RCAR_BL31_SDRAM_BTM (RCAR_BL31_LOG_BASE + 0x14000)
128#define RCAR_BL31_LOG_SIZE (RCAR_BL31_SDRAM_BTM - RCAR_BL31_LOG_BASE)
129#define BL31_SRAM_BASE (DEVICE_SRAM_BASE)
130#define BL31_SRAM_LIMIT (DEVICE_SRAM_BASE + DEVICE_SRAM_SIZE)
131
132/*******************************************************************************
133 * BL32 specific defines.
134 ******************************************************************************/
135#ifndef SPD_NONE
136#define BL32_BASE U(0x44100000)
137#define BL32_LIMIT (BL32_BASE + U(0x100000))
138#endif
139
140/*******************************************************************************
141 * BL33
142 ******************************************************************************/
143#define BL33_BASE DRAM1_NS_BASE
144
145
146/*******************************************************************************
147 * Platform specific page table and MMU setup constants
148 ******************************************************************************/
149#if IMAGE_BL1
150#define MAX_XLAT_TABLES U(2)
151#elif IMAGE_BL2
152#define MAX_XLAT_TABLES U(5)
153#elif IMAGE_BL31
154#define MAX_XLAT_TABLES U(4)
155#elif IMAGE_BL32
156#define MAX_XLAT_TABLES U(3)
157#endif
158
159#if IMAGE_BL2
160#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 40)
161#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 40)
162#else
163#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
164#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
165#endif
166
167#define MAX_MMAP_REGIONS (RCAR_MMAP_ENTRIES + RCAR_BL_REGIONS)
168
169/*******************************************************************************
170 * Declarations and constants to access the mailboxes safely. Each mailbox is
171 * aligned on the biggest cache line size in the platform. This is known only
172 * to the platform as it might have a combination of integrated and external
173 * caches. Such alignment ensures that two maiboxes do not sit on the same cache
174 * line at any cache level. They could belong to different cpus/clusters &
175 * get written while being protected by different locks causing corruption of
176 * a valid mailbox address.
177 ******************************************************************************/
178#define CACHE_WRITEBACK_SHIFT (6)
179#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
180
181/*******************************************************************************
182 * Size of the per-cpu data in bytes that should be reserved in the generic
183 * per-cpu data structure for the RCAR port.
184 ******************************************************************************/
185#if !USE_COHERENT_MEM
186#define PLAT_PCPU_DATA_SIZE (2)
187#endif
188
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +0000189#endif /* PLATFORM_DEF_H */