plat_helpers.S 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright (c) 2013-2024, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <arch.h>
  8. #include <asm_macros.S>
  9. #include <common/bl_common.h>
  10. #include <cortex_a53.h>
  11. #include <cortex_a72.h>
  12. #include <plat_private.h>
  13. #include <plat_pmu_macros.S>
  14. .globl cpuson_entry_point
  15. .globl cpuson_flags
  16. .globl platform_cpu_warmboot
  17. .globl plat_secondary_cold_boot_setup
  18. .globl plat_report_exception
  19. .globl plat_is_my_cpu_primary
  20. .globl plat_my_core_pos
  21. .globl plat_reset_handler
  22. .globl plat_panic_handler
  23. /*
  24. * void plat_reset_handler(void);
  25. *
  26. * Determine the SOC type and call the appropriate reset
  27. * handler.
  28. *
  29. */
  30. func plat_reset_handler
  31. #ifdef PLAT_RK_CPU_RESET_EARLY
  32. mov x18, x30
  33. msr spsel, #0
  34. bl plat_set_my_stack
  35. mov x0, x20
  36. mov x1, x21
  37. mov x2, x22
  38. mov x3, x23
  39. bl rockchip_cpu_reset_early
  40. mov x30, x18
  41. #endif
  42. mrs x0, midr_el1
  43. ubfx x0, x0, MIDR_PN_SHIFT, #12
  44. cmp w0, #((CORTEX_A72_MIDR >> MIDR_PN_SHIFT) & MIDR_PN_MASK)
  45. b.eq handler_a72
  46. b handler_end
  47. handler_a72:
  48. /*
  49. * This handler does the following:
  50. * Set the L2 Data RAM latency for Cortex-A72.
  51. * Set the L2 Tag RAM latency to for Cortex-A72.
  52. */
  53. mov x0, #((5 << CORTEX_A72_L2CTLR_DATA_RAM_LATENCY_SHIFT) | \
  54. (0x1 << 5))
  55. msr CORTEX_A72_L2CTLR_EL1, x0
  56. isb
  57. handler_end:
  58. ret
  59. endfunc plat_reset_handler
  60. func plat_my_core_pos
  61. mrs x0, mpidr_el1
  62. and x1, x0, #MPIDR_CPU_MASK
  63. and x0, x0, #MPIDR_CLUSTER_MASK
  64. add x0, x1, x0, LSR #PLAT_RK_CLST_TO_CPUID_SHIFT
  65. ret
  66. endfunc plat_my_core_pos
  67. /* --------------------------------------------------------------------
  68. * void plat_secondary_cold_boot_setup (void);
  69. *
  70. * This function performs any platform specific actions
  71. * needed for a secondary cpu after a cold reset e.g
  72. * mark the cpu's presence, mechanism to place it in a
  73. * holding pen etc.
  74. * --------------------------------------------------------------------
  75. */
  76. func plat_secondary_cold_boot_setup
  77. /* rk3368 does not do cold boot for secondary CPU */
  78. cb_panic:
  79. b cb_panic
  80. endfunc plat_secondary_cold_boot_setup
  81. func plat_is_my_cpu_primary
  82. mrs x0, mpidr_el1
  83. and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
  84. cmp x0, #PLAT_RK_PRIMARY_CPU
  85. cset x0, eq
  86. ret
  87. endfunc plat_is_my_cpu_primary
  88. /* --------------------------------------------------------------------
  89. * void plat_panic_handler(void)
  90. * Call system reset function on panic. Set up an emergency stack so we
  91. * can run C functions (it only needs to last for a few calls until we
  92. * reboot anyway).
  93. * --------------------------------------------------------------------
  94. */
  95. func plat_panic_handler
  96. msr spsel, #0
  97. bl plat_set_my_stack
  98. b rockchip_soc_soft_reset
  99. endfunc plat_panic_handler
  100. /* --------------------------------------------------------------------
  101. * void platform_cpu_warmboot (void);
  102. * cpus online or resume enterpoint
  103. * --------------------------------------------------------------------
  104. */
  105. func platform_cpu_warmboot _align=16
  106. mrs x0, MPIDR_EL1
  107. and x19, x0, #MPIDR_CPU_MASK
  108. and x20, x0, #MPIDR_CLUSTER_MASK
  109. mov x0, x20
  110. func_rockchip_clst_warmboot
  111. /* --------------------------------------------------------------------
  112. * big cluster id is 1
  113. * big cores id is from 0-3, little cores id 4-7
  114. * --------------------------------------------------------------------
  115. */
  116. add x21, x19, x20, lsr #PLAT_RK_CLST_TO_CPUID_SHIFT
  117. /* --------------------------------------------------------------------
  118. * get per cpuup flag
  119. * --------------------------------------------------------------------
  120. */
  121. adr x4, cpuson_flags
  122. add x4, x4, x21, lsl #2
  123. ldr w1, [x4]
  124. /* --------------------------------------------------------------------
  125. * check cpuon reason
  126. * --------------------------------------------------------------------
  127. */
  128. cmp w1, PMU_CPU_AUTO_PWRDN
  129. b.eq boot_entry
  130. cmp w1, PMU_CPU_HOTPLUG
  131. b.eq boot_entry
  132. /* --------------------------------------------------------------------
  133. * If the boot core cpuson_flags or cpuson_entry_point is not
  134. * expection. force the core into wfe.
  135. * --------------------------------------------------------------------
  136. */
  137. wfe_loop:
  138. wfe
  139. b wfe_loop
  140. boot_entry:
  141. str wzr, [x4]
  142. /* --------------------------------------------------------------------
  143. * get per cpuup boot addr
  144. * --------------------------------------------------------------------
  145. */
  146. adr x5, cpuson_entry_point
  147. ldr x2, [x5, x21, lsl #3]
  148. br x2
  149. endfunc platform_cpu_warmboot
  150. /* --------------------------------------------------------------------
  151. * Per-CPU Secure entry point - resume or power up
  152. * --------------------------------------------------------------------
  153. */
  154. #if USE_COHERENT_MEM
  155. .section .tzfw_coherent_mem, "a"
  156. #else
  157. .data
  158. #endif
  159. .align 3
  160. cpuson_entry_point:
  161. .rept PLATFORM_CORE_COUNT
  162. .quad 0
  163. .endr
  164. cpuson_flags:
  165. .rept PLATFORM_CORE_COUNT
  166. .word 0
  167. .endr
  168. rockchip_clst_warmboot_data