Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 1 | /* |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2020, Renesas Electronics Corporation. All rights reserved. |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef PLATFORM_DEF_H |
| 8 | #define PLATFORM_DEF_H |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 9 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 10 | #ifndef __ASSEMBLER__ |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 11 | #include <stdlib.h> |
| 12 | #endif |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 13 | |
| 14 | #include <arch.h> |
| 15 | |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 16 | #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 Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 32 | #define PLATFORM_STACK_SIZE U(0x1000) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 33 | #else |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 34 | #define PLATFORM_STACK_SIZE U(0x440) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 35 | #endif |
| 36 | #elif IMAGE_BL2 |
| 37 | #if TRUSTED_BOARD_BOOT |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 38 | #define PLATFORM_STACK_SIZE U(0x1000) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 39 | #else |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 40 | #define PLATFORM_STACK_SIZE U(0x400) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 41 | #endif |
| 42 | #elif IMAGE_BL31 |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 43 | #define PLATFORM_STACK_SIZE U(0x400) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 44 | #elif IMAGE_BL32 |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 45 | #define PLATFORM_STACK_SIZE U(0x440) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 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 Vasut | 2eb10fd | 2018-12-30 17:21:39 +0100 | [diff] [blame] | 82 | #define PLATFORM_CACHE_LINE_SIZE 64 |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 83 | #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 Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 100 | /* |
| 101 | ****************************************************************************** |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 102 | * BL2 specific defines. |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 103 | ****************************************************************************** |
| 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-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 107 | #define RCAR_SYSRAM_BASE U(0xE6300000) |
Marek Vasut | 4ae342c | 2019-01-05 13:56:03 +0100 | [diff] [blame] | 108 | #if (RCAR_LSI == RCAR_E3) || (RCAR_LSI == RCAR_D3) |
Marek Vasut | 2e032c0 | 2018-12-26 15:57:08 +0100 | [diff] [blame] | 109 | #define BL2_LIMIT U(0xE6320000) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 110 | #else |
Marek Vasut | 2e032c0 | 2018-12-26 15:57:08 +0100 | [diff] [blame] | 111 | #define BL2_LIMIT U(0xE6360000) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 112 | #endif |
| 113 | |
Marek Vasut | 4ae342c | 2019-01-05 13:56:03 +0100 | [diff] [blame] | 114 | #if (RCAR_LSI == RCAR_E3) || (RCAR_LSI == RCAR_D3) |
Valentine Barshak | f218414 | 2018-10-30 02:06:17 +0300 | [diff] [blame] | 115 | #define BL2_BASE U(0xE6304000) |
Marek Vasut | 2e032c0 | 2018-12-26 15:57:08 +0100 | [diff] [blame] | 116 | #define BL2_IMAGE_LIMIT U(0xE6318000) |
Valentine Barshak | f218414 | 2018-10-30 02:06:17 +0300 | [diff] [blame] | 117 | #elif (RCAR_LSI == RCAR_V3M) |
| 118 | #define BL2_BASE U(0xE6344000) |
| 119 | #define BL2_IMAGE_LIMIT U(0xE636E800) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 120 | #else |
Valentine Barshak | f218414 | 2018-10-30 02:06:17 +0300 | [diff] [blame] | 121 | #define BL2_BASE U(0xE6304000) |
Marek Vasut | 2e032c0 | 2018-12-26 15:57:08 +0100 | [diff] [blame] | 122 | #define BL2_IMAGE_LIMIT U(0xE632E800) |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 123 | #endif |
| 124 | #define RCAR_SYSRAM_SIZE (BL2_BASE - RCAR_SYSRAM_BASE) |
| 125 | |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 126 | /* |
| 127 | ****************************************************************************** |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 128 | * BL31 specific defines. |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 129 | ****************************************************************************** |
| 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-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 133 | #define BL31_BASE (RCAR_TRUSTED_SRAM_BASE) |
| 134 | #define BL31_LIMIT (RCAR_TRUSTED_SRAM_BASE + \ |
| 135 | RCAR_TRUSTED_SRAM_SIZE) |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 136 | #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-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 139 | #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) |
| 147 | #define BL32_LIMIT (BL32_BASE + U(0x100000)) |
| 148 | #endif |
| 149 | |
| 150 | /******************************************************************************* |
| 151 | * BL33 |
| 152 | ******************************************************************************/ |
| 153 | #define BL33_BASE DRAM1_NS_BASE |
| 154 | |
| 155 | |
| 156 | /******************************************************************************* |
| 157 | * Platform specific page table and MMU setup constants |
| 158 | ******************************************************************************/ |
| 159 | #if IMAGE_BL1 |
| 160 | #define MAX_XLAT_TABLES U(2) |
| 161 | #elif IMAGE_BL2 |
| 162 | #define MAX_XLAT_TABLES U(5) |
| 163 | #elif IMAGE_BL31 |
| 164 | #define MAX_XLAT_TABLES U(4) |
| 165 | #elif IMAGE_BL32 |
| 166 | #define MAX_XLAT_TABLES U(3) |
| 167 | #endif |
| 168 | |
| 169 | #if IMAGE_BL2 |
| 170 | #define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 40) |
| 171 | #define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 40) |
| 172 | #else |
| 173 | #define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32) |
| 174 | #define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32) |
| 175 | #endif |
| 176 | |
| 177 | #define MAX_MMAP_REGIONS (RCAR_MMAP_ENTRIES + RCAR_BL_REGIONS) |
| 178 | |
| 179 | /******************************************************************************* |
| 180 | * Declarations and constants to access the mailboxes safely. Each mailbox is |
| 181 | * aligned on the biggest cache line size in the platform. This is known only |
| 182 | * to the platform as it might have a combination of integrated and external |
Biju Das | 00e6aea | 2020-12-13 20:49:27 +0000 | [diff] [blame] | 183 | * caches. Such alignment ensures that two mailboxes do not sit on the same cache |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 184 | * line at any cache level. They could belong to different cpus/clusters & |
| 185 | * get written while being protected by different locks causing corruption of |
| 186 | * a valid mailbox address. |
| 187 | ******************************************************************************/ |
| 188 | #define CACHE_WRITEBACK_SHIFT (6) |
| 189 | #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT) |
| 190 | |
| 191 | /******************************************************************************* |
| 192 | * Size of the per-cpu data in bytes that should be reserved in the generic |
| 193 | * per-cpu data structure for the RCAR port. |
| 194 | ******************************************************************************/ |
| 195 | #if !USE_COHERENT_MEM |
| 196 | #define PLAT_PCPU_DATA_SIZE (2) |
| 197 | #endif |
| 198 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 199 | #endif /* PLATFORM_DEF_H */ |