lowlevel_init.S 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. #include <asm/arch/AT91RM9200.h>
  40. _MTEXT_BASE:
  41. #undef START_FROM_MEM
  42. #ifdef START_FROM_MEM
  43. .word TEXT_BASE-PHYS_FLASH_1
  44. #else
  45. .word TEXT_BASE
  46. #endif
  47. .globl lowlevel_init
  48. lowlevel_init:
  49. /* Get the CKGR Base Address */
  50. ldr r1, =AT91C_BASE_CKGR
  51. /* Main oscillator Enable register */
  52. #ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR
  53. ldr r0, =0x0000FF01 /* Enable main oscillator, OSCOUNT = 0xFF */
  54. #else
  55. ldr r0, =0x0000FF00 /* Disable main oscillator, OSCOUNT = 0xFF */
  56. #endif
  57. str r0, [r1, #AT91C_CKGR_MOR]
  58. /* Add loop to compensate Main Oscillator startup time */
  59. ldr r0, =0x00000010
  60. LoopOsc:
  61. subs r0, r0, #1
  62. bhi LoopOsc
  63. /* memory control configuration */
  64. /* this isn't very elegant, but what the heck */
  65. ldr r0, =SMRDATA
  66. ldr r1, _MTEXT_BASE
  67. sub r0, r0, r1
  68. add r2, r0, #80
  69. 0:
  70. /* the address */
  71. ldr r1, [r0], #4
  72. /* the value */
  73. ldr r3, [r0], #4
  74. str r3, [r1]
  75. cmp r2, r0
  76. bne 0b
  77. /* delay - this is all done by guess */
  78. ldr r0, =0x00010000
  79. 1:
  80. subs r0, r0, #1
  81. bhi 1b
  82. ldr r0, =SMRDATA1
  83. ldr r1, _MTEXT_BASE
  84. sub r0, r0, r1
  85. add r2, r0, #176
  86. 2:
  87. /* the address */
  88. ldr r1, [r0], #4
  89. /* the value */
  90. ldr r3, [r0], #4
  91. str r3, [r1]
  92. cmp r2, r0
  93. bne 2b
  94. /* switch from FastBus to Asynchronous clock mode */
  95. mrc p15, 0, r0, c1, c0, 0
  96. orr r0, r0, #0xC0000000 @ set bit 31 (iA) and 30 (nF)
  97. mcr p15, 0, r0, c1, c0, 0
  98. /* everything is fine now */
  99. mov pc, lr
  100. .ltorg
  101. SMRDATA:
  102. .word AT91C_MC_PUIA
  103. .word CONFIG_SYS_MC_PUIA_VAL
  104. .word AT91C_MC_PUP
  105. .word CONFIG_SYS_MC_PUP_VAL
  106. .word AT91C_MC_PUER
  107. .word CONFIG_SYS_MC_PUER_VAL
  108. .word AT91C_MC_ASR
  109. .word CONFIG_SYS_MC_ASR_VAL
  110. .word AT91C_MC_AASR
  111. .word CONFIG_SYS_MC_AASR_VAL
  112. .word AT91C_EBI_CFGR
  113. .word CONFIG_SYS_EBI_CFGR_VAL
  114. .word AT91C_SMC_CSR0
  115. .word CONFIG_SYS_SMC_CSR0_VAL
  116. .word AT91C_PLLAR
  117. .word CONFIG_SYS_PLLAR_VAL
  118. .word AT91C_PLLBR
  119. .word CONFIG_SYS_PLLBR_VAL
  120. .word AT91C_MCKR
  121. .word CONFIG_SYS_MCKR_VAL
  122. /* SMRDATA is 80 bytes long */
  123. /* here there's a delay of 100 */
  124. SMRDATA1:
  125. .word AT91C_PIOC_ASR
  126. .word CONFIG_SYS_PIOC_ASR_VAL
  127. .word AT91C_PIOC_BSR
  128. .word CONFIG_SYS_PIOC_BSR_VAL
  129. .word AT91C_PIOC_PDR
  130. .word CONFIG_SYS_PIOC_PDR_VAL
  131. .word AT91C_EBI_CSA
  132. .word CONFIG_SYS_EBI_CSA_VAL
  133. .word AT91C_SDRC_CR
  134. .word CONFIG_SYS_SDRC_CR_VAL
  135. .word AT91C_SDRC_MR
  136. .word CONFIG_SYS_SDRC_MR_VAL
  137. .word CONFIG_SYS_SDRAM
  138. .word CONFIG_SYS_SDRAM_VAL
  139. .word AT91C_SDRC_MR
  140. .word CONFIG_SYS_SDRC_MR_VAL1
  141. .word CONFIG_SYS_SDRAM
  142. .word CONFIG_SYS_SDRAM_VAL
  143. .word CONFIG_SYS_SDRAM
  144. .word CONFIG_SYS_SDRAM_VAL
  145. .word CONFIG_SYS_SDRAM
  146. .word CONFIG_SYS_SDRAM_VAL
  147. .word CONFIG_SYS_SDRAM
  148. .word CONFIG_SYS_SDRAM_VAL
  149. .word CONFIG_SYS_SDRAM
  150. .word CONFIG_SYS_SDRAM_VAL
  151. .word CONFIG_SYS_SDRAM
  152. .word CONFIG_SYS_SDRAM_VAL
  153. .word CONFIG_SYS_SDRAM
  154. .word CONFIG_SYS_SDRAM_VAL
  155. .word CONFIG_SYS_SDRAM
  156. .word CONFIG_SYS_SDRAM_VAL
  157. .word AT91C_SDRC_MR
  158. .word CONFIG_SYS_SDRC_MR_VAL2
  159. .word CONFIG_SYS_SDRAM1
  160. .word CONFIG_SYS_SDRAM_VAL
  161. .word AT91C_SDRC_TR
  162. .word CONFIG_SYS_SDRC_TR_VAL
  163. .word CONFIG_SYS_SDRAM
  164. .word CONFIG_SYS_SDRAM_VAL
  165. .word AT91C_SDRC_MR
  166. .word CONFIG_SYS_SDRC_MR_VAL3
  167. .word CONFIG_SYS_SDRAM
  168. .word CONFIG_SYS_SDRAM_VAL
  169. /* SMRDATA1 is 176 bytes long */
  170. #endif /* CONFIG_SKIP_LOWLEVEL_INIT */