lx2160a_warm_rst.S 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Copyright 2020 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. .section .text, "ax"
  8. #include <asm_macros.S>
  9. #ifndef NXP_COINED_BB
  10. #include <flash_info.h>
  11. #include <fspi.h>
  12. #endif
  13. #include <regs.h>
  14. #ifdef NXP_COINED_BB
  15. #include <snvs.h>
  16. #endif
  17. #include <plat_warm_rst.h>
  18. #include <platform_def.h>
  19. #define SDRAM_CFG 0x110
  20. #define SDRAM_CFG_2 0x114
  21. #define SDRAM_MD_CNTL 0x120
  22. #define SDRAM_INTERVAL 0x124
  23. #define TIMING_CFG_10 0x258
  24. #define DEBUG_2 0xF04
  25. #define DEBUG_26 0xF64
  26. #define DDR_DSR2 0xB24
  27. #define DDR_CNTRLR_2 0x2
  28. #define COUNT_100 1000
  29. .globl _soc_sys_warm_reset
  30. .align 12
  31. func _soc_sys_warm_reset
  32. mov x3, xzr
  33. b touch_line0
  34. start_line0:
  35. mov x3, #1
  36. mov x2, #NUM_OF_DDRC
  37. ldr x1, =NXP_DDR_ADDR
  38. 1:
  39. ldr w0, [x1, #SDRAM_CFG]
  40. orr w0, w0, #SDRAM_CFG_MEM_HLT
  41. str w0, [x1, #SDRAM_CFG]
  42. 2:
  43. ldr w0, [x1, #DEBUG_2]
  44. and w0, w0, #DDR_DBG_2_MEM_IDLE
  45. cbz w0, 2b
  46. ldr w0, [x1, #DEBUG_26]
  47. orr w0, w0, #DDR_DEBUG_26_BIT_12
  48. orr w0, w0, #DDR_DEBUG_26_BIT_13
  49. orr w0, w0, #DDR_DEBUG_26_BIT_14
  50. touch_line0:
  51. cbz x3, touch_line1
  52. orr w0, w0, #DDR_DEBUG_26_BIT_15
  53. orr w0, w0, #DDR_DEBUG_26_BIT_16
  54. str w0, [x1, #DEBUG_26]
  55. ldr w0, [x1, #SDRAM_CFG_2]
  56. orr w0, w0, #SDRAM_CFG2_FRC_SR
  57. str w0, [x1, #SDRAM_CFG_2]
  58. 3:
  59. ldr w0, [x1, #DDR_DSR2]
  60. orr w0, w0, #DDR_DSR_2_PHY_INIT_CMPLT
  61. str w0, [x1, #DDR_DSR2]
  62. ldr w0, [x1, #DDR_DSR2]
  63. and w0, w0, #DDR_DSR_2_PHY_INIT_CMPLT
  64. cbnz w0, 3b
  65. ldr w0, [x1, #SDRAM_INTERVAL]
  66. and w0, w0, #SDRAM_INTERVAL_REFINT_CLEAR
  67. str w0, [x1, #SDRAM_INTERVAL]
  68. touch_line1:
  69. cbz x3, touch_line2
  70. ldr w0, [x1, #SDRAM_MD_CNTL]
  71. orr w0, w0, #MD_CNTL_CKE(1)
  72. orr w0, w0, #MD_CNTL_MD_EN
  73. str w0, [x1, #SDRAM_MD_CNTL]
  74. ldr w0, [x1, #TIMING_CFG_10]
  75. orr w0, w0, #DDR_TIMING_CFG_10_T_STAB
  76. str w0, [x1, #TIMING_CFG_10]
  77. ldr w0, [x1, #SDRAM_CFG_2]
  78. and w0, w0, #SDRAM_CFG2_FRC_SR_CLEAR
  79. str w0, [x1, #SDRAM_CFG_2]
  80. 4:
  81. ldr w0, [x1, #DDR_DSR2]
  82. and w0, w0, #DDR_DSR_2_PHY_INIT_CMPLT
  83. cbz w0, 4b
  84. nop
  85. touch_line2:
  86. cbz x3, touch_line3
  87. ldr w0, [x1, #DEBUG_26]
  88. orr w0, w0, #DDR_DEBUG_26_BIT_25
  89. and w0, w0, #DDR_DEBUG_26_BIT_24_CLEAR
  90. str w0, [x1, #DEBUG_26]
  91. cmp x2, #DDR_CNTRLR_2
  92. b.ne 5f
  93. ldr x1, =NXP_DDR2_ADDR
  94. mov x2, xzr
  95. b 1b
  96. 5:
  97. mov x5, xzr
  98. 6:
  99. add x5, x5, #1
  100. cmp x5, #COUNT_100
  101. b.ne 6b
  102. nop
  103. touch_line3:
  104. cbz x3, touch_line4
  105. #ifdef NXP_COINED_BB
  106. ldr x1, =NXP_SNVS_ADDR
  107. ldr w0, [x1, #NXP_APP_DATA_LP_GPR_OFFSET]
  108. /* On Warm Boot is enabled, then zeroth bit
  109. * of SNVS LP GPR register 0 will used
  110. * to save the status of warm-reset as a cause.
  111. */
  112. orr w0, w0, #(1 << NXP_LPGPR_ZEROTH_BIT)
  113. /* write back */
  114. str w0, [x1, #NXP_APP_DATA_LP_GPR_OFFSET]
  115. nop
  116. nop
  117. nop
  118. nop
  119. nop
  120. nop
  121. nop
  122. nop
  123. nop
  124. nop
  125. nop
  126. touch_line4:
  127. cbz x3, touch_line6
  128. #elif !(ERLY_WRM_RST_FLG_FLSH_UPDT)
  129. ldr x1, =NXP_FLEXSPI_ADDR
  130. ldr w0, [x1, #FSPI_IPCMD]
  131. orr w0, w0, #FSPI_IPCMD_TRG_MASK
  132. str w0, [x1, #FSPI_IPCMD]
  133. 7:
  134. ldr w0, [x1, #FSPI_INTR]
  135. and w0, w0, #FSPI_INTR_IPCMDDONE_MASK
  136. cmp w0, #0
  137. b.eq 7b
  138. ldr w0, [x1, #FSPI_IPTXFCR]
  139. orr w0, w0, #FSPI_IPTXFCR_CLR
  140. str w0, [x1, #FSPI_IPTXFCR]
  141. ldr w0, [x1, #FSPI_INTR]
  142. orr w0, w0, #FSPI_INTR_IPCMDDONE_MASK
  143. str w0, [x1, #FSPI_INTR]
  144. nop
  145. touch_line4:
  146. cbz x3, touch_line5
  147. /* flexspi driver has an api
  148. * is_flash_busy().
  149. * Impelementation of the api will not
  150. * fit-in in 1 cache line.
  151. * instead a nop-cycles are introduced to
  152. * simulate the wait time for flash write
  153. * completion.
  154. *
  155. * Note: This wait time varies from flash to flash.
  156. */
  157. mov x0, #FLASH_WR_COMP_WAIT_BY_NOP_COUNT
  158. 8:
  159. sub x0, x0, #1
  160. nop
  161. cmp x0, #0
  162. b.ne 8b
  163. nop
  164. nop
  165. nop
  166. nop
  167. nop
  168. nop
  169. nop
  170. nop
  171. nop
  172. touch_line5:
  173. cbz x3, touch_line6
  174. #endif
  175. ldr x2, =NXP_RST_ADDR
  176. /* clear the RST_REQ_MSK and SW_RST_REQ */
  177. mov w0, #0x00000000
  178. str w0, [x2, #RSTCNTL_OFFSET]
  179. /* initiate the sw reset request */
  180. mov w0, #SW_RST_REQ_INIT
  181. str w0, [x2, #RSTCNTL_OFFSET]
  182. /* In case this address range is mapped as cacheable,
  183. * flush the write out of the dcaches.
  184. */
  185. add x2, x2, #RSTCNTL_OFFSET
  186. dc cvac, x2
  187. dsb st
  188. isb
  189. /* Function does not return */
  190. b .
  191. nop
  192. nop
  193. nop
  194. nop
  195. nop
  196. nop
  197. nop
  198. touch_line6:
  199. cbz x3, start_line0
  200. endfunc _soc_sys_warm_reset