lowlevel_init.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2007, mycable GmbH
  5. * Carsten Schneider <cs@mycable.de>, Alexander Bigga <ab@mycable.de>
  6. *
  7. * (C) Copyright 2003, ARM Ltd.
  8. * Philippe Robin, <philippe.robin@arm.com>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <config.h>
  29. #include <version.h>
  30. #include <asm/macro.h>
  31. #include <asm/arch/mb86r0x.h>
  32. #include <asm/arch/asm-offsets.h>
  33. /* Set up the platform, once the cpu has been initialized */
  34. .globl lowlevel_init
  35. lowlevel_init:
  36. /*
  37. * Initialize Clock Reset Generator (CRG)
  38. */
  39. ldr r0, =MB86R0x_CRG_BASE
  40. /* Not change the initial value that is set by external pin.*/
  41. WAIT_PLL:
  42. ldr r2, [r0, #CRG_CRPR] /* Wait for PLLREADY */
  43. tst r2, #MB86R0x_CRG_CRPR_PLLRDY
  44. beq WAIT_PLL
  45. /* Set clock gate control */
  46. ldr r1, =CONFIG_SYS_CRG_CRHA_INIT
  47. str r1, [r0, #CRG_CRHA]
  48. ldr r1, =CONFIG_SYS_CRG_CRPA_INIT
  49. str r1, [r0, #CRG_CRPA]
  50. ldr r1, =CONFIG_SYS_CRG_CRPB_INIT
  51. str r1, [r0, #CRG_CRPB]
  52. ldr r1, =CONFIG_SYS_CRG_CRHB_INIT
  53. str r1, [r0, #CRG_CRHB]
  54. ldr r1, =CONFIG_SYS_CRG_CRAM_INIT
  55. str r1, [r0, #CRG_CRAM]
  56. /*
  57. * Initialize External Bus Interface
  58. */
  59. ldr r0, =MB86R0x_MEMC_BASE
  60. ldr r1, =CONFIG_SYS_MEMC_MCFMODE0_INIT
  61. str r1, [r0, #MEMC_MCFMODE0]
  62. ldr r1, =CONFIG_SYS_MEMC_MCFMODE2_INIT
  63. str r1, [r0, #MEMC_MCFMODE2]
  64. ldr r1, =CONFIG_SYS_MEMC_MCFMODE4_INIT
  65. str r1, [r0, #MEMC_MCFMODE4]
  66. ldr r1, =CONFIG_SYS_MEMC_MCFTIM0_INIT
  67. str r1, [r0, #MEMC_MCFTIM0]
  68. ldr r1, =CONFIG_SYS_MEMC_MCFTIM2_INIT
  69. str r1, [r0, #MEMC_MCFTIM2]
  70. ldr r1, =CONFIG_SYS_MEMC_MCFTIM4_INIT
  71. str r1, [r0, #MEMC_MCFTIM4]
  72. ldr r1, =CONFIG_SYS_MEMC_MCFAREA0_INIT
  73. str r1, [r0, #MEMC_MCFAREA0]
  74. ldr r1, =CONFIG_SYS_MEMC_MCFAREA2_INIT
  75. str r1, [r0, #MEMC_MCFAREA2]
  76. ldr r1, =CONFIG_SYS_MEMC_MCFAREA4_INIT
  77. str r1, [r0, #MEMC_MCFAREA4]
  78. /*
  79. * Initialize DDR2 Controller
  80. */
  81. /* Wait for PLL LOCK up time or more */
  82. wait_timer 20
  83. /*
  84. * (2) Initialize DDRIF
  85. */
  86. ldr r0, =MB86R0x_DDR2_BASE
  87. ldr r1, =CONFIG_SYS_DDR2_DRIMS_INIT
  88. strh r1, [r0, #DDR2_DRIMS]
  89. /*
  90. * (3) Wait for 20MCKPs(120nsec) or more
  91. */
  92. wait_timer 20
  93. /*
  94. * (4) IRESET/IUSRRST release
  95. */
  96. ldr r0, =MB86R0x_CCNT_BASE
  97. ldr r1, =CONFIG_SYS_CCNT_CDCRC_INIT_1
  98. str r1, [r0, #CCNT_CDCRC]
  99. /*
  100. * (5) Wait for 20MCKPs(120nsec) or more
  101. */
  102. wait_timer 20
  103. /*
  104. * (6) IDLLRST release
  105. */
  106. ldr r0, =MB86R0x_CCNT_BASE
  107. ldr r1, =CONFIG_SYS_CCNT_CDCRC_INIT_2
  108. str r1, [r0, #CCNT_CDCRC]
  109. /*
  110. * (7+8) Wait for 200us(=200000ns) or more (DDR2 Spec)
  111. */
  112. wait_timer 33536
  113. /*
  114. * (9) MCKE ON
  115. */
  116. ldr r0, =MB86R0x_DDR2_BASE
  117. ldr r1, =CONFIG_SYS_DDR2_DRIC1_INIT
  118. strh r1, [r0, #DDR2_DRIC1]
  119. ldr r1, =CONFIG_SYS_DDR2_DRIC2_INIT
  120. strh r1, [r0, #DDR2_DRIC2]
  121. ldr r1, =CONFIG_SYS_DDR2_DRCA_INIT
  122. strh r1, [r0, #DDR2_DRCA]
  123. ldr r1, =MB86R0x_DDR2_DRCI_INIT
  124. strh r1, [r0, #DDR2_DRIC]
  125. /*
  126. * (10) Initialize SDRAM
  127. */
  128. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  129. strh r1, [r0, #DDR2_DRIC]
  130. wait_timer 67 /* 400ns wait */
  131. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_1
  132. strh r1, [r0, #DDR2_DRIC1]
  133. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_1
  134. strh r1, [r0, #DDR2_DRIC2]
  135. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  136. strh r1, [r0, #DDR2_DRIC]
  137. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_2
  138. strh r1, [r0, #DDR2_DRIC1]
  139. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_2
  140. strh r1, [r0, #DDR2_DRIC2]
  141. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  142. strh r1, [r0, #DDR2_DRIC]
  143. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_3
  144. strh r1, [r0, #DDR2_DRIC1]
  145. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_3
  146. strh r1, [r0, #DDR2_DRIC2]
  147. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  148. strh r1, [r0, #DDR2_DRIC]
  149. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_4
  150. strh r1, [r0, #DDR2_DRIC1]
  151. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_4
  152. strh r1, [r0, #DDR2_DRIC2]
  153. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  154. strh r1, [r0, #DDR2_DRIC]
  155. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_5
  156. strh r1, [r0, #DDR2_DRIC1]
  157. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_5
  158. strh r1, [r0, #DDR2_DRIC2]
  159. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  160. strh r1, [r0, #DDR2_DRIC]
  161. wait_timer 200
  162. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_6
  163. strh r1, [r0, #DDR2_DRIC1]
  164. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_6
  165. strh r1, [r0, #DDR2_DRIC2]
  166. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  167. strh r1, [r0, #DDR2_DRIC]
  168. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_7
  169. strh r1, [r0, #DDR2_DRIC1]
  170. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_7
  171. strh r1, [r0, #DDR2_DRIC2]
  172. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  173. strh r1, [r0, #DDR2_DRIC]
  174. wait_timer 18 /* 105ns wait */
  175. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_8
  176. strh r1, [r0, #DDR2_DRIC1]
  177. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_8
  178. strh r1, [r0, #DDR2_DRIC2]
  179. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  180. strh r1, [r0, #DDR2_DRIC]
  181. wait_timer 200 /* MRS to OCD: 200clock */
  182. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_9
  183. strh r1, [r0, #DDR2_DRIC1]
  184. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_9
  185. strh r1, [r0, #DDR2_DRIC2]
  186. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  187. strh r1, [r0, #DDR2_DRIC]
  188. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC1_10
  189. strh r1, [r0, #DDR2_DRIC1]
  190. ldr r1, =CONFIG_SYS_DDR2_INIT_DRIC2_10
  191. strh r1, [r0, #DDR2_DRIC2]
  192. ldr r1, =MB86R0x_DDR2_DRCI_CMD
  193. strh r1, [r0, #DDR2_DRIC]
  194. ldr r1, =CONFIG_SYS_DDR2_DRCM_INIT
  195. strh r1, [r0, #DDR2_DRCM]
  196. ldr r1, =CONFIG_SYS_DDR2_DRCST1_INIT
  197. strh r1, [r0, #DDR2_DRCST1]
  198. ldr r1, =CONFIG_SYS_DDR2_DRCST2_INIT
  199. strh r1, [r0, #DDR2_DRCST2]
  200. ldr r1, =CONFIG_SYS_DDR2_DRCR_INIT
  201. strh r1, [r0, #DDR2_DRCR]
  202. ldr r1, =CONFIG_SYS_DDR2_DRCF_INIT
  203. strh r1, [r0, #DDR2_DRCF]
  204. ldr r1, =CONFIG_SYS_DDR2_DRASR_INIT
  205. strh r1, [r0, #DDR2_DRASR]
  206. /*
  207. * (11) ODT setting
  208. */
  209. ldr r1, =CONFIG_SYS_DDR2_DROBS_INIT
  210. strh r1, [r0, #DDR2_DROBS]
  211. ldr r1, =CONFIG_SYS_DDR2_DROABA_INIT
  212. strh r1, [r0, #DDR2_DROABA]
  213. ldr r1, =CONFIG_SYS_DDR2_DRIBSODT1_INIT
  214. strh r1, [r0, #DDR2_DRIBSODT1]
  215. /*
  216. * (12) Shift to ODTCONT ON (SDRAM side) and DDR2 usual operation mode
  217. */
  218. ldr r1, =CONFIG_SYS_DDR2_DROS_INIT
  219. strh r1, [r0, #DDR2_DROS]
  220. ldr r1, =MB86R0x_DDR2_DRCI_NORMAL
  221. strh r1, [r0, #DDR2_DRIC]
  222. mov pc, lr