lowlevel_init.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Memory Setup stuff - taken from blob memsetup.S
  3. *
  4. * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
  5. * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
  6. *
  7. * Modified for the at91rm9200dk board by
  8. * (C) Copyright 2004
  9. * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <config.h>
  30. #include <version.h>
  31. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  32. /*
  33. * some parameters for the board
  34. *
  35. * This is based on rm9200dk.cfg for the BDI2000 from ABATRON which in
  36. * turn is based on the boot.bin code from ATMEL
  37. *
  38. */
  39. /* flash */
  40. #define MC_PUIA 0xFFFFFF10
  41. #define MC_PUP 0xFFFFFF50
  42. #define MC_PUER 0xFFFFFF54
  43. #define MC_ASR 0xFFFFFF04
  44. #define MC_AASR 0xFFFFFF08
  45. #define EBI_CFGR 0xFFFFFF64
  46. #define SMC_CSR0 0xFFFFFF70
  47. /* clocks */
  48. #define PLLAR 0xFFFFFC28
  49. #define PLLBR 0xFFFFFC2C
  50. #define MCKR 0xFFFFFC30
  51. #define AT91C_BASE_CKGR 0xFFFFFC20
  52. #define CKGR_MOR 0
  53. /* sdram */
  54. #define PIOC_ASR 0xFFFFF870
  55. #define PIOC_BSR 0xFFFFF874
  56. #define PIOC_PDR 0xFFFFF804
  57. #define EBI_CSA 0xFFFFFF60
  58. #define SDRC_CR 0xFFFFFF98
  59. #define SDRC_MR 0xFFFFFF90
  60. #define SDRC_TR 0xFFFFFF94
  61. _MTEXT_BASE:
  62. #undef START_FROM_MEM
  63. #ifdef START_FROM_MEM
  64. .word TEXT_BASE-PHYS_FLASH_1
  65. #else
  66. .word TEXT_BASE
  67. #endif
  68. .globl lowlevel_init
  69. lowlevel_init:
  70. /* Get the CKGR Base Address */
  71. ldr r1, =AT91C_BASE_CKGR
  72. /* Main oscillator Enable register */
  73. #ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR
  74. ldr r0, =0x0000FF01 /* Enable main oscillator, OSCOUNT = 0xFF */
  75. #else
  76. ldr r0, =0x0000FF00 /* Disable main oscillator, OSCOUNT = 0xFF */
  77. #endif
  78. str r0, [r1, #CKGR_MOR]
  79. /* Add loop to compensate Main Oscillator startup time */
  80. ldr r0, =0x00000010
  81. LoopOsc:
  82. subs r0, r0, #1
  83. bhi LoopOsc
  84. /* memory control configuration */
  85. /* this isn't very elegant, but what the heck */
  86. ldr r0, =SMRDATA
  87. ldr r1, _MTEXT_BASE
  88. sub r0, r0, r1
  89. add r2, r0, #80
  90. 0:
  91. /* the address */
  92. ldr r1, [r0], #4
  93. /* the value */
  94. ldr r3, [r0], #4
  95. str r3, [r1]
  96. cmp r2, r0
  97. bne 0b
  98. /* delay - this is all done by guess */
  99. ldr r0, =0x00010000
  100. 1:
  101. subs r0, r0, #1
  102. bhi 1b
  103. ldr r0, =SMRDATA1
  104. ldr r1, _MTEXT_BASE
  105. sub r0, r0, r1
  106. add r2, r0, #176
  107. 2:
  108. /* the address */
  109. ldr r1, [r0], #4
  110. /* the value */
  111. ldr r3, [r0], #4
  112. str r3, [r1]
  113. cmp r2, r0
  114. bne 2b
  115. /* switch from FastBus to Asynchronous clock mode */
  116. mrc p15, 0, r0, c1, c0, 0
  117. orr r0, r0, #0xC0000000 @ set bit 31 (iA) and 30 (nF)
  118. mcr p15, 0, r0, c1, c0, 0
  119. /* everything is fine now */
  120. mov pc, lr
  121. .ltorg
  122. SMRDATA:
  123. .word MC_PUIA
  124. .word MC_PUIA_VAL
  125. .word MC_PUP
  126. .word MC_PUP_VAL
  127. .word MC_PUER
  128. .word MC_PUER_VAL
  129. .word MC_ASR
  130. .word MC_ASR_VAL
  131. .word MC_AASR
  132. .word MC_AASR_VAL
  133. .word EBI_CFGR
  134. .word EBI_CFGR_VAL
  135. .word SMC_CSR0
  136. .word SMC_CSR0_VAL
  137. .word PLLAR
  138. .word PLLAR_VAL
  139. .word PLLBR
  140. .word PLLBR_VAL
  141. .word MCKR
  142. .word MCKR_VAL
  143. /* SMRDATA is 80 bytes long */
  144. /* here there's a delay of 100 */
  145. SMRDATA1:
  146. .word PIOC_ASR
  147. .word PIOC_ASR_VAL
  148. .word PIOC_BSR
  149. .word PIOC_BSR_VAL
  150. .word PIOC_PDR
  151. .word PIOC_PDR_VAL
  152. .word EBI_CSA
  153. .word EBI_CSA_VAL
  154. .word SDRC_CR
  155. .word SDRC_CR_VAL
  156. .word SDRC_MR
  157. .word SDRC_MR_VAL
  158. .word SDRAM
  159. .word SDRAM_VAL
  160. .word SDRC_MR
  161. .word SDRC_MR_VAL1
  162. .word SDRAM
  163. .word SDRAM_VAL
  164. .word SDRAM
  165. .word SDRAM_VAL
  166. .word SDRAM
  167. .word SDRAM_VAL
  168. .word SDRAM
  169. .word SDRAM_VAL
  170. .word SDRAM
  171. .word SDRAM_VAL
  172. .word SDRAM
  173. .word SDRAM_VAL
  174. .word SDRAM
  175. .word SDRAM_VAL
  176. .word SDRAM
  177. .word SDRAM_VAL
  178. .word SDRC_MR
  179. .word SDRC_MR_VAL2
  180. .word SDRAM1
  181. .word SDRAM_VAL
  182. .word SDRC_TR
  183. .word SDRC_TR_VAL
  184. .word SDRAM
  185. .word SDRAM_VAL
  186. .word SDRC_MR
  187. .word SDRC_MR_VAL3
  188. .word SDRAM
  189. .word SDRAM_VAL
  190. /* SMRDATA1 is 176 bytes long */
  191. #endif /* CONFIG_SKIP_LOWLEVEL_INIT */