plat_helpers.S 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (c) 2013-2019, 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_a12.h>
  11. #include <plat_private.h>
  12. #include <plat_pmu_macros.S>
  13. .globl cpuson_entry_point
  14. .globl cpuson_flags
  15. .globl platform_cpu_warmboot
  16. .globl plat_secondary_cold_boot_setup
  17. .globl plat_report_exception
  18. .globl plat_is_my_cpu_primary
  19. .globl plat_my_core_pos
  20. .globl plat_reset_handler
  21. .globl plat_panic_handler
  22. /*
  23. * void plat_reset_handler(void);
  24. *
  25. * Determine the SOC type and call the appropriate reset
  26. * handler.
  27. *
  28. */
  29. func plat_reset_handler
  30. bx lr
  31. endfunc plat_reset_handler
  32. func plat_my_core_pos
  33. ldcopr r0, MPIDR
  34. and r1, r0, #MPIDR_CPU_MASK
  35. #ifdef PLAT_RK_MPIDR_CLUSTER_MASK
  36. and r0, r0, #PLAT_RK_MPIDR_CLUSTER_MASK
  37. #else
  38. and r0, r0, #MPIDR_CLUSTER_MASK
  39. #endif
  40. add r0, r1, r0, LSR #PLAT_RK_CLST_TO_CPUID_SHIFT
  41. bx lr
  42. endfunc plat_my_core_pos
  43. /* --------------------------------------------------------------------
  44. * void plat_secondary_cold_boot_setup (void);
  45. *
  46. * This function performs any platform specific actions
  47. * needed for a secondary cpu after a cold reset e.g
  48. * mark the cpu's presence, mechanism to place it in a
  49. * holding pen etc.
  50. * --------------------------------------------------------------------
  51. */
  52. func plat_secondary_cold_boot_setup
  53. /* rk3288 does not do cold boot for secondary CPU */
  54. cb_panic:
  55. b cb_panic
  56. endfunc plat_secondary_cold_boot_setup
  57. func plat_is_my_cpu_primary
  58. ldcopr r0, MPIDR
  59. #ifdef PLAT_RK_MPIDR_CLUSTER_MASK
  60. ldr r1, =(PLAT_RK_MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
  61. #else
  62. ldr r1, =(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
  63. #endif
  64. and r0, r1
  65. cmp r0, #PLAT_RK_PRIMARY_CPU
  66. moveq r0, #1
  67. movne r0, #0
  68. bx lr
  69. endfunc plat_is_my_cpu_primary
  70. /* --------------------------------------------------------------------
  71. * void plat_panic_handler(void)
  72. * Call system reset function on panic. Set up an emergency stack so we
  73. * can run C functions (it only needs to last for a few calls until we
  74. * reboot anyway).
  75. * --------------------------------------------------------------------
  76. */
  77. func plat_panic_handler
  78. bl plat_set_my_stack
  79. b rockchip_soc_soft_reset
  80. endfunc plat_panic_handler
  81. /* --------------------------------------------------------------------
  82. * void platform_cpu_warmboot (void);
  83. * cpus online or resume entrypoint
  84. * --------------------------------------------------------------------
  85. */
  86. func platform_cpu_warmboot _align=16
  87. push { r4 - r7, lr }
  88. ldcopr r0, MPIDR
  89. and r5, r0, #MPIDR_CPU_MASK
  90. #ifdef PLAT_RK_MPIDR_CLUSTER_MASK
  91. and r6, r0, #PLAT_RK_MPIDR_CLUSTER_MASK
  92. #else
  93. and r6, r0, #MPIDR_CLUSTER_MASK
  94. #endif
  95. mov r0, r6
  96. func_rockchip_clst_warmboot
  97. /* --------------------------------------------------------------------
  98. * big cluster id is 1
  99. * big cores id is from 0-3, little cores id 4-7
  100. * --------------------------------------------------------------------
  101. */
  102. add r7, r5, r6, LSR #PLAT_RK_CLST_TO_CPUID_SHIFT
  103. /* --------------------------------------------------------------------
  104. * get per cpuup flag
  105. * --------------------------------------------------------------------
  106. */
  107. ldr r4, =cpuson_flags
  108. add r4, r4, r7, lsl #2
  109. ldr r1, [r4]
  110. /* --------------------------------------------------------------------
  111. * check cpuon reason
  112. * --------------------------------------------------------------------
  113. */
  114. cmp r1, #PMU_CPU_AUTO_PWRDN
  115. beq boot_entry
  116. cmp r1, #PMU_CPU_HOTPLUG
  117. beq boot_entry
  118. /* --------------------------------------------------------------------
  119. * If the boot core cpuson_flags or cpuson_entry_point is not
  120. * expection. force the core into wfe.
  121. * --------------------------------------------------------------------
  122. */
  123. wfe_loop:
  124. wfe
  125. b wfe_loop
  126. boot_entry:
  127. mov r1, #0
  128. str r1, [r4]
  129. /* --------------------------------------------------------------------
  130. * get per cpuup boot addr
  131. * --------------------------------------------------------------------
  132. */
  133. ldr r5, =cpuson_entry_point
  134. ldr r2, [r5, r7, lsl #2] /* ehem. #3 */
  135. pop { r4 - r7, lr }
  136. bx r2
  137. endfunc platform_cpu_warmboot
  138. /* --------------------------------------------------------------------
  139. * Per-CPU Secure entry point - resume or power up
  140. * --------------------------------------------------------------------
  141. */
  142. .section .tzfw_coherent_mem, "a"
  143. .align 3
  144. cpuson_entry_point:
  145. .rept PLATFORM_CORE_COUNT
  146. .quad 0
  147. .endr
  148. cpuson_flags:
  149. .rept PLATFORM_CORE_COUNT
  150. .word 0
  151. .endr
  152. rockchip_clst_warmboot_data