plat_helpers.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2023, Aspeed Technology Inc.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <assert_macros.S>
  8. #include <arch.h>
  9. #include <cortex_a35.h>
  10. #include <platform_def.h>
  11. .globl platform_mem_init
  12. .globl plat_is_my_cpu_primary
  13. .globl plat_my_core_pos
  14. .globl plat_secondary_cold_boot_setup
  15. .globl plat_get_syscnt_freq2
  16. .globl plat_crash_console_init
  17. .globl plat_crash_console_putc
  18. .globl plat_crash_console_flush
  19. /* void platform_mem_init(void); */
  20. func platform_mem_init
  21. /* DRAM init. is done by preceding MCU */
  22. ret
  23. endfunc platform_mem_init
  24. /* unsigned int plat_is_my_cpu_primary(void); */
  25. func plat_is_my_cpu_primary
  26. mrs x0, mpidr_el1
  27. and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
  28. cmp x0, #PLATFORM_CORE_PRIMARY
  29. cset w0, eq
  30. ret
  31. endfunc plat_is_my_cpu_primary
  32. /* unsigned int plat_my_core_pos(void); */
  33. func plat_my_core_pos
  34. mrs x0, mpidr_el1
  35. mov x2, #PLATFORM_CORE_COUNT_PER_CLUSTER
  36. and x1, x0, #MPIDR_CPU_MASK
  37. and x0, x0, #MPIDR_CLUSTER_MASK
  38. madd x0, x0, x2, x1
  39. ret
  40. endfunc plat_my_core_pos
  41. /* void plat_secondary_cold_boot_setup (void); */
  42. func plat_secondary_cold_boot_setup
  43. mov x0, xzr
  44. bl plat_my_core_pos
  45. mov_imm x1, SCU_CPU_SMP_EP0
  46. add x1, x1, x0, lsl #3
  47. poll_smp_mbox_go:
  48. wfe
  49. ldr x0, [x1]
  50. cmp x0, xzr
  51. beq poll_smp_mbox_go
  52. br x0
  53. endfunc plat_secondary_cold_boot_setup
  54. /* int plat_crash_console_init(void); */
  55. func plat_crash_console_init
  56. mov_imm x0, CONSOLE_UART_BASE
  57. mov_imm x1, CONSOLE_UART_CLKIN_HZ
  58. mov_imm x2, CONSOLE_UART_BAUDRATE
  59. b console_16550_core_init
  60. endfunc plat_crash_console_init
  61. /* int plat_crash_console_putc(int); */
  62. func plat_crash_console_putc
  63. mov_imm x1, CONSOLE_UART_BASE
  64. b console_16550_core_putc
  65. endfunc plat_crash_console_putc
  66. /* void plat_crash_console_flush(void); */
  67. func plat_crash_console_flush
  68. mov_imm x0, CONSOLE_UART_BASE
  69. b console_16550_core_flush
  70. endfunc plat_crash_console_flush