juno_helpers.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <common/bl_common.h>
  9. #include <cortex_a53.h>
  10. #include <cortex_a57.h>
  11. #include <cortex_a72.h>
  12. #include <cpu_macros.S>
  13. #include <platform_def.h>
  14. .globl plat_reset_handler
  15. .globl plat_arm_calc_core_pos
  16. #define JUNO_REVISION(rev) REV_JUNO_R##rev
  17. #define JUNO_HANDLER(rev) plat_reset_handler_juno_r##rev
  18. #define JUMP_TO_HANDLER_IF_JUNO_R(revision) \
  19. jump_to_handler JUNO_REVISION(revision), JUNO_HANDLER(revision)
  20. /* --------------------------------------------------------------------
  21. * Helper macro to jump to the given handler if the board revision
  22. * matches.
  23. * Expects the Juno board revision in x0.
  24. * --------------------------------------------------------------------
  25. */
  26. .macro jump_to_handler _revision, _handler
  27. cmp r0, #\_revision
  28. beq \_handler
  29. .endm
  30. /* --------------------------------------------------------------------
  31. * Platform reset handler for Juno R0.
  32. *
  33. * Juno R0 has the following topology:
  34. * - Quad core Cortex-A53 processor cluster;
  35. * - Dual core Cortex-A57 processor cluster.
  36. *
  37. * This handler does the following:
  38. * - Implement workaround for defect id 831273 by enabling an event
  39. * stream every 65536 cycles.
  40. * - Set the L2 Data RAM latency to 2 (i.e. 3 cycles) for Cortex-A57
  41. * - Set the L2 Tag RAM latency to 2 (i.e. 3 cycles) for Cortex-A57
  42. * --------------------------------------------------------------------
  43. */
  44. func JUNO_HANDLER(0)
  45. /* --------------------------------------------------------------------
  46. * Enable the event stream every 65536 cycles
  47. * --------------------------------------------------------------------
  48. */
  49. mov r0, #(0xf << EVNTI_SHIFT)
  50. orr r0, r0, #EVNTEN_BIT
  51. stcopr r0, CNTKCTL
  52. /* --------------------------------------------------------------------
  53. * Nothing else to do on Cortex-A53.
  54. * --------------------------------------------------------------------
  55. */
  56. jump_if_cpu_midr CORTEX_A53_MIDR, 1f
  57. /* --------------------------------------------------------------------
  58. * Cortex-A57 specific settings
  59. * --------------------------------------------------------------------
  60. */
  61. mov r0, #((CORTEX_A57_L2_DATA_RAM_LATENCY_3_CYCLES << CORTEX_A57_L2CTLR_DATA_RAM_LATENCY_SHIFT) | \
  62. (CORTEX_A57_L2_TAG_RAM_LATENCY_3_CYCLES << CORTEX_A57_L2CTLR_TAG_RAM_LATENCY_SHIFT))
  63. stcopr r0, CORTEX_A57_L2CTLR
  64. 1:
  65. isb
  66. bx lr
  67. endfunc JUNO_HANDLER(0)
  68. /* --------------------------------------------------------------------
  69. * Platform reset handler for Juno R1.
  70. *
  71. * Juno R1 has the following topology:
  72. * - Quad core Cortex-A53 processor cluster;
  73. * - Dual core Cortex-A57 processor cluster.
  74. *
  75. * This handler does the following:
  76. * - Set the L2 Data RAM latency to 2 (i.e. 3 cycles) for Cortex-A57
  77. *
  78. * Note that:
  79. * - The default value for the L2 Tag RAM latency for Cortex-A57 is
  80. * suitable.
  81. * - Defect #831273 doesn't affect Juno R1.
  82. * --------------------------------------------------------------------
  83. */
  84. func JUNO_HANDLER(1)
  85. /* --------------------------------------------------------------------
  86. * Nothing to do on Cortex-A53.
  87. * --------------------------------------------------------------------
  88. */
  89. jump_if_cpu_midr CORTEX_A57_MIDR, A57
  90. bx lr
  91. A57:
  92. /* --------------------------------------------------------------------
  93. * Cortex-A57 specific settings
  94. * --------------------------------------------------------------------
  95. */
  96. mov r0, #(CORTEX_A57_L2_DATA_RAM_LATENCY_3_CYCLES << CORTEX_A57_L2CTLR_DATA_RAM_LATENCY_SHIFT)
  97. stcopr r0, CORTEX_A57_L2CTLR
  98. isb
  99. bx lr
  100. endfunc JUNO_HANDLER(1)
  101. /* --------------------------------------------------------------------
  102. * Platform reset handler for Juno R2.
  103. *
  104. * Juno R2 has the following topology:
  105. * - Quad core Cortex-A53 processor cluster;
  106. * - Dual core Cortex-A72 processor cluster.
  107. *
  108. * This handler does the following:
  109. * - Set the L2 Data RAM latency to 2 (i.e. 3 cycles) for Cortex-A72
  110. * - Set the L2 Tag RAM latency to 1 (i.e. 2 cycles) for Cortex-A72
  111. *
  112. * Note that:
  113. * - Defect #831273 doesn't affect Juno R2.
  114. * --------------------------------------------------------------------
  115. */
  116. func JUNO_HANDLER(2)
  117. /* --------------------------------------------------------------------
  118. * Nothing to do on Cortex-A53.
  119. * --------------------------------------------------------------------
  120. */
  121. jump_if_cpu_midr CORTEX_A72_MIDR, A72
  122. bx lr
  123. A72:
  124. /* --------------------------------------------------------------------
  125. * Cortex-A72 specific settings
  126. * --------------------------------------------------------------------
  127. */
  128. mov r0, #((CORTEX_A72_L2_DATA_RAM_LATENCY_3_CYCLES << CORTEX_A72_L2CTLR_DATA_RAM_LATENCY_SHIFT) | \
  129. (CORTEX_A72_L2_TAG_RAM_LATENCY_2_CYCLES << CORTEX_A72_L2CTLR_TAG_RAM_LATENCY_SHIFT))
  130. stcopr r0, CORTEX_A72_L2CTLR
  131. isb
  132. bx lr
  133. endfunc JUNO_HANDLER(2)
  134. /* --------------------------------------------------------------------
  135. * void plat_reset_handler(void);
  136. *
  137. * Determine the Juno board revision and call the appropriate reset
  138. * handler.
  139. * --------------------------------------------------------------------
  140. */
  141. func plat_reset_handler
  142. /* Read the V2M SYS_ID register */
  143. ldr r0, =(V2M_SYSREGS_BASE + V2M_SYS_ID)
  144. ldr r1, [r0]
  145. /* Extract board revision from the SYS_ID */
  146. ubfx r0, r1, #V2M_SYS_ID_REV_SHIFT, #4
  147. JUMP_TO_HANDLER_IF_JUNO_R(0)
  148. JUMP_TO_HANDLER_IF_JUNO_R(1)
  149. JUMP_TO_HANDLER_IF_JUNO_R(2)
  150. /* Board revision is not supported */
  151. no_ret plat_panic_handler
  152. endfunc plat_reset_handler
  153. /* -----------------------------------------------------
  154. * unsigned int plat_arm_calc_core_pos(u_register_t mpidr)
  155. * Helper function to calculate the core position.
  156. * -----------------------------------------------------
  157. */
  158. func plat_arm_calc_core_pos
  159. b css_calc_core_pos_swap_cluster
  160. endfunc plat_arm_calc_core_pos