imx8_helpers.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Copyright (c) 2015-2024, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <platform_def.h>
  8. #include <cortex_a35.h>
  9. .globl plat_is_my_cpu_primary
  10. .globl plat_my_core_pos
  11. .globl plat_calc_core_pos
  12. .globl plat_reset_handler
  13. .globl plat_get_my_entrypoint
  14. .globl plat_secondary_cold_boot_setup
  15. .globl plat_crash_console_init
  16. .globl plat_crash_console_putc
  17. .globl plat_crash_console_flush
  18. .globl platform_mem_init
  19. .globl imx_mailbox_init
  20. /* --------------------------------------------------------------------
  21. * Helper macro that reads the part number of the current CPU and jumps
  22. * to the given label if it matches the CPU MIDR provided.
  23. *
  24. * Clobbers x0.
  25. * --------------------------------------------------------------------
  26. */
  27. .macro jump_if_cpu_midr _cpu_midr, _label
  28. mrs x0, midr_el1
  29. ubfx x0, x0, MIDR_PN_SHIFT, #12
  30. cmp w0, #((\_cpu_midr >> MIDR_PN_SHIFT) & MIDR_PN_MASK)
  31. b.eq \_label
  32. .endm
  33. /* ----------------------------------------------
  34. * The mailbox_base is used to distinguish warm/cold
  35. * reset. The mailbox_base is in the data section, not
  36. * in .bss, this allows function to start using this
  37. * variable before the runtime memory is initialized.
  38. * ----------------------------------------------
  39. */
  40. .section .data.mailbox_base
  41. .align 3
  42. mailbox_base: .quad 0x0
  43. /* ----------------------------------------------
  44. * unsigned int plat_is_my_cpu_primary(void);
  45. * This function checks if this is the primary CPU
  46. * ----------------------------------------------
  47. */
  48. func plat_is_my_cpu_primary
  49. mrs x0, mpidr_el1
  50. and x0, x0, #(MPIDR_CPU_MASK)
  51. cmp x0, #PLAT_PRIMARY_CPU
  52. cset x0, eq
  53. ret
  54. endfunc plat_is_my_cpu_primary
  55. /* ----------------------------------------------
  56. * unsigned int plat_my_core_pos(void)
  57. * This Function uses the plat_calc_core_pos()
  58. * to get the index of the calling CPU.
  59. * ----------------------------------------------
  60. */
  61. func plat_my_core_pos
  62. mrs x0, mpidr_el1
  63. and x1, x0, #MPIDR_CPU_MASK
  64. and x0, x0, #MPIDR_CLUSTER_MASK
  65. add x0, x1, x0, LSR #6
  66. ret
  67. endfunc plat_my_core_pos
  68. /*
  69. * unsigned int plat_calc_core_pos(uint64_t mpidr)
  70. * helper function to calculate the core position.
  71. * With this function.
  72. */
  73. func plat_calc_core_pos
  74. and x1, x0, #MPIDR_CPU_MASK
  75. and x0, x0, #MPIDR_CLUSTER_MASK
  76. add x0, x1, x0, LSR #6
  77. ret
  78. endfunc plat_calc_core_pos
  79. /* ----------------------------------------------
  80. * function to handle platform specific reset.
  81. * ----------------------------------------------
  82. */
  83. func plat_reset_handler
  84. #if defined(PLAT_imx8ulp)
  85. /* enable the 512KB cache by default */
  86. mov x0, #IMX_SIM1_BASE
  87. /*
  88. * if the RVBADDR is ROM entry, that means we did
  89. * NOT switch the L2 cache to 512KB. default is 256K config,
  90. * so skip
  91. */
  92. ldr w1, [x0, #0x5c]
  93. cmp w1, #0x1000
  94. b.eq 1f
  95. add x0, x0, #0x30
  96. ldr w1, [x0]
  97. /* if already 512KB config, skip */
  98. tbnz w1, #4, 1f
  99. ldr w1, [x0]
  100. orr w1, w1, #0x10
  101. str w1, [x0]
  102. orr w1, w1, #0x10000
  103. str w1, [x0]
  104. b .
  105. 1: mrs x0, CORTEX_A35_CPUECTLR_EL1
  106. orr x0, x0, #(0x1 << 0)
  107. orr x0, x0, #(0x1 << 3)
  108. msr CORTEX_A35_CPUECTLR_EL1, x0
  109. mrs x0, CORTEX_A35_L2ECTLR_EL1
  110. orr x0, x0, #(0x1 << 0)
  111. msr CORTEX_A35_L2ECTLR_EL1, x0
  112. isb
  113. #endif
  114. /* enable EL2 cpuectlr RW access */
  115. mov x0, #0x73
  116. msr actlr_el3, x0
  117. msr actlr_el2, x0
  118. isb
  119. ret
  120. endfunc plat_reset_handler
  121. /* ---------------------------------------------
  122. * function to get the entrypoint.
  123. * ---------------------------------------------
  124. */
  125. func plat_get_my_entrypoint
  126. adrp x1, mailbox_base
  127. ldr x0, [x1, :lo12:mailbox_base]
  128. ret
  129. endfunc plat_get_my_entrypoint
  130. func imx_mailbox_init
  131. adrp x1, mailbox_base
  132. str x0, [x1, :lo12:mailbox_base]
  133. ret
  134. endfunc imx_mailbox_init
  135. func plat_secondary_cold_boot_setup
  136. b .
  137. endfunc plat_secondary_cold_boot_setup
  138. func plat_crash_console_init
  139. mov x0, #1
  140. ret
  141. endfunc plat_crash_console_init
  142. func plat_crash_console_putc
  143. ret
  144. endfunc plat_crash_console_putc
  145. func plat_crash_console_flush
  146. mov x0, #0
  147. ret
  148. endfunc plat_crash_console_flush
  149. func platform_mem_init
  150. ret
  151. endfunc platform_mem_init