def.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2021-2022, Xilinx, Inc. All rights reserved.
  4. * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef DEF_H
  9. #define DEF_H
  10. #include <plat/arm/common/smccc_def.h>
  11. #include <plat/common/common_def.h>
  12. #define MAX_INTR_EL3 2
  13. /* List all consoles */
  14. #define VERSAL2_CONSOLE_ID_none 0
  15. #define VERSAL2_CONSOLE_ID_pl011 1
  16. #define VERSAL2_CONSOLE_ID_pl011_0 1
  17. #define VERSAL2_CONSOLE_ID_pl011_1 2
  18. #define VERSAL2_CONSOLE_ID_dcc 3
  19. #define VERSAL2_CONSOLE_ID_dtb 4
  20. #define CONSOLE_IS(con) (VERSAL2_CONSOLE_ID_ ## con == VERSAL2_CONSOLE)
  21. /* Runtime console */
  22. #define RT_CONSOLE_ID_pl011 1
  23. #define RT_CONSOLE_ID_pl011_0 1
  24. #define RT_CONSOLE_ID_pl011_1 2
  25. #define RT_CONSOLE_ID_dcc 3
  26. #define RT_CONSOLE_ID_dtb 4
  27. #define RT_CONSOLE_IS(con) (RT_CONSOLE_ID_ ## con == CONSOLE_RUNTIME)
  28. /* List all platforms */
  29. #define SILICON U(0)
  30. #define SPP U(1)
  31. #define EMU U(2)
  32. #define QEMU U(3)
  33. #define SPP_MMD U(5)
  34. #define EMU_MMD U(6)
  35. #define QEMU_COSIM U(7)
  36. /* For platform detection */
  37. #define PMC_TAP U(0xF11A0000)
  38. #define PMC_TAP_VERSION (PMC_TAP + 0x4U)
  39. # define PLATFORM_MASK GENMASK(27U, 24U)
  40. # define PLATFORM_VERSION_MASK GENMASK(31U, 28U)
  41. /* Global timer reset */
  42. #define PSX_CRF U(0xEC200000)
  43. #define ACPU0_CLK_CTRL U(0x10C)
  44. #define ACPU_CLK_CTRL_CLKACT BIT(25)
  45. #define RST_APU0_OFFSET U(0x300)
  46. #define RST_APU_COLD_RESET BIT(0)
  47. #define RST_APU_WARN_RESET BIT(4)
  48. #define RST_APU_CLUSTER_COLD_RESET BIT(8)
  49. #define RST_APU_CLUSTER_WARM_RESET BIT(9)
  50. #define PSX_CRF_RST_TIMESTAMP_OFFSET U(0x33C)
  51. #define APU_PCLI (0xECB10000ULL)
  52. #define APU_PCLI_CPU_STEP (0x30ULL)
  53. #define APU_PCLI_CLUSTER_CPU_STEP (4ULL * APU_PCLI_CPU_STEP)
  54. #define APU_PCLI_CLUSTER_OFFSET U(0x8000)
  55. #define APU_PCLI_CLUSTER_STEP U(0x1000)
  56. #define PCLI_PREQ_OFFSET U(0x4)
  57. #define PREQ_CHANGE_REQUEST BIT(0)
  58. #define PCLI_PSTATE_OFFSET U(0x8)
  59. #define PCLI_PSTATE_VAL_SET U(0x48)
  60. #define PCLI_PSTATE_VAL_CLEAR U(0x38)
  61. /* Firmware Image Package */
  62. #define PRIMARY_CPU U(0)
  63. #define CORE_0_ISR_WAKE_OFFSET (0x00000020ULL)
  64. #define APU_PCIL_CORE_X_ISR_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_ISR_WAKE_OFFSET + \
  65. (APU_PCLI_CPU_STEP * (cpu_id))))
  66. #define APU_PCIL_CORE_X_ISR_WAKE_MASK (0x00000001U)
  67. #define CORE_0_IEN_WAKE_OFFSET (0x00000028ULL)
  68. #define APU_PCIL_CORE_X_IEN_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_IEN_WAKE_OFFSET + \
  69. (APU_PCLI_CPU_STEP * (cpu_id))))
  70. #define APU_PCIL_CORE_X_IEN_WAKE_MASK (0x00000001U)
  71. #define CORE_0_IDS_WAKE_OFFSET (0x0000002CULL)
  72. #define APU_PCIL_CORE_X_IDS_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_IDS_WAKE_OFFSET + \
  73. (APU_PCLI_CPU_STEP * (cpu_id))))
  74. #define APU_PCIL_CORE_X_IDS_WAKE_MASK (0x00000001U)
  75. #define CORE_0_ISR_POWER_OFFSET (0x00000010ULL)
  76. #define APU_PCIL_CORE_X_ISR_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_ISR_POWER_OFFSET + \
  77. (APU_PCLI_CPU_STEP * (cpu_id))))
  78. #define APU_PCIL_CORE_X_ISR_POWER_MASK U(0x00000001)
  79. #define CORE_0_IEN_POWER_OFFSET (0x00000018ULL)
  80. #define APU_PCIL_CORE_X_IEN_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_IEN_POWER_OFFSET + \
  81. (APU_PCLI_CPU_STEP * (cpu_id))))
  82. #define APU_PCIL_CORE_X_IEN_POWER_MASK (0x00000001U)
  83. #define CORE_0_IDS_POWER_OFFSET (0x0000001CULL)
  84. #define APU_PCIL_CORE_X_IDS_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_IDS_POWER_OFFSET + \
  85. (APU_PCLI_CPU_STEP * (cpu_id))))
  86. #define APU_PCIL_CORE_X_IDS_POWER_MASK (0x00000001U)
  87. #define CORE_PWRDN_EN_BIT_MASK (0x1U)
  88. /*******************************************************************************
  89. * memory map related constants
  90. ******************************************************************************/
  91. /* IPP 1.2/SPP 0.9 mapping */
  92. #define DEVICE0_BASE U(0xE8000000) /* psx, crl, iou */
  93. #define DEVICE0_SIZE U(0x08000000)
  94. #define DEVICE1_BASE U(0xE2000000) /* gic */
  95. #define DEVICE1_SIZE U(0x00800000)
  96. #define DEVICE2_BASE U(0xF1000000) /* uart, pmc_tap */
  97. #define DEVICE2_SIZE U(0x01000000)
  98. #define CRF_BASE U(0xFD1A0000)
  99. #define CRF_SIZE U(0x00600000)
  100. #define IPI_BASE U(0xEB300000)
  101. #define IPI_SIZE U(0x00100000)
  102. /* CRL */
  103. #define CRL U(0xEB5E0000)
  104. #define CRL_TIMESTAMP_REF_CTRL_OFFSET U(0x14C)
  105. #define CRL_RST_TIMESTAMP_OFFSET U(0x348)
  106. #define CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT (1U << 25U)
  107. /* IOU SCNTRS */
  108. #define IOU_SCNTRS U(0xEC920000)
  109. #define IOU_SCNTRS_COUNTER_CONTROL_REG_OFFSET U(0)
  110. #define IOU_SCNTRS_BASE_FREQ_OFFSET U(0x20)
  111. #define IOU_SCNTRS_CONTROL_EN U(1)
  112. #define APU_CLUSTER0 U(0xECC00000)
  113. #define APU_RVBAR_L_0 U(0x40)
  114. #define APU_RVBAR_H_0 U(0x44)
  115. #define APU_CLUSTER_STEP U(0x100000)
  116. #define SLCR_OSPI_QSPI_IOU_AXI_MUX_SEL U(0xF1060504)
  117. #define PMXC_IOU_SLCR_SRAM_CSR U(0xF106104C)
  118. #define PMXC_IOU_SLCR_PHY_RESET U(0xF1061050)
  119. #define PMXC_IOU_SLCR_TX_RX_CONFIG_RDY U(0xF1061054)
  120. #define PMXC_CRP_RST_UFS U(0xF1260340)
  121. /*******************************************************************************
  122. * IRQ constants
  123. ******************************************************************************/
  124. #define IRQ_SEC_PHY_TIMER U(29)
  125. /*******************************************************************************
  126. * UART related constants
  127. ******************************************************************************/
  128. #define UART0_BASE U(0xF1920000)
  129. #define UART1_BASE U(0xF1930000)
  130. #define UART_BAUDRATE 115200
  131. #if CONSOLE_IS(pl011) || CONSOLE_IS(dtb)
  132. #define UART_BASE UART0_BASE
  133. # define UART_TYPE CONSOLE_PL011
  134. #elif CONSOLE_IS(pl011_1)
  135. #define UART_BASE UART1_BASE
  136. # define UART_TYPE CONSOLE_PL011
  137. #elif CONSOLE_IS(dcc)
  138. # define UART_BASE 0x0
  139. # define UART_TYPE CONSOLE_DCC
  140. #elif CONSOLE_IS(none)
  141. # define UART_TYPE CONSOLE_NONE
  142. #else
  143. # error "invalid VERSAL2_CONSOLE"
  144. #endif
  145. /* Runtime console */
  146. #if defined(CONSOLE_RUNTIME)
  147. #if RT_CONSOLE_IS(pl011) || RT_CONSOLE_IS(dtb)
  148. # define RT_UART_BASE UART0_BASE
  149. # define RT_UART_TYPE CONSOLE_PL011
  150. #elif RT_CONSOLE_IS(pl011_1)
  151. # define RT_UART_BASE UART1_BASE
  152. # define RT_UART_TYPE CONSOLE_PL011
  153. #elif RT_CONSOLE_IS(dcc)
  154. # define RT_UART_BASE 0x0
  155. # define RT_UART_TYPE CONSOLE_DCC
  156. #else
  157. # error "invalid CONSOLE_RUNTIME"
  158. #endif
  159. #endif
  160. #endif /* DEF_H */