versal_net_def.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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-2023, Advanced Micro Devices, Inc. All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef VERSAL_NET_DEF_H
  9. #define VERSAL_NET_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 VERSAL_NET_CONSOLE_ID_none U(0)
  15. #define VERSAL_NET_CONSOLE_ID_pl011 U(1)
  16. #define VERSAL_NET_CONSOLE_ID_pl011_0 U(1)
  17. #define VERSAL_NET_CONSOLE_ID_pl011_1 U(2)
  18. #define VERSAL_NET_CONSOLE_ID_dcc U(3)
  19. #define VERSAL_NET_CONSOLE_ID_dtb U(4)
  20. #define CONSOLE_IS(con) (VERSAL_NET_CONSOLE_ID_ ## con == VERSAL_NET_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 VERSAL_NET_SILICON U(0)
  30. #define VERSAL_NET_SPP U(1)
  31. #define VERSAL_NET_EMU U(2)
  32. #define VERSAL_NET_QEMU U(3)
  33. #define VERSAL_NET_QEMU_COSIM U(7)
  34. /* For platform detection */
  35. #define PMC_TAP U(0xF11A0000)
  36. #define PMC_TAP_VERSION (PMC_TAP + 0x4U)
  37. # define PLATFORM_MASK GENMASK(27U, 24U)
  38. # define PLATFORM_VERSION_MASK GENMASK(31U, 28U)
  39. /* Global timer reset */
  40. #define PSX_CRF U(0xEC200000)
  41. #define ACPU0_CLK_CTRL U(0x10C)
  42. #define ACPU_CLK_CTRL_CLKACT BIT(25)
  43. #define RST_APU0_OFFSET U(0x300)
  44. #define RST_APU_COLD_RESET BIT(0)
  45. #define RST_APU_WARN_RESET BIT(4)
  46. #define RST_APU_CLUSTER_COLD_RESET BIT(8)
  47. #define RST_APU_CLUSTER_WARM_RESET BIT(9)
  48. #define PSX_CRF_RST_TIMESTAMP_OFFSET U(0x33C)
  49. #define APU_PCLI (0xECB10000ULL)
  50. #define APU_PCLI_CPU_STEP (0x30ULL)
  51. #define APU_PCLI_CLUSTER_CPU_STEP (4ULL * APU_PCLI_CPU_STEP)
  52. #define APU_PCLI_CLUSTER_OFFSET U(0x8000)
  53. #define APU_PCLI_CLUSTER_STEP U(0x1000)
  54. #define PCLI_PREQ_OFFSET U(0x4)
  55. #define PREQ_CHANGE_REQUEST BIT(0)
  56. #define PCLI_PSTATE_OFFSET U(0x8)
  57. #define PCLI_PSTATE_VAL_SET U(0x48)
  58. #define PCLI_PSTATE_VAL_CLEAR U(0x38)
  59. /* Firmware Image Package */
  60. #define VERSAL_NET_PRIMARY_CPU U(0)
  61. #define CORE_0_ISR_WAKE_OFFSET (0x00000020ULL)
  62. #define APU_PCIL_CORE_X_ISR_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_ISR_WAKE_OFFSET + \
  63. (APU_PCLI_CPU_STEP * (cpu_id))))
  64. #define APU_PCIL_CORE_X_ISR_WAKE_MASK (0x00000001U)
  65. #define CORE_0_IEN_WAKE_OFFSET (0x00000028ULL)
  66. #define APU_PCIL_CORE_X_IEN_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_IEN_WAKE_OFFSET + \
  67. (APU_PCLI_CPU_STEP * (cpu_id))))
  68. #define APU_PCIL_CORE_X_IEN_WAKE_MASK (0x00000001U)
  69. #define CORE_0_IDS_WAKE_OFFSET (0x0000002CULL)
  70. #define APU_PCIL_CORE_X_IDS_WAKE_REG(cpu_id) (APU_PCLI + (CORE_0_IDS_WAKE_OFFSET + \
  71. (APU_PCLI_CPU_STEP * (cpu_id))))
  72. #define APU_PCIL_CORE_X_IDS_WAKE_MASK (0x00000001U)
  73. #define CORE_0_ISR_POWER_OFFSET (0x00000010ULL)
  74. #define APU_PCIL_CORE_X_ISR_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_ISR_POWER_OFFSET + \
  75. (APU_PCLI_CPU_STEP * (cpu_id))))
  76. #define APU_PCIL_CORE_X_ISR_POWER_MASK U(0x00000001)
  77. #define CORE_0_IEN_POWER_OFFSET (0x00000018ULL)
  78. #define APU_PCIL_CORE_X_IEN_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_IEN_POWER_OFFSET + \
  79. (APU_PCLI_CPU_STEP * (cpu_id))))
  80. #define APU_PCIL_CORE_X_IEN_POWER_MASK (0x00000001U)
  81. #define CORE_0_IDS_POWER_OFFSET (0x0000001CULL)
  82. #define APU_PCIL_CORE_X_IDS_POWER_REG(cpu_id) (APU_PCLI + (CORE_0_IDS_POWER_OFFSET + \
  83. (APU_PCLI_CPU_STEP * (cpu_id))))
  84. #define APU_PCIL_CORE_X_IDS_POWER_MASK (0x00000001U)
  85. #define CORE_PWRDN_EN_BIT_MASK (0x1U)
  86. /*******************************************************************************
  87. * memory map related constants
  88. ******************************************************************************/
  89. /* IPP 1.2/SPP 0.9 mapping */
  90. #define DEVICE0_BASE U(0xE8000000) /* psx, crl, iou */
  91. #define DEVICE0_SIZE U(0x08000000)
  92. #define DEVICE1_BASE U(0xE2000000) /* gic */
  93. #define DEVICE1_SIZE U(0x00800000)
  94. #define DEVICE2_BASE U(0xF1000000) /* uart, pmc_tap */
  95. #define DEVICE2_SIZE U(0x01000000)
  96. #define CRF_BASE U(0xFD1A0000)
  97. #define CRF_SIZE U(0x00600000)
  98. #define IPI_BASE U(0xEB300000)
  99. #define IPI_SIZE U(0x00100000)
  100. /* CRL */
  101. #define VERSAL_NET_CRL U(0xEB5E0000)
  102. #define VERSAL_NET_CRL_TIMESTAMP_REF_CTRL_OFFSET U(0x14C)
  103. #define VERSAL_NET_CRL_RST_TIMESTAMP_OFFSET U(0x348)
  104. #define VERSAL_NET_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT (1U << 25U)
  105. /* IOU SCNTRS */
  106. #define IOU_SCNTRS_BASE U(0xEC920000)
  107. #define IOU_SCNTRS_COUNTER_CONTROL_REG_OFFSET U(0)
  108. #define IOU_SCNTRS_BASE_FREQ_OFFSET U(0x20)
  109. #define IOU_SCNTRS_CONTROL_EN U(1)
  110. #define APU_CLUSTER0 U(0xECC00000)
  111. #define APU_RVBAR_L_0 U(0x40)
  112. #define APU_RVBAR_H_0 U(0x44)
  113. #define APU_CLUSTER_STEP U(0x100000)
  114. #define SLCR_OSPI_QSPI_IOU_AXI_MUX_SEL U(0xF1060504)
  115. /*******************************************************************************
  116. * IRQ constants
  117. ******************************************************************************/
  118. #define VERSAL_NET_IRQ_SEC_PHY_TIMER U(29)
  119. #define ARM_IRQ_SEC_PHY_TIMER 29
  120. /*******************************************************************************
  121. * UART related constants
  122. ******************************************************************************/
  123. #define VERSAL_NET_UART0_BASE U(0xF1920000)
  124. #define VERSAL_NET_UART1_BASE U(0xF1930000)
  125. #define UART_BAUDRATE 115200
  126. #if CONSOLE_IS(pl011) || CONSOLE_IS(dtb)
  127. #define UART_BASE VERSAL_NET_UART0_BASE
  128. # define UART_TYPE CONSOLE_PL011
  129. #elif CONSOLE_IS(pl011_1)
  130. #define UART_BASE VERSAL_NET_UART1_BASE
  131. # define UART_TYPE CONSOLE_PL011
  132. #elif CONSOLE_IS(dcc)
  133. # define UART_BASE 0x0
  134. # define UART_TYPE CONSOLE_DCC
  135. #elif CONSOLE_IS(none)
  136. # define UART_TYPE CONSOLE_NONE
  137. #else
  138. # error "invalid VERSAL_NET_CONSOLE"
  139. #endif
  140. /* Runtime console */
  141. #if defined(CONSOLE_RUNTIME)
  142. #if RT_CONSOLE_IS(pl011) || RT_CONSOLE_IS(dtb)
  143. # define RT_UART_BASE VERSAL_NET_UART0_BASE
  144. # define RT_UART_TYPE CONSOLE_PL011
  145. #elif RT_CONSOLE_IS(pl011_1)
  146. # define RT_UART_BASE VERSAL_NET_UART1_BASE
  147. # define RT_UART_TYPE CONSOLE_PL011
  148. #elif RT_CONSOLE_IS(dcc)
  149. # define RT_UART_BASE 0x0
  150. # define RT_UART_TYPE CONSOLE_DCC
  151. #else
  152. # error "invalid CONSOLE_RUNTIME"
  153. #endif
  154. #endif
  155. /* Processor core device IDs */
  156. #define PM_DEV_CLUSTER0_ACPU_0 (0x1810C0AFU)
  157. #define PM_DEV_CLUSTER0_ACPU_1 (0x1810C0B0U)
  158. #define PM_DEV_CLUSTER0_ACPU_2 (0x1810C0B1U)
  159. #define PM_DEV_CLUSTER0_ACPU_3 (0x1810C0B2U)
  160. #define PM_DEV_CLUSTER1_ACPU_0 (0x1810C0B3U)
  161. #define PM_DEV_CLUSTER1_ACPU_1 (0x1810C0B4U)
  162. #define PM_DEV_CLUSTER1_ACPU_2 (0x1810C0B5U)
  163. #define PM_DEV_CLUSTER1_ACPU_3 (0x1810C0B6U)
  164. #define PM_DEV_CLUSTER2_ACPU_0 (0x1810C0B7U)
  165. #define PM_DEV_CLUSTER2_ACPU_1 (0x1810C0B8U)
  166. #define PM_DEV_CLUSTER2_ACPU_2 (0x1810C0B9U)
  167. #define PM_DEV_CLUSTER2_ACPU_3 (0x1810C0BAU)
  168. #define PM_DEV_CLUSTER3_ACPU_0 (0x1810C0BBU)
  169. #define PM_DEV_CLUSTER3_ACPU_1 (0x1810C0BCU)
  170. #define PM_DEV_CLUSTER3_ACPU_2 (0x1810C0BDU)
  171. #define PM_DEV_CLUSTER3_ACPU_3 (0x1810C0BEU)
  172. #endif /* VERSAL_NET_DEF_H */