plat_helpers.S 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2022-2023 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <cortex_a55.h>
  8. #include <platform_def.h>
  9. .globl plat_is_my_cpu_primary
  10. .globl plat_my_core_pos
  11. .globl plat_calc_core_pos
  12. .globl platform_mem_init
  13. /* ------------------------------------------------------
  14. * Helper macro that reads the part number of the current
  15. * CPU and jumps to the given label if it matches the CPU
  16. * MIDR provided.
  17. *
  18. * Clobbers x0.
  19. * ------------------------------------------------------
  20. */
  21. .macro jump_if_cpu_midr _cpu_midr, _label
  22. mrs x0, midr_el1
  23. ubfx x0, x0, MIDR_PN_SHIFT, #12
  24. cmp w0, #((\_cpu_midr >> MIDR_PN_SHIFT) & MIDR_PN_MASK)
  25. b.eq \_label
  26. .endm
  27. /* ----------------------------------------------
  28. * unsigned int plat_is_my_cpu_primary(void);
  29. * This function checks if this is the primary CPU
  30. * ----------------------------------------------
  31. */
  32. func plat_is_my_cpu_primary
  33. mrs x0, mpidr_el1
  34. mov_imm x1, MPIDR_AFFINITY_MASK
  35. and x0, x0, x1
  36. cmp x0, #PLAT_PRIMARY_CPU
  37. cset x0, eq
  38. ret
  39. endfunc plat_is_my_cpu_primary
  40. /* ----------------------------------------------
  41. * unsigned int plat_my_core_pos(void)
  42. * This function uses the plat_calc_core_pos()
  43. * to get the index of the calling CPU.
  44. * ----------------------------------------------
  45. */
  46. func plat_my_core_pos
  47. mrs x0, mpidr_el1
  48. mov x1, #MPIDR_AFFLVL_MASK
  49. and x0, x1, x0, lsr #MPIDR_AFF1_SHIFT
  50. ret
  51. endfunc plat_my_core_pos
  52. /*
  53. * unsigned int plat_calc_core_pos(uint64_t mpidr)
  54. * helper function to calculate the core position.
  55. * With this function.
  56. */
  57. func plat_calc_core_pos
  58. mov x1, #MPIDR_AFFLVL_MASK
  59. and x0, x1, x0, lsr #MPIDR_AFF1_SHIFT
  60. ret
  61. endfunc plat_calc_core_pos
  62. func platform_mem_init
  63. ret
  64. endfunc platform_mem_init