memsetup.S 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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, <gj@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. #ifdef CONFIG_BOOTBINFUNC
  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 ATMMEL
  37. *
  38. */
  39. /* flash */
  40. #define MC_PUIA 0xFFFFFF10
  41. #define MC_PUIA_VAL 0x00000000
  42. #define MC_PUP 0xFFFFFF50
  43. #define MC_PUP_VAL 0x00000000
  44. #define MC_PUER 0xFFFFFF54
  45. #define MC_PUER_VAL 0x00000000
  46. #define MC_ASR 0xFFFFFF04
  47. #define MC_ASR_VAL 0x00000000
  48. #define MC_AASR 0xFFFFFF08
  49. #define MC_AASR_VAL 0x00000000
  50. #define EBI_CFGR 0xFFFFFF64
  51. #define EBI_CFGR_VAL 0x00000000
  52. #define SMC2_CSR 0xFFFFFF70
  53. #define SMC2_CSR_VAL 0x00003284 /* 16bit, 2 TDF, 4 WS */
  54. /* clocks */
  55. #define PLLAR 0xFFFFFC28
  56. #define PLLAR_VAL 0x20263E04 /* 179.712000 MHz for PCK */
  57. #define PLLBR 0xFFFFFC2C
  58. #define PLLBR_VAL 0x10483E0E /* 48.054857 MHz (divider by 2 for USB) */
  59. #define MCKR 0xFFFFFC30
  60. #define MCKR_VAL 0x00000202 /* PCK/3 = MCK Master Clock = 59.904000MHz from PLLA */
  61. /* sdram */
  62. #define PIOC_ASR 0xFFFFF870
  63. #define PIOC_ASR_VAL 0xFFFF0000 /* Configure PIOC as peripheral (D16/D31) */
  64. #define PIOC_BSR 0xFFFFF804
  65. #define PIOC_BSR_VAL 0x00000000
  66. #define PIOC_PDR 0xFFFFF804
  67. #define PIOC_PDR_VAL 0xFFFF0000
  68. #define EBI_CSA 0xFFFFFF60
  69. #define EBI_CSA_VAL 0x00000002 /* CS1=SDRAM */
  70. #define SDRC_CR 0xFFFFFF98
  71. #define SDRC_CR_VAL 0x2188c155
  72. #define SDRAM 0x20000000 /* address of the SDRAM */
  73. #define SDRAM1 0x20000080 /* address of the SDRAM */
  74. #define SDRAM_VAL 0x00000000 /* value written to SDRAM */
  75. #define SDRC_MR 0xFFFFFF90
  76. #define SDRC_MR_VAL 0x00000002 /* Precharge All */
  77. #define SDRC_MR_VAL1 0x00000004 /* refresh */
  78. #define SDRC_MR_VAL2 0x00000003 /* Load Mode Register */
  79. #define SDRC_MR_VAL3 0x00000000 /* Normal Mode */
  80. #define SDRC_TR 0xFFFFFF94
  81. #define SDRC_TR_VAL 0x000002E0 /* Write refresh rate */
  82. _TEXT_BASE:
  83. .word TEXT_BASE
  84. .globl memsetup
  85. memsetup:
  86. /* memory control configuration */
  87. /* this isn't very elegant, but what the heck */
  88. ldr r0, =SMRDATA
  89. ldr r1, _TEXT_BASE
  90. sub r0, r0, r1
  91. add r2, r0, #80
  92. 0:
  93. /* the address */
  94. ldr r1, [r0], #4
  95. /* the value */
  96. ldr r3, [r0], #4
  97. str r3, [r1]
  98. cmp r2, r0
  99. bne 0b
  100. /* delay - this is all done by guess */
  101. ldr r0, =0x00001000
  102. 1:
  103. subs r0, r0, #1
  104. bhi 1b
  105. ldr r0, =SMRDATA1
  106. ldr r1, _TEXT_BASE
  107. sub r0, r0, r1
  108. add r2, r0, #176
  109. 2:
  110. /* the address */
  111. ldr r1, [r0], #4
  112. /* the value */
  113. ldr r3, [r0], #4
  114. str r3, [r1]
  115. cmp r2, r0
  116. bne 2b
  117. /* everything is fine now */
  118. mov pc, lr
  119. .ltorg
  120. SMRDATA:
  121. .word MC_PUIA
  122. .word MC_PUIA_VAL
  123. .word MC_PUP
  124. .word MC_PUP_VAL
  125. .word MC_PUER
  126. .word MC_PUER_VAL
  127. .word MC_ASR
  128. .word MC_ASR_VAL
  129. .word MC_AASR
  130. .word MC_AASR_VAL
  131. .word EBI_CFGR
  132. .word EBI_CFGR_VAL
  133. .word SMC2_CSR
  134. .word SMC2_CSR_VAL
  135. .word PLLAR
  136. .word PLLAR_VAL
  137. .word PLLBR
  138. .word PLLBR_VAL
  139. .word MCKR
  140. .word MCKR_VAL
  141. /* SMRDATA is 80 bytes long */
  142. /* here there's a delay of 100 */
  143. SMRDATA1:
  144. .word PIOC_ASR
  145. .word PIOC_ASR_VAL
  146. .word PIOC_BSR
  147. .word PIOC_BSR_VAL
  148. .word PIOC_PDR
  149. .word PIOC_PDR_VAL
  150. .word EBI_CSA
  151. .word EBI_CSA_VAL
  152. .word SDRC_CR
  153. .word SDRC_CR_VAL
  154. .word SDRC_MR
  155. .word SDRC_MR_VAL
  156. .word SDRAM
  157. .word SDRAM_VAL
  158. .word SDRC_MR
  159. .word SDRC_MR_VAL1
  160. .word SDRAM
  161. .word SDRAM_VAL
  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 SDRC_MR
  177. .word SDRC_MR_VAL2
  178. .word SDRAM1
  179. .word SDRAM_VAL
  180. .word SDRC_TR
  181. .word SDRC_TR_VAL
  182. .word SDRAM
  183. .word SDRAM_VAL
  184. .word SDRC_MR
  185. .word SDRC_MR_VAL3
  186. .word SDRAM
  187. .word SDRAM_VAL
  188. /* SMRDATA1 is 176 bytes long */
  189. #endif /* CONFIG_BOOTBINFUNC */