plat_helpers.S 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (c) 2013-2016, 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. mrs x0, midr_el1
  32. ubfx x0, x0, MIDR_PN_SHIFT, #12
  33. cmp w0, #((CORTEX_A72_MIDR >> MIDR_PN_SHIFT) & MIDR_PN_MASK)
  34. b.eq handler_a72
  35. b handler_end
  36. handler_a72:
  37. /*
  38. * This handler does the following:
  39. * Set the L2 Data RAM latency for Cortex-A72.
  40. * Set the L2 Tag RAM latency to for Cortex-A72.
  41. */
  42. mov x0, #((5 << CORTEX_A72_L2CTLR_DATA_RAM_LATENCY_SHIFT) | \
  43. (0x1 << 5))
  44. msr CORTEX_A72_L2CTLR_EL1, x0
  45. isb
  46. handler_end:
  47. ret
  48. endfunc plat_reset_handler
  49. func plat_my_core_pos
  50. mrs x0, mpidr_el1
  51. and x1, x0, #MPIDR_CPU_MASK
  52. and x0, x0, #MPIDR_CLUSTER_MASK
  53. add x0, x1, x0, LSR #PLAT_RK_CLST_TO_CPUID_SHIFT
  54. ret
  55. endfunc plat_my_core_pos
  56. /* --------------------------------------------------------------------
  57. * void plat_secondary_cold_boot_setup (void);
  58. *
  59. * This function performs any platform specific actions
  60. * needed for a secondary cpu after a cold reset e.g
  61. * mark the cpu's presence, mechanism to place it in a
  62. * holding pen etc.
  63. * --------------------------------------------------------------------
  64. */
  65. func plat_secondary_cold_boot_setup
  66. /* rk3368 does not do cold boot for secondary CPU */
  67. cb_panic:
  68. b cb_panic
  69. endfunc plat_secondary_cold_boot_setup
  70. func plat_is_my_cpu_primary
  71. mrs x0, mpidr_el1
  72. and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
  73. cmp x0, #PLAT_RK_PRIMARY_CPU
  74. cset x0, eq
  75. ret
  76. endfunc plat_is_my_cpu_primary
  77. /* --------------------------------------------------------------------
  78. * void plat_panic_handler(void)
  79. * Call system reset function on panic. Set up an emergency stack so we
  80. * can run C functions (it only needs to last for a few calls until we
  81. * reboot anyway).
  82. * --------------------------------------------------------------------
  83. */
  84. func plat_panic_handler
  85. msr spsel, #0
  86. bl plat_set_my_stack
  87. b rockchip_soc_soft_reset
  88. endfunc plat_panic_handler
  89. /* --------------------------------------------------------------------
  90. * void platform_cpu_warmboot (void);
  91. * cpus online or resume enterpoint
  92. * --------------------------------------------------------------------
  93. */
  94. func platform_cpu_warmboot _align=16
  95. mrs x0, MPIDR_EL1
  96. and x19, x0, #MPIDR_CPU_MASK
  97. and x20, x0, #MPIDR_CLUSTER_MASK
  98. mov x0, x20
  99. func_rockchip_clst_warmboot
  100. /* --------------------------------------------------------------------
  101. * big cluster id is 1
  102. * big cores id is from 0-3, little cores id 4-7
  103. * --------------------------------------------------------------------
  104. */
  105. add x21, x19, x20, lsr #PLAT_RK_CLST_TO_CPUID_SHIFT
  106. /* --------------------------------------------------------------------
  107. * get per cpuup flag
  108. * --------------------------------------------------------------------
  109. */
  110. adr x4, cpuson_flags
  111. add x4, x4, x21, lsl #2
  112. ldr w1, [x4]
  113. /* --------------------------------------------------------------------
  114. * check cpuon reason
  115. * --------------------------------------------------------------------
  116. */
  117. cmp w1, PMU_CPU_AUTO_PWRDN
  118. b.eq boot_entry
  119. cmp w1, PMU_CPU_HOTPLUG
  120. b.eq boot_entry
  121. /* --------------------------------------------------------------------
  122. * If the boot core cpuson_flags or cpuson_entry_point is not
  123. * expection. force the core into wfe.
  124. * --------------------------------------------------------------------
  125. */
  126. wfe_loop:
  127. wfe
  128. b wfe_loop
  129. boot_entry:
  130. str wzr, [x4]
  131. /* --------------------------------------------------------------------
  132. * get per cpuup boot addr
  133. * --------------------------------------------------------------------
  134. */
  135. adr x5, cpuson_entry_point
  136. ldr x2, [x5, x21, lsl #3]
  137. br x2
  138. endfunc platform_cpu_warmboot
  139. /* --------------------------------------------------------------------
  140. * Per-CPU Secure entry point - resume or power up
  141. * --------------------------------------------------------------------
  142. */
  143. .section .tzfw_coherent_mem, "a"
  144. .align 3
  145. cpuson_entry_point:
  146. .rept PLATFORM_CORE_COUNT
  147. .quad 0
  148. .endr
  149. cpuson_flags:
  150. .rept PLATFORM_CORE_COUNT
  151. .word 0
  152. .endr
  153. rockchip_clst_warmboot_data