lowlevel_init.S 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Board specific setup info
  4. *
  5. * (C) Copyright 2004, ARM Ltd.
  6. * Philippe Robin, <philippe.robin@arm.com>
  7. */
  8. #include <config.h>
  9. /* Reset using CM control register */
  10. .global reset_cpu
  11. reset_cpu:
  12. mov r0, #CM_BASE
  13. ldr r1,[r0,#OS_CTRL]
  14. orr r1,r1,#CMMASK_RESET
  15. str r1,[r0,#OS_CTRL]
  16. reset_failed:
  17. b reset_failed
  18. /* Set up the platform, once the cpu has been initialized */
  19. .globl lowlevel_init
  20. lowlevel_init:
  21. /* If U-Boot has been run after the ARM boot monitor
  22. * then all the necessary actions have been done
  23. * otherwise we are running from user flash mapped to 0x00000000
  24. * --- DO NOT REMAP BEFORE THE CODE HAS BEEN RELOCATED --
  25. * Changes to the (possibly soft) reset defaults of the processor
  26. * itself should be performed in cpu/arm<>/start.S
  27. * This function affects only the core module or board settings
  28. */
  29. #ifdef CONFIG_CM_INIT
  30. /* CM has an initialization register
  31. * - bits in it are wired into test-chip pins to force
  32. * reset defaults
  33. * - may need to change its contents for U-Boot
  34. */
  35. /* set the desired CM specific value */
  36. mov r2,#CMMASK_LOWVEC /* Vectors at 0x00000000 for all */
  37. #if defined (CONFIG_CM10200E) || defined (CONFIG_CM10220E)
  38. orr r2,r2,#CMMASK_INIT_102
  39. #else
  40. #if !defined (CONFIG_CM920T) && !defined (CONFIG_CM920T_ETM) && \
  41. !defined (CONFIG_CM940T)
  42. #ifdef CONFIG_CM_MULTIPLE_SSRAM
  43. /* set simple mapping */
  44. and r2,r2,#CMMASK_MAP_SIMPLE
  45. #endif /* #ifdef CONFIG_CM_MULTIPLE_SSRAM */
  46. #ifdef CONFIG_CM_TCRAM
  47. /* disable TCRAM */
  48. and r2,r2,#CMMASK_TCRAM_DISABLE
  49. #endif /* #ifdef CONFIG_CM_TCRAM */
  50. #if defined (CONFIG_CM926EJ_S) || defined (CONFIG_CM1026EJ_S) || \
  51. defined (CONFIG_CM1136JF_S)
  52. and r2,r2,#CMMASK_LE
  53. #endif /* cpu with little endian initialization */
  54. orr r2,r2,#CMMASK_CMxx6_COMMON
  55. #endif /* CMxx6 code */
  56. #endif /* ARM102xxE value */
  57. /* read CM_INIT */
  58. mov r0, #CM_BASE
  59. ldr r1, [r0, #OS_INIT]
  60. /* check against desired bit setting */
  61. and r3,r1,r2
  62. cmp r3,r2
  63. beq init_reg_OK
  64. /* lock for change */
  65. mov r3, #CMVAL_LOCK1
  66. add r3,r3,#CMVAL_LOCK2
  67. str r3, [r0, #OS_LOCK]
  68. /* set desired value */
  69. orr r1,r1,r2
  70. /* write & relock CM_INIT */
  71. str r1, [r0, #OS_INIT]
  72. mov r1, #CMVAL_UNLOCK
  73. str r1, [r0, #OS_LOCK]
  74. /* soft reset so new values used */
  75. b reset_cpu
  76. init_reg_OK:
  77. #endif /* CONFIG_CM_INIT */
  78. mov pc, lr
  79. #ifdef CONFIG_CM_SPD_DETECT
  80. /* Fast memory is available for the DRAM data
  81. * - ensure it has been transferred, then summarize the data
  82. * into a CM register
  83. */
  84. .globl dram_query
  85. dram_query:
  86. stmfd r13!,{r4-r6,lr}
  87. /* set up SDRAM info */
  88. /* - based on example code from the CM User Guide */
  89. mov r0, #CM_BASE
  90. readspdbit:
  91. ldr r1, [r0, #OS_SDRAM] /* read the SDRAM register */
  92. and r1, r1, #0x20 /* mask SPD bit (5) */
  93. cmp r1, #0x20 /* test if set */
  94. bne readspdbit
  95. setupsdram:
  96. add r0, r0, #OS_SPD /* address the copy of the SDP data */
  97. ldrb r1, [r0, #3] /* number of row address lines */
  98. ldrb r2, [r0, #4] /* number of column address lines */
  99. ldrb r3, [r0, #5] /* number of banks */
  100. ldrb r4, [r0, #31] /* module bank density */
  101. mul r5, r4, r3 /* size of SDRAM (MB divided by 4) */
  102. mov r5, r5, ASL#2 /* size in MB */
  103. mov r0, #CM_BASE /* reload for later code */
  104. cmp r5, #0x10 /* is it 16MB? */
  105. bne not16
  106. mov r6, #0x2 /* store size and CAS latency of 2 */
  107. b writesize
  108. not16:
  109. cmp r5, #0x20 /* is it 32MB? */
  110. bne not32
  111. mov r6, #0x6
  112. b writesize
  113. not32:
  114. cmp r5, #0x40 /* is it 64MB? */
  115. bne not64
  116. mov r6, #0xa
  117. b writesize
  118. not64:
  119. cmp r5, #0x80 /* is it 128MB? */
  120. bne not128
  121. mov r6, #0xe
  122. b writesize
  123. not128:
  124. /* if it is none of these sizes then it is either 256MB, or
  125. * there is no SDRAM fitted so default to 256MB
  126. */
  127. mov r6, #0x12
  128. writesize:
  129. mov r1, r1, ASL#8 /* row addr lines from SDRAM reg */
  130. orr r2, r1, r2, ASL#12 /* OR in column address lines */
  131. orr r3, r2, r3, ASL#16 /* OR in number of banks */
  132. orr r6, r6, r3 /* OR in size and CAS latency */
  133. str r6, [r0, #OS_SDRAM] /* store SDRAM parameters */
  134. #endif /* #ifdef CONFIG_CM_SPD_DETECT */
  135. ldmfd r13!,{r4-r6,pc} /* back to caller */
  136. #ifdef CONFIG_CM_REMAP
  137. /* CM remap bit is operational
  138. * - use it to map writeable memory at 0x00000000, in place of flash
  139. */
  140. .globl cm_remap
  141. cm_remap:
  142. stmfd r13!,{r4-r10,lr}
  143. mov r0, #CM_BASE
  144. ldr r1, [r0, #OS_CTRL]
  145. orr r1, r1, #CMMASK_REMAP /* set remap and led bits */
  146. str r1, [r0, #OS_CTRL]
  147. /* Now 0x00000000 is writeable, replace the vectors */
  148. ldr r0, =_start /* r0 <- start of vectors */
  149. add r2, r0, #64 /* r2 <- past vectors */
  150. sub r1,r1,r1 /* destination 0x00000000 */
  151. copy_vec:
  152. ldmia r0!, {r3-r10} /* copy from source address [r0] */
  153. stmia r1!, {r3-r10} /* copy to target address [r1] */
  154. cmp r0, r2 /* until source end address [r2] */
  155. ble copy_vec
  156. ldmfd r13!,{r4-r10,pc} /* back to caller */
  157. #endif /* #ifdef CONFIG_CM_REMAP */