lowlevel_init.S 5.6 KB

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