plat_pmu_macros.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <platform_def.h>
  9. #include <pmu_regs.h>
  10. .globl clst_warmboot_data
  11. .macro sram_func _name
  12. .cfi_sections .debug_frame
  13. .section .sram.text, "ax"
  14. .type \_name, %function
  15. .cfi_startproc
  16. \_name:
  17. .endm
  18. #define CRU_CLKSEL_CON6 0x118
  19. #define DDRCTL0_C_SYSREQ_CFG 0x0100
  20. #define DDRCTL1_C_SYSREQ_CFG 0x1000
  21. #define DDRC0_SREF_DONE_EXT 0x01
  22. #define DDRC1_SREF_DONE_EXT 0x04
  23. #define PLL_MODE_SHIFT (0x8)
  24. #define PLL_NORMAL_MODE ((0x3 << (PLL_MODE_SHIFT + 16)) | \
  25. (0x1 << PLL_MODE_SHIFT))
  26. #define MPIDR_CLST_L_BITS 0x0
  27. /*
  28. * For different socs, if we want to speed up warmboot,
  29. * we need to config some regs here.
  30. * If scu was suspend, we must resume related clk
  31. * from slow (24M) mode to normal mode first.
  32. * X0: MPIDR_EL1 & MPIDR_CLUSTER_MASK
  33. */
  34. .macro func_rockchip_clst_warmboot
  35. adr x4, clst_warmboot_data
  36. lsr x5, x0, #6
  37. ldr w3, [x4, x5]
  38. str wzr, [x4, x5]
  39. cmp w3, #PMU_CLST_RET
  40. b.ne clst_warmboot_end
  41. ldr w6, =(PLL_NORMAL_MODE)
  42. /*
  43. * core_l offset is CRU_BASE + 0xc,
  44. * core_b offset is CRU_BASE + 0x2c
  45. */
  46. ldr x7, =(CRU_BASE + 0xc)
  47. lsr x2, x0, #3
  48. str w6, [x7, x2]
  49. clst_warmboot_end:
  50. .endm
  51. .macro rockchip_clst_warmboot_data
  52. clst_warmboot_data:
  53. .rept PLATFORM_CLUSTER_COUNT
  54. .word 0
  55. .endr
  56. .endm
  57. /* -----------------------------------------------
  58. * void sram_func_set_ddrctl_pll(uint32_t pll_src)
  59. * Function to switch the PLL source for ddrctrl
  60. * In: x0 - The PLL of the clk_ddrc clock source
  61. * out: None
  62. * Clobber list : x0 - x3, x5, x8 - x10
  63. * -----------------------------------------------
  64. */
  65. .globl sram_func_set_ddrctl_pll
  66. sram_func sram_func_set_ddrctl_pll
  67. /* backup parameter */
  68. mov x8, x0
  69. /* disable the MMU at EL3 */
  70. mrs x9, sctlr_el3
  71. bic x10, x9, #(SCTLR_M_BIT)
  72. msr sctlr_el3, x10
  73. isb
  74. dsb sy
  75. /* enable ddrctl0_1 idle request */
  76. mov x5, PMU_BASE
  77. ldr w0, [x5, #PMU_SFT_CON]
  78. orr w0, w0, #DDRCTL0_C_SYSREQ_CFG
  79. orr w0, w0, #DDRCTL1_C_SYSREQ_CFG
  80. str w0, [x5, #PMU_SFT_CON]
  81. check_ddrc0_1_sref_enter:
  82. ldr w1, [x5, #PMU_DDR_SREF_ST]
  83. and w2, w1, #DDRC0_SREF_DONE_EXT
  84. and w3, w1, #DDRC1_SREF_DONE_EXT
  85. orr w2, w2, w3
  86. cmp w2, #(DDRC0_SREF_DONE_EXT | DDRC1_SREF_DONE_EXT)
  87. b.eq check_ddrc0_1_sref_enter
  88. /*
  89. * select a PLL for ddrctrl:
  90. * x0 = 0: ALPLL
  91. * x0 = 1: ABPLL
  92. * x0 = 2: DPLL
  93. * x0 = 3: GPLLL
  94. */
  95. mov x5, CRU_BASE
  96. lsl w0, w8, #4
  97. orr w0, w0, #0x00300000
  98. str w0, [x5, #CRU_CLKSEL_CON6]
  99. /* disable ddrctl0_1 idle request */
  100. mov x5, PMU_BASE
  101. ldr w0, [x5, #PMU_SFT_CON]
  102. bic w0, w0, #DDRCTL0_C_SYSREQ_CFG
  103. bic w0, w0, #DDRCTL1_C_SYSREQ_CFG
  104. str w0, [x5, #PMU_SFT_CON]
  105. check_ddrc0_1_sref_exit:
  106. ldr w1, [x5, #PMU_DDR_SREF_ST]
  107. and w2, w1, #DDRC0_SREF_DONE_EXT
  108. and w3, w1, #DDRC1_SREF_DONE_EXT
  109. orr w2, w2, w3
  110. cmp w2, #0x0
  111. b.eq check_ddrc0_1_sref_exit
  112. /* reenable the MMU at EL3 */
  113. msr sctlr_el3, x9
  114. isb
  115. dsb sy
  116. ret
  117. endfunc sram_func_set_ddrctl_pll