zynqmp_helpers.S 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2013-2020, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <drivers/arm/gicv2.h>
  8. #include <platform_def.h>
  9. .globl plat_secondary_cold_boot_setup
  10. .globl plat_is_my_cpu_primary
  11. .globl zynqmp_calc_core_pos
  12. .globl plat_my_core_pos
  13. .globl platform_mem_init
  14. /* -----------------------------------------------------
  15. * void plat_secondary_cold_boot_setup (void);
  16. *
  17. * This function performs any platform specific actions
  18. * needed for a secondary cpu after a cold reset e.g
  19. * mark the cpu's presence, mechanism to place it in a
  20. * holding pen etc.
  21. * TODO: Should we read the PSYS register to make sure
  22. * that the request has gone through.
  23. * -----------------------------------------------------
  24. */
  25. func plat_secondary_cold_boot_setup
  26. mrs x0, mpidr_el1
  27. /* Deactivate the gic cpu interface */
  28. ldr x1, =BASE_GICC_BASE
  29. mov w0, #(IRQ_BYP_DIS_GRP1 | FIQ_BYP_DIS_GRP1)
  30. orr w0, w0, #(IRQ_BYP_DIS_GRP0 | FIQ_BYP_DIS_GRP0)
  31. str w0, [x1, #GICC_CTLR]
  32. /*
  33. * There is no sane reason to come out of this wfi. This
  34. * cpu will be powered on and reset by the cpu_on pm api
  35. */
  36. dsb sy
  37. 1:
  38. no_ret plat_panic_handler
  39. endfunc plat_secondary_cold_boot_setup
  40. func plat_is_my_cpu_primary
  41. mov x9, x30
  42. bl plat_my_core_pos
  43. cmp x0, #ZYNQMP_PRIMARY_CPU
  44. cset x0, eq
  45. ret x9
  46. endfunc plat_is_my_cpu_primary
  47. /* -----------------------------------------------------
  48. * unsigned int plat_my_core_pos(void)
  49. * This function uses the zynqmp_calc_core_pos()
  50. * definition to get the index of the calling CPU.
  51. * -----------------------------------------------------
  52. */
  53. func plat_my_core_pos
  54. mrs x0, mpidr_el1
  55. b zynqmp_calc_core_pos
  56. endfunc plat_my_core_pos
  57. /* -----------------------------------------------------
  58. * unsigned int zynqmp_calc_core_pos(u_register_t mpidr)
  59. * Helper function to calculate the core position.
  60. * With this function: CorePos = (ClusterId * 4) +
  61. * CoreId
  62. * -----------------------------------------------------
  63. */
  64. func zynqmp_calc_core_pos
  65. and x1, x0, #MPIDR_CPU_MASK
  66. and x0, x0, #MPIDR_CLUSTER_MASK
  67. add x0, x1, x0, LSR #6
  68. ret
  69. endfunc zynqmp_calc_core_pos
  70. /* ---------------------------------------------------------------------
  71. * We don't need to carry out any memory initialization on ARM
  72. * platforms. The Secure RAM is accessible straight away.
  73. * ---------------------------------------------------------------------
  74. */
  75. func platform_mem_init
  76. ret
  77. endfunc platform_mem_init