plat_helpers.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright 2024 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <platform_def.h>
  8. #include <s32cc-ncore.h>
  9. .globl plat_crash_console_flush
  10. .globl plat_crash_console_init
  11. .globl plat_crash_console_putc
  12. .globl plat_is_my_cpu_primary
  13. .globl plat_my_core_pos
  14. .globl plat_reset_handler
  15. .globl plat_secondary_cold_boot_setup
  16. .globl platform_mem_init
  17. .globl s32g2_core_pos_by_mpidr
  18. /* int plat_crash_console_init(void); */
  19. func plat_crash_console_init
  20. mov_imm x0, UART_BASE
  21. mov_imm x1, UART_CLOCK_HZ
  22. mov_imm x2, UART_BAUDRATE
  23. b console_linflex_core_init
  24. endfunc plat_crash_console_init
  25. /* int plat_crash_console_putc(int); */
  26. func plat_crash_console_putc
  27. mov_imm x1, UART_BASE
  28. b console_linflex_core_putc
  29. ret
  30. endfunc plat_crash_console_putc
  31. /* void plat_crash_console_flush(void); */
  32. func plat_crash_console_flush
  33. mov_imm x0, UART_BASE
  34. b console_linflex_core_flush
  35. ret
  36. endfunc plat_crash_console_flush
  37. /**
  38. * unsigned int s32g2_core_pos_by_mpidr(u_register_t mpidr);
  39. *
  40. * In: x0 - MPIDR_EL1
  41. * Out: x0
  42. * Clobber list: x0, x1
  43. */
  44. func s32g2_core_pos_by_mpidr
  45. and x1, x0, #MPIDR_CPU_MASK
  46. and x0, x0, #MPIDR_CLUSTER_MASK
  47. lsr x0, x0, #MPIDR_AFF1_SHIFT
  48. add x0, x1, x0, lsl #PLATFORM_MPIDR_CPU_MASK_BITS
  49. ret
  50. endfunc s32g2_core_pos_by_mpidr
  51. /**
  52. * unsigned int plat_my_core_pos(void);
  53. *
  54. * Out: x0
  55. * Clobber list: x0, x1, x8
  56. */
  57. func plat_my_core_pos
  58. mov x8, x30
  59. mrs x0, mpidr_el1
  60. bl s32g2_core_pos_by_mpidr
  61. mov x30, x8
  62. ret
  63. endfunc plat_my_core_pos
  64. /**
  65. * unsigned int plat_is_my_cpu_primary(void);
  66. *
  67. * Clobber list: x0, x1, x7, x8
  68. */
  69. func plat_is_my_cpu_primary
  70. mov x7, x30
  71. bl plat_my_core_pos
  72. cmp x0, #PLATFORM_PRIMARY_CPU
  73. cset x0, eq
  74. mov x30, x7
  75. ret
  76. endfunc plat_is_my_cpu_primary
  77. /**
  78. * void plat_secondary_cold_boot_setup (void);
  79. */
  80. func plat_secondary_cold_boot_setup
  81. ret
  82. endfunc plat_secondary_cold_boot_setup
  83. /**
  84. * void plat_reset_handler(void);
  85. *
  86. * Set the CAIUTC[IsolEn] bit for the primary A53 cluster.
  87. * This is so cache invalidate operations from the early TF-A boot code
  88. * won't cause Ncore to crash.
  89. *
  90. * Clobber list: x0, x1, x2
  91. */
  92. func plat_reset_handler
  93. mov x0, #NCORE_CAIU0_BASE_ADDR
  94. ldr w1, [x0, #NCORE_CAIUTC_OFF]
  95. movz w2, #1
  96. lsl w2, w2, #NCORE_CAIUTC_ISOLEN_SHIFT
  97. orr w1, w1, w2
  98. str w1, [x0, #NCORE_CAIUTC_OFF]
  99. ret
  100. endfunc plat_reset_handler
  101. /* void platform_mem_init(void); */
  102. func platform_mem_init
  103. mov x10, x30
  104. mov x0, #BL31_BASE
  105. mov x1, #(BL31_LIMIT & 0xFFFFU)
  106. movk x1, #(BL31_LIMIT >> 16), lsl #16
  107. sub x1, x1, x0
  108. bl zeromem
  109. mov x0, #BL33_BASE
  110. mov x1, #(BL33_LIMIT & 0xFFFFU)
  111. movk x1, #(BL33_LIMIT >> 16), lsl #16
  112. sub x1, x1, x0
  113. bl zeromem
  114. mov x30, x10
  115. ret
  116. endfunc platform_mem_init