lowlevel_init.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2003
  5. * Texas Instruments, <www.ti.com>
  6. *
  7. * -- Some bits of code used from rrload's head_OMAP1510.s --
  8. * Copyright (C) 2002 RidgeRun, Inc.
  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. #if defined(CONFIG_OMAP1510)
  31. #include <./configs/omap1510.h>
  32. #endif
  33. #define OMAP1510_CLKS ((1<<EN_XORPCK)|(1<<EN_PERCK)|(1<<EN_TIMCK)|(1<<EN_GPIOCK))
  34. _TEXT_BASE:
  35. .word TEXT_BASE /* sdram load addr from config.mk */
  36. .globl lowlevel_init
  37. lowlevel_init:
  38. /*
  39. * Configure 1510 pins functions to match our board.
  40. */
  41. ldr r0, REG_PULL_DWN_CTRL_0
  42. ldr r1, VAL_PULL_DWN_CTRL_0
  43. str r1, [r0]
  44. ldr r0, REG_PULL_DWN_CTRL_1
  45. ldr r1, VAL_PULL_DWN_CTRL_1
  46. str r1, [r0]
  47. ldr r0, REG_PULL_DWN_CTRL_2
  48. ldr r1, VAL_PULL_DWN_CTRL_2
  49. str r1, [r0]
  50. ldr r0, REG_PULL_DWN_CTRL_3
  51. ldr r1, VAL_PULL_DWN_CTRL_3
  52. str r1, [r0]
  53. ldr r0, REG_FUNC_MUX_CTRL_4
  54. ldr r1, VAL_FUNC_MUX_CTRL_4
  55. str r1, [r0]
  56. ldr r0, REG_FUNC_MUX_CTRL_5
  57. ldr r1, VAL_FUNC_MUX_CTRL_5
  58. str r1, [r0]
  59. ldr r0, REG_FUNC_MUX_CTRL_6
  60. ldr r1, VAL_FUNC_MUX_CTRL_6
  61. str r1, [r0]
  62. ldr r0, REG_FUNC_MUX_CTRL_7
  63. ldr r1, VAL_FUNC_MUX_CTRL_7
  64. str r1, [r0]
  65. ldr r0, REG_FUNC_MUX_CTRL_8
  66. ldr r1, VAL_FUNC_MUX_CTRL_8
  67. str r1, [r0]
  68. ldr r0, REG_FUNC_MUX_CTRL_9
  69. ldr r1, VAL_FUNC_MUX_CTRL_9
  70. str r1, [r0]
  71. ldr r0, REG_FUNC_MUX_CTRL_A
  72. ldr r1, VAL_FUNC_MUX_CTRL_A
  73. str r1, [r0]
  74. ldr r0, REG_FUNC_MUX_CTRL_B
  75. ldr r1, VAL_FUNC_MUX_CTRL_B
  76. str r1, [r0]
  77. ldr r0, REG_FUNC_MUX_CTRL_C
  78. ldr r1, VAL_FUNC_MUX_CTRL_C
  79. str r1, [r0]
  80. ldr r0, REG_FUNC_MUX_CTRL_D
  81. ldr r1, VAL_FUNC_MUX_CTRL_D
  82. str r1, [r0]
  83. ldr r0, REG_VOLTAGE_CTRL_0
  84. ldr r1, VAL_VOLTAGE_CTRL_0
  85. str r1, [r0]
  86. ldr r0, REG_TEST_DBG_CTRL_0
  87. ldr r1, VAL_TEST_DBG_CTRL_0
  88. str r1, [r0]
  89. ldr r0, REG_MOD_CONF_CTRL_0
  90. ldr r1, VAL_MOD_CONF_CTRL_0
  91. str r1, [r0]
  92. /* Move to 1510 mode */
  93. ldr r0, REG_COMP_MODE_CTRL_0
  94. ldr r1, VAL_COMP_MODE_CTRL_0
  95. str r1, [r0]
  96. /* Set up Traffic Ctlr*/
  97. ldr r0, REG_TC_IMIF_PRIO
  98. mov r1, #0x0
  99. str r1, [r0]
  100. ldr r0, REG_TC_EMIFS_PRIO
  101. str r1, [r0]
  102. ldr r0, REG_TC_EMIFF_PRIO
  103. str r1, [r0]
  104. ldr r0, REG_TC_EMIFS_CONFIG
  105. ldr r1, [r0]
  106. bic r1, r1, #0x08 /* clear the global power-down enable PDE bit */
  107. bic r1, r1, #0x01 /* write protect flash by clearing the WP bit */
  108. str r1, [r0] /* EMIFS GlB Configuration. (value 0x12 most likely) */
  109. /* Setup some clock domains */
  110. ldr r1, =OMAP1510_CLKS
  111. ldr r0, REG_ARM_IDLECT2
  112. strh r1, [r0] /* CLKM, Clock domain control. */
  113. mov r1, #0x01 /* PER_EN bit */
  114. ldr r0, REG_ARM_RSTCT2
  115. strh r1, [r0] /* CLKM; Peripheral reset. */
  116. /* Set CLKM to Sync-Scalable */
  117. /* I supposidly need to enable the dsp clock before switching */
  118. mov r1, #0x1000
  119. ldr r0, REG_ARM_SYSST
  120. strh r1, [r0]
  121. mov r0, #0x400
  122. 1:
  123. subs r0, r0, #0x1 /* wait for any bubbles to finish */
  124. bne 1b
  125. ldr r1, VAL_ARM_CKCTL /* use 12Mhz ref, PER must be <= 50Mhz so /2 */
  126. ldr r0, REG_ARM_CKCTL
  127. strh r1, [r0]
  128. /* setup DPLL 1 */
  129. ldr r1, VAL_DPLL1_CTL
  130. ldr r0, REG_DPLL1_CTL
  131. strh r1, [r0]
  132. ands r1, r1, #0x10 /* Check if PLL is enabled. */
  133. beq lock_end /* Do not look for lock if BYPASS selected */
  134. 2:
  135. ldrh r1, [r0]
  136. ands r1, r1, #0x01 /* Check the LOCK bit. */
  137. beq 2b /* ...loop until bit goes hi. */
  138. lock_end:
  139. /* Set memory timings corresponding to the new clock speed */
  140. /* Check execution location to determine current execution location
  141. * and branch to appropriate initialization code.
  142. */
  143. mov r0, #0x10000000 /* Load physical SDRAM base. */
  144. mov r1, pc /* Get current execution location. */
  145. /* Zero all but top 6 bits of PC, as they alone detect whether an
  146. * address is in the range 0x1000:0000-0x13ff:ffff, the 64M sized
  147. * valid range for SDRAM on the OMAP 1510/5910.
  148. */
  149. and r1, r1, #0xfc000000
  150. cmp r1, r0 /* Compare. */
  151. beq skip_sdram /* Skip over EMIF-fast initialization
  152. * if running from SDRAM.
  153. */
  154. /*
  155. * Delay for SDRAM initialization.
  156. */
  157. mov r3, #0x1800 /* value should be checked */
  158. 3:
  159. subs r3, r3, #0x1 /* Decrement count */
  160. bne 3b
  161. /*
  162. * Set SDRAM control values. Disable refresh before MRS command.
  163. */
  164. ldr r0, VAL_TC_EMIFF_SDRAM_CONFIG /* get good value */
  165. bic r3, r0, #0xC /* (BIT3|BIT2) ulConfig with auto-refresh disabled. */
  166. orr r3, r3, #0x8000000 /* (BIT27) Disable CLK when Power down or Self-Refresh */
  167. orr r3, r3, #0x4000000 /* BIT26 Power Down Enable */
  168. ldr r2, REG_TC_EMIFF_SDRAM_CONFIG /* Point to configuration register. */
  169. str r3, [r2] /* Store the passed value with AR disabled. */
  170. ldr r1, VAL_TC_EMIFF_MRS /* get MRS value */
  171. ldr r2, REG_TC_EMIFF_MRS /* Point to MRS register. */
  172. str r1, [r2] /* Store the passed value.*/
  173. ldr r2, REG_TC_EMIFF_SDRAM_CONFIG /* Point to configuration register. */
  174. str r0, [r2] /* Store the passed value. */
  175. /*
  176. * Delay for SDRAM initialization.
  177. */
  178. mov r3, #0x1800
  179. 4:
  180. subs r3, r3, #1 /* Decrement count. */
  181. bne 4b
  182. skip_sdram:
  183. /* slow interface */
  184. ldr r1, VAL_TC_EMIFS_CS0_CONFIG
  185. ldr r0, REG_TC_EMIFS_CS0_CONFIG
  186. str r1, [r0] /* Chip Select 0 */
  187. ldr r1, VAL_TC_EMIFS_CS1_CONFIG
  188. ldr r0, REG_TC_EMIFS_CS1_CONFIG
  189. str r1, [r0] /* Chip Select 1 */
  190. ldr r1, VAL_TC_EMIFS_CS2_CONFIG
  191. ldr r0, REG_TC_EMIFS_CS2_CONFIG
  192. str r1, [r0] /* Chip Select 2 */
  193. ldr r1, VAL_TC_EMIFS_CS3_CONFIG
  194. ldr r0, REG_TC_EMIFS_CS3_CONFIG
  195. str r1, [r0] /* Chip Select 3 */
  196. /* Next, Enable the RS232 Line Drivers in the FPGA. */
  197. /* Also, power on the audio CODEC's amplifier here, */
  198. /* which will make a noise on the audio output. */
  199. /* This is done here instead of in the kernel so there */
  200. /* isn't a loud popping noise at the start of each */
  201. /* song. */
  202. /* Also, disable the CODEC's clocks. */
  203. /* omap1510-HelenP1 [specific] */
  204. ldr r0, REG_FPGA_POWER
  205. mov r1, #0
  206. ldr r2, REG_FPGA_DIP_SWITCH
  207. ldrb r3, [r2]
  208. cmp r3, #0x8
  209. movne r1, #0x62 /* Enable the RS232 Line Drivers in the EPLD */
  210. strb r1, [r0]
  211. ldr r0, REG_FPGA_AUDIO
  212. mov r1, #0x0 /* Disable sound driver (CODEC clocks) */
  213. strb r1, [r0]
  214. /* back to arch calling code */
  215. mov pc, lr
  216. /* the literal pools origin */
  217. .ltorg
  218. /* OMAP configuration registers */
  219. REG_FUNC_MUX_CTRL_0: /* 32 bits */
  220. .word 0xfffe1000
  221. REG_FUNC_MUX_CTRL_1: /* 32 bits */
  222. .word 0xfffe1004
  223. REG_FUNC_MUX_CTRL_2: /* 32 bits */
  224. .word 0xfffe1008
  225. REG_COMP_MODE_CTRL_0: /* 32 bits */
  226. .word 0xfffe100c
  227. REG_FUNC_MUX_CTRL_3: /* 32 bits */
  228. .word 0xfffe1010
  229. REG_FUNC_MUX_CTRL_4: /* 32 bits */
  230. .word 0xfffe1014
  231. REG_FUNC_MUX_CTRL_5: /* 32 bits */
  232. .word 0xfffe1018
  233. REG_FUNC_MUX_CTRL_6: /* 32 bits */
  234. .word 0xfffe101c
  235. REG_FUNC_MUX_CTRL_7: /* 32 bits */
  236. .word 0xfffe1020
  237. REG_FUNC_MUX_CTRL_8: /* 32 bits */
  238. .word 0xfffe1024
  239. REG_FUNC_MUX_CTRL_9: /* 32 bits */
  240. .word 0xfffe1028
  241. REG_FUNC_MUX_CTRL_A: /* 32 bits */
  242. .word 0xfffe102C
  243. REG_FUNC_MUX_CTRL_B: /* 32 bits */
  244. .word 0xfffe1030
  245. REG_FUNC_MUX_CTRL_C: /* 32 bits */
  246. .word 0xfffe1034
  247. REG_FUNC_MUX_CTRL_D: /* 32 bits */
  248. .word 0xfffe1038
  249. REG_PULL_DWN_CTRL_0: /* 32 bits */
  250. .word 0xfffe1040
  251. REG_PULL_DWN_CTRL_1: /* 32 bits */
  252. .word 0xfffe1044
  253. REG_PULL_DWN_CTRL_2: /* 32 bits */
  254. .word 0xfffe1048
  255. REG_PULL_DWN_CTRL_3: /* 32 bits */
  256. .word 0xfffe104c
  257. REG_VOLTAGE_CTRL_0: /* 32 bits */
  258. .word 0xfffe1060
  259. REG_TEST_DBG_CTRL_0: /* 32 bits */
  260. .word 0xfffe1070
  261. REG_MOD_CONF_CTRL_0: /* 32 bits */
  262. .word 0xfffe1080
  263. REG_TC_IMIF_PRIO: /* 32 bits */
  264. .word 0xfffecc00
  265. REG_TC_EMIFS_PRIO: /* 32 bits */
  266. .word 0xfffecc04
  267. REG_TC_EMIFF_PRIO: /* 32 bits */
  268. .word 0xfffecc08
  269. REG_TC_EMIFS_CONFIG: /* 32 bits */
  270. .word 0xfffecc0c
  271. REG_TC_EMIFS_CS0_CONFIG: /* 32 bits */
  272. .word 0xfffecc10
  273. REG_TC_EMIFS_CS1_CONFIG: /* 32 bits */
  274. .word 0xfffecc14
  275. REG_TC_EMIFS_CS2_CONFIG: /* 32 bits */
  276. .word 0xfffecc18
  277. REG_TC_EMIFS_CS3_CONFIG: /* 32 bits */
  278. .word 0xfffecc1c
  279. REG_TC_EMIFF_SDRAM_CONFIG: /* 32 bits */
  280. .word 0xfffecc20
  281. REG_TC_EMIFF_MRS: /* 32 bits */
  282. .word 0xfffecc24
  283. /* MPU clock/reset/power mode control registers */
  284. REG_ARM_CKCTL: /* 16 bits */
  285. .word 0xfffece00
  286. REG_ARM_IDLECT2: /* 16 bits */
  287. .word 0xfffece08
  288. REG_ARM_RSTCT2: /* 16 bits */
  289. .word 0xfffece14
  290. REG_ARM_SYSST: /* 16 bits */
  291. .word 0xfffece18
  292. /* DPLL control registers */
  293. REG_DPLL1_CTL: /* 16 bits */
  294. .word 0xfffecf00
  295. /* identification code register */
  296. REG_IDCODE: /* 32 bits */
  297. .word 0xfffed404
  298. /* Innovator specific */
  299. REG_FPGA_LED_DIGIT: /* 8 bits (not used on Innovator) */
  300. .word 0x08000003
  301. REG_FPGA_POWER: /* 8 bits */
  302. .word 0x08000005
  303. REG_FPGA_AUDIO: /* 8 bits (not used on Innovator) */
  304. .word 0x0800000c
  305. REG_FPGA_DIP_SWITCH: /* 8 bits (not used on Innovator) */
  306. .word 0x0800000e
  307. VAL_COMP_MODE_CTRL_0:
  308. .word 0x0000eaef
  309. VAL_FUNC_MUX_CTRL_4:
  310. .word 0x00000000
  311. VAL_FUNC_MUX_CTRL_5:
  312. .word 0x00000000
  313. VAL_FUNC_MUX_CTRL_6:
  314. .word 0x00000001
  315. VAL_FUNC_MUX_CTRL_7:
  316. .word 0x00000000
  317. VAL_FUNC_MUX_CTRL_8:
  318. .word 0x10001200
  319. VAL_FUNC_MUX_CTRL_9:
  320. .word 0x01201012
  321. VAL_FUNC_MUX_CTRL_A:
  322. .word 0x00000248
  323. VAL_FUNC_MUX_CTRL_B:
  324. .word 0x00000248
  325. VAL_FUNC_MUX_CTRL_C:
  326. .word 0x09000000
  327. VAL_FUNC_MUX_CTRL_D:
  328. .word 0x00000000
  329. VAL_PULL_DWN_CTRL_0:
  330. .word 0x11a10000
  331. VAL_PULL_DWN_CTRL_1:
  332. .word 0x2e047fff
  333. VAL_PULL_DWN_CTRL_2:
  334. .word 0xffd603a6
  335. VAL_PULL_DWN_CTRL_3:
  336. .word 0x00003e03
  337. VAL_VOLTAGE_CTRL_0:
  338. .word 0x00000007
  339. VAL_TEST_DBG_CTRL_0:
  340. /* See Errata 4.13, This works around a SRAM bug, for chips below ES2.5 .
  341. * This slows down internal SRAM accesses.
  342. */
  343. .word 0x00000007
  344. VAL_MOD_CONF_CTRL_0:
  345. .word 0x0b000008
  346. VAL_ARM_CKCTL:
  347. .word 0x010f
  348. VAL_DPLL1_CTL:
  349. .word 0x2710
  350. VAL_TC_EMIFS_CS1_CONFIG_PRELIM:
  351. .word 0x00001149
  352. VAL_TC_EMIFS_CS2_CONFIG_PRELIM:
  353. .word 0x00004158
  354. VAL_TC_EMIFS_CS0_CONFIG:
  355. .word 0x002130b0
  356. VAL_TC_EMIFS_CS1_CONFIG:
  357. .word 0x0000f559
  358. VAL_TC_EMIFS_CS2_CONFIG:
  359. .word 0x000055f0
  360. VAL_TC_EMIFS_CS3_CONFIG:
  361. .word 0x00003331
  362. VAL_TC_EMIFF_SDRAM_CONFIG:
  363. .word 0x010290fc
  364. VAL_TC_EMIFF_MRS:
  365. .word 0x00000027