lowlevel_init.S 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2003-2004
  5. *
  6. * Texas Instruments, <www.ti.com>
  7. * Kshitij Gupta <Kshitij@ti.com>
  8. *
  9. * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004
  10. *
  11. * Modified for OMAP730 P2 Board by Dave Peverley, MPC-Data Limited
  12. * (http://www.mpc-data.co.uk)
  13. *
  14. * TODO : Tidy up and change to use system register defines
  15. * from omap730.h where possible.
  16. *
  17. * See file CREDITS for list of people who contributed to this
  18. * project.
  19. *
  20. * This program is free software; you can redistribute it and/or
  21. * modify it under the terms of the GNU General Public License as
  22. * published by the Free Software Foundation; either version 2 of
  23. * the License, or (at your option) any later version.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU General Public License
  31. * along with this program; if not, write to the Free Software
  32. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33. * MA 02111-1307 USA
  34. */
  35. #include <config.h>
  36. #include <version.h>
  37. #if defined(CONFIG_OMAP730)
  38. #include <./configs/omap730.h>
  39. #endif
  40. _TEXT_BASE:
  41. .word TEXT_BASE /* sdram load addr from config.mk */
  42. .globl lowlevel_init
  43. lowlevel_init:
  44. /* Save callers address in r11 - r11 must never be modified */
  45. mov r11, lr
  46. /*------------------------------------------------------*
  47. *mask all IRQs by setting all bits in the INTMR default*
  48. *------------------------------------------------------*/
  49. mov r1, #0xffffffff
  50. ldr r0, =REG_IHL1_MIR
  51. str r1, [r0]
  52. ldr r0, =REG_IHL2_MIR
  53. str r1, [r0]
  54. /*------------------------------------------------------*
  55. * Set up ARM CLM registers (IDLECT1) *
  56. *------------------------------------------------------*/
  57. ldr r0, REG_ARM_IDLECT1
  58. ldr r1, VAL_ARM_IDLECT1
  59. str r1, [r0]
  60. /*------------------------------------------------------*
  61. * Set up ARM CLM registers (IDLECT2) *
  62. *------------------------------------------------------*/
  63. ldr r0, REG_ARM_IDLECT2
  64. ldr r1, VAL_ARM_IDLECT2
  65. str r1, [r0]
  66. /*------------------------------------------------------*
  67. * Set up ARM CLM registers (IDLECT3) *
  68. *------------------------------------------------------*/
  69. ldr r0, REG_ARM_IDLECT3
  70. ldr r1, VAL_ARM_IDLECT3
  71. str r1, [r0]
  72. mov r1, #0x01 /* PER_EN bit */
  73. ldr r0, REG_ARM_RSTCT2
  74. strh r1, [r0] /* CLKM; Peripheral reset. */
  75. /* Set CLKM to Sync-Scalable */
  76. /* I supposedly need to enable the dsp clock before switching */
  77. mov r1, #0x1000
  78. ldr r0, REG_ARM_SYSST
  79. strh r1, [r0]
  80. mov r0, #0x400
  81. 1:
  82. subs r0, r0, #0x1 /* wait for any bubbles to finish */
  83. bne 1b
  84. ldr r1, VAL_ARM_CKCTL
  85. ldr r0, REG_ARM_CKCTL
  86. strh r1, [r0]
  87. /* a few nops to let settle */
  88. nop
  89. nop
  90. nop
  91. nop
  92. nop
  93. nop
  94. nop
  95. nop
  96. nop
  97. nop
  98. /* setup DPLL 1 */
  99. /* Ramp up the clock to 96Mhz */
  100. ldr r1, VAL_DPLL1_CTL
  101. ldr r0, REG_DPLL1_CTL
  102. strh r1, [r0]
  103. ands r1, r1, #0x10 /* Check if PLL is enabled. */
  104. beq lock_end /* Do not look for lock if BYPASS selected */
  105. 2:
  106. ldrh r1, [r0]
  107. ands r1, r1, #0x01 /* Check the LOCK bit.*/
  108. beq 2b /* loop until bit goes hi. */
  109. lock_end:
  110. /*------------------------------------------------------*
  111. * Turn off the watchdog during init... *
  112. *------------------------------------------------------*/
  113. ldr r0, REG_WATCHDOG
  114. ldr r1, WATCHDOG_VAL1
  115. str r1, [r0]
  116. ldr r1, WATCHDOG_VAL2
  117. str r1, [r0]
  118. ldr r0, REG_WSPRDOG
  119. ldr r1, WSPRDOG_VAL1
  120. str r1, [r0]
  121. ldr r0, REG_WWPSDOG
  122. watch1Wait:
  123. ldr r1, [r0]
  124. tst r1, #0x10
  125. bne watch1Wait
  126. ldr r0, REG_WSPRDOG
  127. ldr r1, WSPRDOG_VAL2
  128. str r1, [r0]
  129. ldr r0, REG_WWPSDOG
  130. watch2Wait:
  131. ldr r1, [r0]
  132. tst r1, #0x10
  133. bne watch2Wait
  134. /* Set memory timings corresponding to the new clock speed */
  135. /* Check execution location to determine current execution location
  136. * and branch to appropriate initialization code.
  137. */
  138. /* Compare physical SDRAM base & current execution location. */
  139. and r0, pc, #0xF0000000
  140. /* Compare. */
  141. cmp r0, #0
  142. /* Skip over EMIF-fast initialization if running from SDRAM. */
  143. bne skip_sdram
  144. /*
  145. * Delay for SDRAM initialization.
  146. */
  147. mov r3, #0x1800 /* value should be checked */
  148. 3:
  149. subs r3, r3, #0x1 /* Decrement count */
  150. bne 3b
  151. ldr r0, REG_SDRAM_CONFIG
  152. ldr r1, SDRAM_CONFIG_VAL
  153. str r1, [r0]
  154. ldr r0, REG_SDRAM_MRS_LEGACY
  155. ldr r1, SDRAM_MRS_VAL
  156. str r1, [r0]
  157. skip_sdram:
  158. common_tc:
  159. /* slow interface */
  160. ldr r1, VAL_TC_EMIFS_CS0_CONFIG
  161. ldr r0, REG_TC_EMIFS_CS0_CONFIG
  162. str r1, [r0] /* Chip Select 0 */
  163. ldr r1, VAL_TC_EMIFS_CS1_CONFIG
  164. ldr r0, REG_TC_EMIFS_CS1_CONFIG
  165. str r1, [r0] /* Chip Select 1 */
  166. ldr r1, VAL_TC_EMIFS_CS2_CONFIG
  167. ldr r0, REG_TC_EMIFS_CS2_CONFIG
  168. str r1, [r0] /* Chip Select 2 */
  169. ldr r1, VAL_TC_EMIFS_CS3_CONFIG
  170. ldr r0, REG_TC_EMIFS_CS3_CONFIG
  171. str r1, [r0] /* Chip Select 3 */
  172. /* 48MHz clock request for UART1 */
  173. ldr r1, PERSEUS2_CONFIG_BASE
  174. ldrh r0, [r1, #CONFIG_PCC_CONF]
  175. orr r0, r0, #CONF_MOD_UART1_CLK_MODE_R
  176. strh r0, [r1, #CONFIG_PCC_CONF]
  177. /* Initialize public and private rheas
  178. * - set access factor 2 on both rhea / strobe
  179. * - disable write buffer on strb0, enable write buffer on strb1
  180. */
  181. ldr R0, REG_RHEA_PUB_CTL
  182. ldr R1, REG_RHEA_PRIV_CTL
  183. ldr R2, VAL_RHEA_CTL
  184. strh R2, [R0]
  185. strh R2, [R1]
  186. mov R3, #2 /* disable write buffer on strb0, enable write buffer on strb1 */
  187. strh R3, [R0, #0x08] /* arm rhea control reg */
  188. strh R3, [R1, #0x08]
  189. /* enable IRQ and FIQ */
  190. mrs r4, CPSR
  191. bic r4, r4, #IRQ_MASK
  192. bic r4, r4, #FIQ_MASK
  193. msr CPSR, r4
  194. /* set TAP CONF to TRI EMULATION */
  195. ldr r1, [r0, #CONFIG_MODE2]
  196. bic r1, r1, #0x18
  197. orr r1, r1, #0x10
  198. str r1, [r0, #CONFIG_MODE2]
  199. /* set tdbgen to 1 */
  200. ldr r0, PERSEUS2_CONFIG_BASE
  201. ldr r1, [r0, #CONFIG_MODE1]
  202. mov r2, #0x10000
  203. orr r1, r1, r2
  204. str r1, [r0, #CONFIG_MODE1]
  205. #ifdef CONFIG_P2_OMAP1610
  206. /* inserting additional 2 clock cycle hold time for LAN */
  207. ldr r0, REG_TC_EMIFS_CS1_ADVANCED
  208. ldr r1, VAL_TC_EMIFS_CS1_ADVANCED
  209. str r1, [r0]
  210. #endif
  211. /* Start MPU Timer 1 */
  212. ldr r0, REG_MPU_LOAD_TIMER
  213. ldr r1, VAL_MPU_LOAD_TIMER
  214. str r1, [r0]
  215. ldr r0, REG_MPU_CNTL_TIMER
  216. ldr r1, VAL_MPU_CNTL_TIMER
  217. str r1, [r0]
  218. /* back to arch calling code */
  219. mov pc, r11
  220. /* the literal pools origin */
  221. .ltorg
  222. REG_TC_EMIFS_CONFIG: /* 32 bits */
  223. .word 0xfffecc0c
  224. REG_TC_EMIFS_CS0_CONFIG: /* 32 bits */
  225. .word 0xfffecc10
  226. REG_TC_EMIFS_CS1_CONFIG: /* 32 bits */
  227. .word 0xfffecc14
  228. REG_TC_EMIFS_CS2_CONFIG: /* 32 bits */
  229. .word 0xfffecc18
  230. REG_TC_EMIFS_CS3_CONFIG: /* 32 bits */
  231. .word 0xfffecc1c
  232. #ifdef CONFIG_P2_OMAP730
  233. REG_TC_EMIFS_CS1_ADVANCED: /* 32 bits */
  234. .word 0xfffecc54
  235. #endif
  236. /* MPU clock/reset/power mode control registers */
  237. REG_ARM_CKCTL: /* 16 bits */
  238. .word 0xfffece00
  239. REG_ARM_IDLECT3: /* 16 bits */
  240. .word 0xfffece24
  241. REG_ARM_IDLECT2: /* 16 bits */
  242. .word 0xfffece08
  243. REG_ARM_IDLECT1: /* 16 bits */
  244. .word 0xfffece04
  245. REG_ARM_RSTCT2: /* 16 bits */
  246. .word 0xfffece14
  247. REG_ARM_SYSST: /* 16 bits */
  248. .word 0xfffece18
  249. /* DPLL control registers */
  250. REG_DPLL1_CTL: /* 16 bits */
  251. .word 0xfffecf00
  252. /* Watch Dog register */
  253. /* secure watchdog stop */
  254. REG_WSPRDOG:
  255. .word 0xfffeb048
  256. /* watchdog write pending */
  257. REG_WWPSDOG:
  258. .word 0xfffeb034
  259. WSPRDOG_VAL1:
  260. .word 0x0000aaaa
  261. WSPRDOG_VAL2:
  262. .word 0x00005555
  263. /* SDRAM config is: auto refresh enabled, 16 bit 4 bank,
  264. counter @8192 rows, 10 ns, 8 burst */
  265. REG_SDRAM_CONFIG:
  266. .word 0xfffecc20
  267. REG_SDRAM_MRS_LEGACY:
  268. .word 0xfffecc24
  269. REG_WATCHDOG:
  270. .word 0xfffec808
  271. REG_MPU_LOAD_TIMER:
  272. .word 0xfffec504
  273. REG_MPU_CNTL_TIMER:
  274. .word 0xfffec500
  275. /* Public and private rhea bridge registers definition */
  276. REG_RHEA_PUB_CTL:
  277. .word 0xFFFECA00
  278. REG_RHEA_PRIV_CTL:
  279. .word 0xFFFED300
  280. /* EMIFF SDRAM Configuration register
  281. - self refresh disable
  282. - auto refresh enabled
  283. - SDRAM type 64 Mb, 16 bits bus 4 banks
  284. - power down enabled
  285. - SDRAM clock disabled
  286. */
  287. SDRAM_CONFIG_VAL:
  288. .word 0x0C017DF4
  289. /* Burst full page length ; cas latency = 3 */
  290. SDRAM_MRS_VAL:
  291. .word 0x00000037
  292. VAL_ARM_CKCTL:
  293. .word 0x6505
  294. VAL_DPLL1_CTL:
  295. .word 0x3412
  296. #ifdef CONFIG_P2_OMAP730
  297. VAL_TC_EMIFS_CS0_CONFIG:
  298. .word 0x0000FFF3
  299. VAL_TC_EMIFS_CS1_CONFIG:
  300. .word 0x00004278
  301. VAL_TC_EMIFS_CS2_CONFIG:
  302. .word 0x00004278
  303. VAL_TC_EMIFS_CS3_CONFIG:
  304. .word 0x00004278
  305. VAL_TC_EMIFS_CS1_ADVANCED:
  306. .word 0x00000022
  307. #endif
  308. VAL_ARM_IDLECT1:
  309. .word 0x00000400
  310. VAL_ARM_IDLECT2:
  311. .word 0x00000886
  312. VAL_ARM_IDLECT3:
  313. .word 0x00000015
  314. WATCHDOG_VAL1:
  315. .word 0x000000f5
  316. WATCHDOG_VAL2:
  317. .word 0x000000a0
  318. VAL_MPU_LOAD_TIMER:
  319. .word 0xffffffff
  320. VAL_MPU_CNTL_TIMER:
  321. .word 0xffffffa1
  322. VAL_RHEA_CTL:
  323. .word 0xFF22
  324. /* Config Register vals */
  325. PERSEUS2_CONFIG_BASE:
  326. .word 0xFFFE1000
  327. .equ CONFIG_PCC_CONF, 0xB4
  328. .equ CONFIG_MODE1, 0x10
  329. .equ CONFIG_MODE2, 0x14
  330. .equ CONF_MOD_UART1_CLK_MODE_R, 0x0A
  331. /* misc values */
  332. .equ IRQ_MASK, 0x80 /* IRQ mask value */
  333. .equ FIQ_MASK, 0x40 /* FIQ mask value */