rainier.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2020-2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <context.h>
  9. #include <cpu_macros.S>
  10. #include <cpuamu.h>
  11. #include <rainier.h>
  12. /* Hardware handled coherency */
  13. #if HW_ASSISTED_COHERENCY == 0
  14. #error "Rainier CPU must be compiled with HW_ASSISTED_COHERENCY enabled"
  15. #endif
  16. /* 64-bit only core */
  17. #if CTX_INCLUDE_AARCH32_REGS == 1
  18. #error "Rainier CPU supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
  19. #endif
  20. /* --------------------------------------------------
  21. * Disable speculative loads if Rainier supports
  22. * SSBS.
  23. *
  24. * Shall clobber: x0.
  25. * --------------------------------------------------
  26. */
  27. func rainier_disable_speculative_loads
  28. /* Check if the PE implements SSBS */
  29. mrs x0, id_aa64pfr1_el1
  30. tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT)
  31. b.eq 1f
  32. /* Disable speculative loads */
  33. msr SSBS, xzr
  34. 1:
  35. ret
  36. endfunc rainier_disable_speculative_loads
  37. /* Rainier R0P0 is based on Neoverse N1 R4P0. */
  38. workaround_reset_start rainier, ERRATUM(1868343), ERRATA_N1_1868343
  39. sysreg_bit_set RAINIER_CPUACTLR_EL1, RAINIER_CPUACTLR_EL1_BIT_13
  40. workaround_reset_end rainier, ERRATUM(1868343)
  41. check_erratum_ls rainier, ERRATUM(1868343), CPU_REV(0, 0)
  42. cpu_reset_func_start rainier
  43. bl rainier_disable_speculative_loads
  44. /* Forces all cacheable atomic instructions to be near */
  45. sysreg_bit_set RAINIER_CPUACTLR2_EL1, RAINIER_CPUACTLR2_EL1_BIT_2
  46. #if ENABLE_FEAT_AMU
  47. /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
  48. sysreg_bit_set actlr_el3, RAINIER_ACTLR_AMEN_BIT
  49. /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
  50. sysreg_bit_set actlr_el2, RAINIER_ACTLR_AMEN_BIT
  51. /* Enable group0 counters */
  52. mov x0, #RAINIER_AMU_GROUP0_MASK
  53. msr CPUAMCNTENSET_EL0, x0
  54. #endif
  55. cpu_reset_func_end rainier
  56. /* ---------------------------------------------
  57. * HW will do the cache maintenance while powering down
  58. * ---------------------------------------------
  59. */
  60. func rainier_core_pwr_dwn
  61. /* ---------------------------------------------
  62. * Enable CPU power down bit in power control register
  63. * ---------------------------------------------
  64. */
  65. sysreg_bit_set RAINIER_CPUPWRCTLR_EL1, RAINIER_CORE_PWRDN_EN_MASK
  66. isb
  67. ret
  68. endfunc rainier_core_pwr_dwn
  69. /* ---------------------------------------------
  70. * This function provides Rainier specific
  71. * register information for crash reporting.
  72. * It needs to return with x6 pointing to
  73. * a list of register names in ascii and
  74. * x8 - x15 having values of registers to be
  75. * reported.
  76. * ---------------------------------------------
  77. */
  78. .section .rodata.rainier_regs, "aS"
  79. rainier_regs: /* The ascii list of register names to be reported */
  80. .asciz "cpuectlr_el1", ""
  81. func rainier_cpu_reg_dump
  82. adr x6, rainier_regs
  83. mrs x8, RAINIER_CPUECTLR_EL1
  84. ret
  85. endfunc rainier_cpu_reg_dump
  86. declare_cpu_ops rainier, RAINIER_MIDR, \
  87. rainier_reset_func, \
  88. rainier_core_pwr_dwn