blob: 1213a3c9615c01bc420c44bc0dbf6a852075a000 [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001/*
Toshiyuki Ogasahara1885aa52021-07-12 18:43:26 +09002 * Copyright (c) 2015-2021, Renesas Electronics Corporation. All rights reserved.
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02003 *
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
Julius Werner53456fc2019-07-09 13:49:11 -070010#ifndef __ASSEMBLER__
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020011#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
Biju Das00e6aea2020-12-13 20:49:27 +000032#define PLATFORM_STACK_SIZE U(0x1000)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020033#else
Biju Das00e6aea2020-12-13 20:49:27 +000034#define PLATFORM_STACK_SIZE U(0x440)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020035#endif
36#elif IMAGE_BL2
37#if TRUSTED_BOARD_BOOT
Biju Das00e6aea2020-12-13 20:49:27 +000038#define PLATFORM_STACK_SIZE U(0x1000)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020039#else
Biju Das00e6aea2020-12-13 20:49:27 +000040#define PLATFORM_STACK_SIZE U(0x400)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020041#endif
42#elif IMAGE_BL31
Biju Das00e6aea2020-12-13 20:49:27 +000043#define PLATFORM_STACK_SIZE U(0x400)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020044#elif IMAGE_BL32
Biju Das00e6aea2020-12-13 20:49:27 +000045#define PLATFORM_STACK_SIZE U(0x440)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020046#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
Biju Das00e6aea2020-12-13 20:49:27 +0000100/*
101 ******************************************************************************
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200102 * BL2 specific defines.
Biju Das00e6aea2020-12-13 20:49:27 +0000103 ******************************************************************************
104 * Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug
105 * size plus a little space for growth.
106 */
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200107#define RCAR_SYSRAM_BASE U(0xE6300000)
Marek Vasut4ae342c2019-01-05 13:56:03 +0100108#if (RCAR_LSI == RCAR_E3) || (RCAR_LSI == RCAR_D3)
Marek Vasut2e032c02018-12-26 15:57:08 +0100109#define BL2_LIMIT U(0xE6320000)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200110#else
Marek Vasut2e032c02018-12-26 15:57:08 +0100111#define BL2_LIMIT U(0xE6360000)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200112#endif
113
Marek Vasut4ae342c2019-01-05 13:56:03 +0100114#if (RCAR_LSI == RCAR_E3) || (RCAR_LSI == RCAR_D3)
Valentine Barshakf2184142018-10-30 02:06:17 +0300115#define BL2_BASE U(0xE6304000)
Marek Vasut2e032c02018-12-26 15:57:08 +0100116#define BL2_IMAGE_LIMIT U(0xE6318000)
Valentine Barshakf2184142018-10-30 02:06:17 +0300117#elif (RCAR_LSI == RCAR_V3M)
118#define BL2_BASE U(0xE6344000)
119#define BL2_IMAGE_LIMIT U(0xE636E800)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200120#else
Valentine Barshakf2184142018-10-30 02:06:17 +0300121#define BL2_BASE U(0xE6304000)
Marek Vasut2e032c02018-12-26 15:57:08 +0100122#define BL2_IMAGE_LIMIT U(0xE632E800)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200123#endif
124#define RCAR_SYSRAM_SIZE (BL2_BASE - RCAR_SYSRAM_BASE)
125
Biju Das00e6aea2020-12-13 20:49:27 +0000126/*
127 ******************************************************************************
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200128 * BL31 specific defines.
Biju Das00e6aea2020-12-13 20:49:27 +0000129 ******************************************************************************
130 * Put BL3-1 at the top of the Trusted SRAM. BL31_BASE is calculated using the
131 * current BL3-1 debug size plus a little space for growth.
132 */
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200133#define BL31_BASE (RCAR_TRUSTED_SRAM_BASE)
134#define BL31_LIMIT (RCAR_TRUSTED_SRAM_BASE + \
135 RCAR_TRUSTED_SRAM_SIZE)
Biju Das00e6aea2020-12-13 20:49:27 +0000136#define RCAR_BL31_LOG_BASE (0x44040000)
137#define RCAR_BL31_SDRAM_BTM (RCAR_BL31_LOG_BASE + 0x14000)
138#define RCAR_BL31_LOG_SIZE (RCAR_BL31_SDRAM_BTM - RCAR_BL31_LOG_BASE)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200139#define BL31_SRAM_BASE (DEVICE_SRAM_BASE)
140#define BL31_SRAM_LIMIT (DEVICE_SRAM_BASE + DEVICE_SRAM_SIZE)
141
142/*******************************************************************************
143 * BL32 specific defines.
144 ******************************************************************************/
145#ifndef SPD_NONE
146#define BL32_BASE U(0x44100000)
Toshiyuki Ogasahara1885aa52021-07-12 18:43:26 +0900147#define BL32_LIMIT (BL32_BASE + U(0x200000))
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200148#endif
149
150/*******************************************************************************
151 * BL33
152 ******************************************************************************/
153#define BL33_BASE DRAM1_NS_BASE
Marek Vasutb25ee352021-02-13 19:09:29 +0100154#define BL33_COMP_SIZE U(0x200000)
155#define BL33_COMP_BASE (BL33_BASE - BL33_COMP_SIZE)
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200156
157/*******************************************************************************
158 * Platform specific page table and MMU setup constants
159 ******************************************************************************/
160#if IMAGE_BL1
161#define MAX_XLAT_TABLES U(2)
162#elif IMAGE_BL2
163#define MAX_XLAT_TABLES U(5)
164#elif IMAGE_BL31
165#define MAX_XLAT_TABLES U(4)
166#elif IMAGE_BL32
167#define MAX_XLAT_TABLES U(3)
168#endif
169
170#if IMAGE_BL2
171#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 40)
172#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 40)
173#else
174#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
175#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
176#endif
177
178#define MAX_MMAP_REGIONS (RCAR_MMAP_ENTRIES + RCAR_BL_REGIONS)
179
180/*******************************************************************************
181 * Declarations and constants to access the mailboxes safely. Each mailbox is
182 * aligned on the biggest cache line size in the platform. This is known only
183 * to the platform as it might have a combination of integrated and external
Biju Das00e6aea2020-12-13 20:49:27 +0000184 * caches. Such alignment ensures that two mailboxes do not sit on the same cache
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200185 * line at any cache level. They could belong to different cpus/clusters &
186 * get written while being protected by different locks causing corruption of
187 * a valid mailbox address.
188 ******************************************************************************/
189#define CACHE_WRITEBACK_SHIFT (6)
190#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
191
192/*******************************************************************************
193 * Size of the per-cpu data in bytes that should be reserved in the generic
194 * per-cpu data structure for the RCAR port.
195 ******************************************************************************/
196#if !USE_COHERENT_MEM
197#define PLAT_PCPU_DATA_SIZE (2)
198#endif
199
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +0000200#endif /* PLATFORM_DEF_H */