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