lowlevel_init.S 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2005-2007
  5. * Samsung Electronics,
  6. * Kyungmin Park <kyungmin.park@samsung.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <config.h>
  27. #include <version.h>
  28. #include <asm/arch/omap2420.h>
  29. #include <asm/arch/mem.h>
  30. #include <asm/arch/clocks.h>
  31. #include "mem.h"
  32. #define APOLLON_CS0_BASE 0x00000000
  33. #ifdef PRCM_CONFIG_I
  34. #define SDRC_ACTIM_CTRLA_0_VAL 0x7BA35907
  35. #define SDRC_ACTIM_CTRLB_0_VAL 0x00000013
  36. #define SDRC_RFR_CTRL_0_VAL 0x00044C01
  37. #elif defined(PRCM_CONFIG_II)
  38. #define SDRC_ACTIM_CTRLA_0_VAL 0x4A59B485
  39. #define SDRC_ACTIM_CTRLB_0_VAL 0x0000000C
  40. #define SDRC_RFR_CTRL_0_VAL 0x00030001
  41. #endif
  42. #define SDRAM_BASE_ADDRESS 0x80008000
  43. _TEXT_BASE:
  44. .word TEXT_BASE /* sdram load addr from config.mk */
  45. .globl lowlevel_init
  46. lowlevel_init:
  47. #ifdef CONFIG_SYS_NOR_BOOT
  48. /* Check running in SDRAM */
  49. mov r0, pc, lsr #28
  50. cmp r0, #8
  51. beq prcm_setup
  52. flash_setup:
  53. /* In Flash */
  54. ldr r0, =WD2_BASE
  55. ldr r1, =WD_UNLOCK1
  56. str r1, [r0, #WSPR]
  57. ldr r1, =WD_UNLOCK2
  58. str r1, [r0, #WSPR]
  59. /* Pin muxing for SDRC */
  60. mov r1, #0x00
  61. ldr r0, =0x480000A1 /* ball C12, mode 0 */
  62. strb r1, [r0]
  63. ldr r0, =0x48000032 /* ball D11, mode 0 */
  64. strb r1, [r0]
  65. ldr r0, =0x480000A3 /* ball B13, mode 0 */
  66. strb r1, [r0]
  67. /* SDRC setting */
  68. ldr r0, =OMAP2420_SDRC_BASE
  69. ldr r1, =0x00000010
  70. str r1, [r0, #0x10]
  71. ldr r1, =0x00000100
  72. str r1, [r0, #0x44]
  73. /* SDRC CS0 configuration */
  74. ldr r1, =0x00d04011
  75. str r1, [r0, #0x80]
  76. ldr r1, =SDRC_ACTIM_CTRLA_0_VAL
  77. str r1, [r0, #0x9C]
  78. ldr r1, =SDRC_ACTIM_CTRLB_0_VAL
  79. str r1, [r0, #0xA0]
  80. ldr r1, =SDRC_RFR_CTRL_0_VAL
  81. str r1, [r0, #0xA4]
  82. ldr r1, =0x00000041
  83. str r1, [r0, #0x70]
  84. /* Manual command sequence */
  85. ldr r1, =0x00000007
  86. str r1, [r0, #0xA8]
  87. ldr r1, =0x00000000
  88. str r1, [r0, #0xA8]
  89. ldr r1, =0x00000001
  90. str r1, [r0, #0xA8]
  91. ldr r1, =0x00000002
  92. str r1, [r0, #0xA8]
  93. str r1, [r0, #0xA8]
  94. /*
  95. * CS0 SDRC Mode register
  96. * Burst length = 4 - DDR memory
  97. * Serial mode
  98. * CAS latency = 3
  99. */
  100. ldr r1, =0x00000032
  101. str r1, [r0, #0x84]
  102. /* Note: You MUST set EMR values */
  103. /* EMR1 & EMR2 */
  104. ldr r1, =0x00000000
  105. str r1, [r0, #0x88]
  106. str r1, [r0, #0x8C]
  107. #ifdef OLD_SDRC_DLLA_CTRL
  108. /* SDRC_DLLA_CTRL */
  109. ldr r1, =0x00007306
  110. str r1, [r0, #0x60]
  111. ldr r1, =0x00007303
  112. str r1, [r0, #0x60]
  113. #else
  114. /* SDRC_DLLA_CTRL */
  115. ldr r1, =0x00000506
  116. str r1, [r0, #0x60]
  117. ldr r1, =0x00000503
  118. str r1, [r0, #0x60]
  119. #endif
  120. #ifdef __BROKEN_FEATURE__
  121. /* SDRC_DLLB_CTRL */
  122. ldr r1, =0x00000506
  123. str r1, [r0, #0x68]
  124. ldr r1, =0x00000503
  125. str r1, [r0, #0x68]
  126. #endif
  127. /* little delay after init */
  128. mov r2, #0x1800
  129. 1:
  130. subs r2, r2, #0x1
  131. bne 1b
  132. /* Setup base address */
  133. ldr r0, =0x00000000 /* NOR address */
  134. ldr r1, =SDRAM_BASE_ADDRESS /* SDRAM address */
  135. ldr r2, =0x20000 /* Size: 128KB */
  136. copy_loop:
  137. ldmia r0!, {r3-r10}
  138. stmia r1!, {r3-r10}
  139. cmp r0, r2
  140. ble copy_loop
  141. ldr r1, =SDRAM_BASE_ADDRESS
  142. mov lr, pc
  143. mov pc, r1
  144. #endif
  145. prcm_setup:
  146. ldr r0, =OMAP2420_CM_BASE
  147. ldr r1, [r0, #0x544] /* CLKSEL2_PLL */
  148. bic r1, r1, #0x03
  149. orr r1, r1, #0x02
  150. str r1, [r0, #0x544]
  151. ldr r1, [r0, #0x500]
  152. bic r1, r1, #0x03
  153. orr r1, r1, #0x01
  154. str r1, [r0, #0x500]
  155. ldr r1, [r0, #0x140]
  156. bic r1, r1, #0x1f
  157. orr r1, r1, #0x02
  158. str r1, [r0, #0x140]
  159. #ifdef PRCM_CONFIG_I
  160. ldr r1, =0x000003C3
  161. #else
  162. ldr r1, =0x00000343
  163. #endif
  164. str r1, [r0, #0x840]
  165. ldr r1, =0x00000002
  166. str r1, [r0, #0x340]
  167. ldr r1, =CM_CLKSEL1_CORE
  168. #ifdef PRCM_CONFIG_I
  169. ldr r2, =0x08300C44
  170. #else
  171. ldr r2, =0x04600C26
  172. #endif
  173. str r2, [r1]
  174. ldr r0, =OMAP2420_CM_BASE
  175. ldr r1, [r0, #0x084]
  176. and r1, r1, #0x01
  177. cmp r1, #0x01
  178. bne clkvalid
  179. b .
  180. clkvalid:
  181. mov r1, #0x01
  182. str r1, [r0, #0x080]
  183. waitvalid:
  184. ldr r1, [r0, #0x084]
  185. and r1, r1, #0x01
  186. cmp r1, #0x00
  187. bne waitvalid
  188. ldr r0, =CM_CLKSEL1_PLL
  189. #ifdef PRCM_CONFIG_I
  190. ldr r1, =0x01837100
  191. #else
  192. ldr r1, =0x01832100
  193. #endif
  194. str r1, [r0]
  195. ldr r0, =PRCM_CLKCFG_CTRL
  196. mov r1, #0x01
  197. str r1, [r0]
  198. mov r6, #0x50
  199. loop1:
  200. subs r6, r6, #0x01
  201. cmp r6, #0x01
  202. bne loop1
  203. ldr r0, =CM_CLKEN_PLL
  204. mov r1, #0x0f
  205. str r1, [r0]
  206. mov r6, #0x100
  207. loop2:
  208. subs r6, r6, #0x01
  209. cmp r6, #0x01
  210. bne loop2
  211. ldr r0, =0x48008200
  212. ldr r1, =0xbfffffff
  213. str r1, [r0]
  214. ldr r0, =0x48008210
  215. ldr r1, =0xfffffff9
  216. str r1, [r0]
  217. ldr r0, =0x4806a004
  218. ldr r1, =0x00
  219. strb r1, [r0]
  220. ldr r0, =0x4806a020
  221. ldr r1, =0x07
  222. strb r1, [r0]
  223. ldr r0, =0x4806a00c
  224. ldr r1, =0x83
  225. strb r1, [r0]
  226. ldr r0, =0x4806a000
  227. ldr r1, =0x1a
  228. strb r1, [r0]
  229. ldr r0, =0x4806a004
  230. ldr r1, =0x00
  231. strb r1, [r0]
  232. ldr r0, =0x4806a00c
  233. ldr r1, =0x03
  234. strb r1, [r0]
  235. ldr r0, =0x4806a010
  236. ldr r1, =0x03
  237. strb r1, [r0]
  238. ldr r0, =0x4806a008
  239. ldr r1, =0x04
  240. strb r1, [r0]
  241. ldr r0, =0x4806a020
  242. ldr r1, =0x00
  243. strb r1, [r0]
  244. #if 0
  245. ldr r0, =0x4806a000
  246. mov r1, #'u'
  247. strb r1, [r0]
  248. #endif
  249. #if 0
  250. /* LED0 OFF */
  251. ldr r3, =0x480000E5
  252. mov r4, #0x0b
  253. strb r4, [r3]
  254. #endif
  255. ldr sp, SRAM_STACK
  256. str ip, [sp] /* stash old link register */
  257. mov ip, lr /* save link reg across call */
  258. bl s_init /* go setup pll,mux,memory */
  259. ldr ip, [sp] /* restore save ip */
  260. mov lr, ip /* restore link reg */
  261. /* map interrupt controller */
  262. ldr r0, VAL_INTH_SETUP
  263. mcr p15, 0, r0, c15, c2, 4
  264. /* back to arch calling code */
  265. mov pc, lr
  266. /* the literal pools origin */
  267. .ltorg
  268. VAL_INTH_SETUP:
  269. .word PERIFERAL_PORT_BASE
  270. SRAM_STACK:
  271. .word LOW_LEVEL_SRAM_STACK