platform_def.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PLATFORM_DEF_H
  7. #define PLATFORM_DEF_H
  8. #include <arch.h>
  9. #include <drivers/arm/gic_common.h>
  10. #include <lib/utils_def.h>
  11. #include <plat/common/common_def.h>
  12. #include "../stm32mp2_def.h"
  13. /*******************************************************************************
  14. * Generic platform constants
  15. ******************************************************************************/
  16. /* Size of cacheable stacks */
  17. #define PLATFORM_STACK_SIZE 0xC00
  18. #define STM32MP_PRIMARY_CPU U(0x0)
  19. #define STM32MP_SECONDARY_CPU U(0x1)
  20. #define MAX_IO_DEVICES U(4)
  21. #define MAX_IO_HANDLES U(4)
  22. #define MAX_IO_BLOCK_DEVICES U(1)
  23. #define MAX_IO_MTD_DEVICES U(1)
  24. #define PLATFORM_CLUSTER_COUNT U(1)
  25. #define PLATFORM_CORE_COUNT U(2)
  26. #define PLATFORM_MAX_CPUS_PER_CLUSTER U(2)
  27. #define PLAT_MAX_PWR_LVL U(1)
  28. #define PLAT_MIN_SUSPEND_PWR_LVL U(2)
  29. #define PLAT_NUM_PWR_DOMAINS U(6)
  30. /* Local power state for power domains in Run state. */
  31. #define STM32MP_LOCAL_STATE_RUN U(0)
  32. /* Local power state for retention. */
  33. #define STM32MP_LOCAL_STATE_RET U(1)
  34. #define STM32MP_LOCAL_STATE_LP U(2)
  35. #define PLAT_MAX_RET_STATE STM32MP_LOCAL_STATE_LP
  36. /* Local power state for OFF/power-down. */
  37. #define STM32MP_LOCAL_STATE_OFF U(3)
  38. #define PLAT_MAX_OFF_STATE STM32MP_LOCAL_STATE_OFF
  39. /* Macros to parse the state information from State-ID (recommended encoding) */
  40. #define PLAT_LOCAL_PSTATE_WIDTH U(4)
  41. #define PLAT_LOCAL_PSTATE_MASK GENMASK(PLAT_LOCAL_PSTATE_WIDTH - 1U, 0)
  42. /*******************************************************************************
  43. * BL2 specific defines.
  44. ******************************************************************************/
  45. /*
  46. * Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug
  47. * size plus a little space for growth.
  48. */
  49. #define BL2_BASE STM32MP_BL2_BASE
  50. #define BL2_LIMIT (STM32MP_BL2_BASE + \
  51. STM32MP_BL2_SIZE)
  52. #define BL2_RO_BASE STM32MP_BL2_RO_BASE
  53. #define BL2_RO_LIMIT (STM32MP_BL2_RO_BASE + \
  54. STM32MP_BL2_RO_SIZE)
  55. #define BL2_RW_BASE STM32MP_BL2_RW_BASE
  56. #define BL2_RW_LIMIT (STM32MP_BL2_RW_BASE + \
  57. STM32MP_BL2_RW_SIZE)
  58. /*******************************************************************************
  59. * BL31 specific defines.
  60. ******************************************************************************/
  61. #define BL31_BASE 0
  62. #define BL31_LIMIT (STM32MP_SEC_SYSRAM_SIZE / 2)
  63. /*******************************************************************************
  64. * BL33 specific defines.
  65. ******************************************************************************/
  66. #define BL33_BASE STM32MP_BL33_BASE
  67. /*******************************************************************************
  68. * Platform specific page table and MMU setup constants
  69. ******************************************************************************/
  70. #define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 33)
  71. #define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 33)
  72. /*******************************************************************************
  73. * Declarations and constants to access the mailboxes safely. Each mailbox is
  74. * aligned on the biggest cache line size in the platform. This is known only
  75. * to the platform as it might have a combination of integrated and external
  76. * caches. Such alignment ensures that two maiboxes do not sit on the same cache
  77. * line at any cache level. They could belong to different cpus/clusters &
  78. * get written while being protected by different locks causing corruption of
  79. * a valid mailbox address.
  80. ******************************************************************************/
  81. #define CACHE_WRITEBACK_SHIFT 6
  82. #define CACHE_WRITEBACK_GRANULE (U(1) << CACHE_WRITEBACK_SHIFT)
  83. /*
  84. * Secure Interrupt: based on the standard ARM mapping
  85. */
  86. #define ARM_IRQ_SEC_PHY_TIMER U(29)
  87. #define ARM_IRQ_NON_SEC_SGI_0 U(0)
  88. #define ARM_IRQ_SEC_SGI_0 U(8)
  89. #define ARM_IRQ_SEC_SGI_1 U(9)
  90. #define ARM_IRQ_SEC_SGI_2 U(10)
  91. #define ARM_IRQ_SEC_SGI_3 U(11)
  92. #define ARM_IRQ_SEC_SGI_4 U(12)
  93. #define ARM_IRQ_SEC_SGI_5 U(13)
  94. #define ARM_IRQ_SEC_SGI_6 U(14)
  95. #define ARM_IRQ_SEC_SGI_7 U(15)
  96. /* Platform IRQ Priority */
  97. #define STM32MP_IRQ_SEC_SPI_PRIO U(0x10)
  98. /*
  99. * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
  100. * terminology. On a GICv2 system or mode, the lists will be merged and treated
  101. * as Group 0 interrupts.
  102. */
  103. #define PLATFORM_G1S_PROPS(grp) \
  104. INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, \
  105. GIC_HIGHEST_SEC_PRIORITY, \
  106. (grp), GIC_INTR_CFG_LEVEL), \
  107. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, \
  108. GIC_HIGHEST_SEC_PRIORITY, \
  109. (grp), GIC_INTR_CFG_EDGE), \
  110. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, \
  111. GIC_HIGHEST_SEC_PRIORITY, \
  112. (grp), GIC_INTR_CFG_EDGE), \
  113. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, \
  114. GIC_HIGHEST_SEC_PRIORITY, \
  115. (grp), GIC_INTR_CFG_EDGE), \
  116. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, \
  117. GIC_HIGHEST_SEC_PRIORITY, \
  118. (grp), GIC_INTR_CFG_EDGE), \
  119. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, \
  120. GIC_HIGHEST_SEC_PRIORITY, \
  121. (grp), GIC_INTR_CFG_EDGE), \
  122. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, \
  123. GIC_HIGHEST_SEC_PRIORITY, \
  124. (grp), GIC_INTR_CFG_EDGE)
  125. #define PLATFORM_G0_PROPS(grp) \
  126. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_0, \
  127. GIC_HIGHEST_SEC_PRIORITY, \
  128. (grp), GIC_INTR_CFG_EDGE), \
  129. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, \
  130. GIC_HIGHEST_SEC_PRIORITY, \
  131. (grp), GIC_INTR_CFG_EDGE)
  132. #endif /* PLATFORM_DEF_H */