platform_def.h 7.0 KB

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