lowlevel_init.S 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2008
  5. * Texas Instruments, <www.ti.com>
  6. *
  7. * Initial Code by:
  8. * Richard Woodruff <r-woodruff2@ti.com>
  9. * Syed Mohammed Khasim <khasim@ti.com>
  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. #include <asm/arch/mem.h>
  32. #include <asm/arch/clocks_omap3.h>
  33. _TEXT_BASE:
  34. .word TEXT_BASE /* sdram load addr from config.mk */
  35. #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_NAND_BOOT)
  36. /**************************************************************************
  37. * cpy_clk_code: relocates clock code into SRAM where its safer to execute
  38. * R1 = SRAM destination address.
  39. *************************************************************************/
  40. .global cpy_clk_code
  41. cpy_clk_code:
  42. /* Copy DPLL code into SRAM */
  43. adr r0, go_to_speed /* get addr of clock setting code */
  44. mov r2, #384 /* r2 size to copy (div by 32 bytes) */
  45. mov r1, r1 /* r1 <- dest address (passed in) */
  46. add r2, r2, r0 /* r2 <- source end address */
  47. next2:
  48. ldmia r0!, {r3 - r10} /* copy from source address [r0] */
  49. stmia r1!, {r3 - r10} /* copy to target address [r1] */
  50. cmp r0, r2 /* until source end address [r2] */
  51. bne next2
  52. mov pc, lr /* back to caller */
  53. /* ***************************************************************************
  54. * go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
  55. * -executed from SRAM.
  56. * R0 = CM_CLKEN_PLL-bypass value
  57. * R1 = CM_CLKSEL1_PLL-m, n, and divider values
  58. * R2 = CM_CLKSEL_CORE-divider values
  59. * R3 = CM_IDLEST_CKGEN - addr dpll lock wait
  60. *
  61. * Note: If core unlocks/relocks and SDRAM is running fast already it gets
  62. * confused. A reset of the controller gets it back. Taking away its
  63. * L3 when its not in self refresh seems bad for it. Normally, this
  64. * code runs from flash before SDR is init so that should be ok.
  65. ****************************************************************************/
  66. .global go_to_speed
  67. go_to_speed:
  68. stmfd sp!, {r4 - r6}
  69. /* move into fast relock bypass */
  70. ldr r4, pll_ctl_add
  71. str r0, [r4]
  72. wait1:
  73. ldr r5, [r3] /* get status */
  74. and r5, r5, #0x1 /* isolate core status */
  75. cmp r5, #0x1 /* still locked? */
  76. beq wait1 /* if lock, loop */
  77. /* set new dpll dividers _after_ in bypass */
  78. ldr r5, pll_div_add1
  79. str r1, [r5] /* set m, n, m2 */
  80. ldr r5, pll_div_add2
  81. str r2, [r5] /* set l3/l4/.. dividers*/
  82. ldr r5, pll_div_add3 /* wkup */
  83. ldr r2, pll_div_val3 /* rsm val */
  84. str r2, [r5]
  85. ldr r5, pll_div_add4 /* gfx */
  86. ldr r2, pll_div_val4
  87. str r2, [r5]
  88. ldr r5, pll_div_add5 /* emu */
  89. ldr r2, pll_div_val5
  90. str r2, [r5]
  91. /* now prepare GPMC (flash) for new dpll speed */
  92. /* flash needs to be stable when we jump back to it */
  93. ldr r5, flash_cfg3_addr
  94. ldr r2, flash_cfg3_val
  95. str r2, [r5]
  96. ldr r5, flash_cfg4_addr
  97. ldr r2, flash_cfg4_val
  98. str r2, [r5]
  99. ldr r5, flash_cfg5_addr
  100. ldr r2, flash_cfg5_val
  101. str r2, [r5]
  102. ldr r5, flash_cfg1_addr
  103. ldr r2, [r5]
  104. orr r2, r2, #0x3 /* up gpmc divider */
  105. str r2, [r5]
  106. /* lock DPLL3 and wait a bit */
  107. orr r0, r0, #0x7 /* set up for lock mode */
  108. str r0, [r4] /* lock */
  109. nop /* ARM slow at this point working at sys_clk */
  110. nop
  111. nop
  112. nop
  113. wait2:
  114. ldr r5, [r3] /* get status */
  115. and r5, r5, #0x1 /* isolate core status */
  116. cmp r5, #0x1 /* still locked? */
  117. bne wait2 /* if lock, loop */
  118. nop
  119. nop
  120. nop
  121. nop
  122. ldmfd sp!, {r4 - r6}
  123. mov pc, lr /* back to caller, locked */
  124. _go_to_speed: .word go_to_speed
  125. /* these constants need to be close for PIC code */
  126. /* The Nor has to be in the Flash Base CS0 for this condition to happen */
  127. flash_cfg1_addr:
  128. .word (GPMC_CONFIG_CS0 + GPMC_CONFIG1)
  129. flash_cfg3_addr:
  130. .word (GPMC_CONFIG_CS0 + GPMC_CONFIG3)
  131. flash_cfg3_val:
  132. .word STNOR_GPMC_CONFIG3
  133. flash_cfg4_addr:
  134. .word (GPMC_CONFIG_CS0 + GPMC_CONFIG4)
  135. flash_cfg4_val:
  136. .word STNOR_GPMC_CONFIG4
  137. flash_cfg5_val:
  138. .word STNOR_GPMC_CONFIG5
  139. flash_cfg5_addr:
  140. .word (GPMC_CONFIG_CS0 + GPMC_CONFIG5)
  141. pll_ctl_add:
  142. .word CM_CLKEN_PLL
  143. pll_div_add1:
  144. .word CM_CLKSEL1_PLL
  145. pll_div_add2:
  146. .word CM_CLKSEL_CORE
  147. pll_div_add3:
  148. .word CM_CLKSEL_WKUP
  149. pll_div_val3:
  150. .word (WKUP_RSM << 1)
  151. pll_div_add4:
  152. .word CM_CLKSEL_GFX
  153. pll_div_val4:
  154. .word (GFX_DIV << 0)
  155. pll_div_add5:
  156. .word CM_CLKSEL1_EMU
  157. pll_div_val5:
  158. .word CLSEL1_EMU_VAL
  159. #endif
  160. .globl lowlevel_init
  161. lowlevel_init:
  162. ldr sp, SRAM_STACK
  163. str ip, [sp] /* stash old link register */
  164. mov ip, lr /* save link reg across call */
  165. bl s_init /* go setup pll, mux, memory */
  166. ldr ip, [sp] /* restore save ip */
  167. mov lr, ip /* restore link reg */
  168. /* back to arch calling code */
  169. mov pc, lr
  170. /* the literal pools origin */
  171. .ltorg
  172. REG_CONTROL_STATUS:
  173. .word CONTROL_STATUS
  174. SRAM_STACK:
  175. .word LOW_LEVEL_SRAM_STACK
  176. /* DPLL(1-4) PARAM TABLES */
  177. /*
  178. * Each of the tables has M, N, FREQSEL, M2 values defined for nominal
  179. * OPP (1.2V). The fields are defined according to dpll_param struct (clock.c).
  180. * The values are defined for all possible sysclk and for ES1 and ES2.
  181. */
  182. mpu_dpll_param:
  183. /* 12MHz */
  184. /* ES1 */
  185. .word MPU_M_12_ES1, MPU_N_12_ES1, MPU_FSEL_12_ES1, MPU_M2_12_ES1
  186. /* ES2 */
  187. .word MPU_M_12_ES2, MPU_N_12_ES2, MPU_FSEL_12_ES2, MPU_M2_ES2
  188. /* 3410 */
  189. .word MPU_M_12, MPU_N_12, MPU_FSEL_12, MPU_M2_12
  190. /* 13MHz */
  191. /* ES1 */
  192. .word MPU_M_13_ES1, MPU_N_13_ES1, MPU_FSEL_13_ES1, MPU_M2_13_ES1
  193. /* ES2 */
  194. .word MPU_M_13_ES2, MPU_N_13_ES2, MPU_FSEL_13_ES2, MPU_M2_13_ES2
  195. /* 3410 */
  196. .word MPU_M_13, MPU_N_13, MPU_FSEL_13, MPU_M2_13
  197. /* 19.2MHz */
  198. /* ES1 */
  199. .word MPU_M_19P2_ES1, MPU_N_19P2_ES1, MPU_FSEL_19P2_ES1, MPU_M2_19P2_ES1
  200. /* ES2 */
  201. .word MPU_M_19P2_ES2, MPU_N_19P2_ES2, MPU_FSEL_19P2_ES2, MPU_M2_19P2_ES2
  202. /* 3410 */
  203. .word MPU_M_19P2, MPU_N_19P2, MPU_FSEL_19P2, MPU_M2_19P2
  204. /* 26MHz */
  205. /* ES1 */
  206. .word MPU_M_26_ES1, MPU_N_26_ES1, MPU_FSEL_26_ES1, MPU_M2_26_ES1
  207. /* ES2 */
  208. .word MPU_M_26_ES2, MPU_N_26_ES2, MPU_FSEL_26_ES2, MPU_M2_26_ES2
  209. /* 3410 */
  210. .word MPU_M_26, MPU_N_26, MPU_FSEL_26, MPU_M2_26
  211. /* 38.4MHz */
  212. /* ES1 */
  213. .word MPU_M_38P4_ES1, MPU_N_38P4_ES1, MPU_FSEL_38P4_ES1, MPU_M2_38P4_ES1
  214. /* ES2 */
  215. .word MPU_M_38P4_ES2, MPU_N_38P4_ES2, MPU_FSEL_38P4_ES2, MPU_M2_38P4_ES2
  216. /* 3410 */
  217. .word MPU_M_38P4, MPU_N_38P4, MPU_FSEL_38P4, MPU_M2_38P4
  218. .globl get_mpu_dpll_param
  219. get_mpu_dpll_param:
  220. adr r0, mpu_dpll_param
  221. mov pc, lr
  222. iva_dpll_param:
  223. /* 12MHz */
  224. /* ES1 */
  225. .word IVA_M_12_ES1, IVA_N_12_ES1, IVA_FSEL_12_ES1, IVA_M2_12_ES1
  226. /* ES2 */
  227. .word IVA_M_12_ES2, IVA_N_12_ES2, IVA_FSEL_12_ES2, IVA_M2_12_ES2
  228. /* 3410 */
  229. .word IVA_M_12, IVA_N_12, IVA_FSEL_12, IVA_M2_12
  230. /* 13MHz */
  231. /* ES1 */
  232. .word IVA_M_13_ES1, IVA_N_13_ES1, IVA_FSEL_13_ES1, IVA_M2_13_ES1
  233. /* ES2 */
  234. .word IVA_M_13_ES2, IVA_N_13_ES2, IVA_FSEL_13_ES2, IVA_M2_13_ES2
  235. /* 3410 */
  236. .word IVA_M_13, IVA_N_13, IVA_FSEL_13, IVA_M2_13
  237. /* 19.2MHz */
  238. /* ES1 */
  239. .word IVA_M_19P2_ES1, IVA_N_19P2_ES1, IVA_FSEL_19P2_ES1, IVA_M2_19P2_ES1
  240. /* ES2 */
  241. .word IVA_M_19P2_ES2, IVA_N_19P2_ES2, IVA_FSEL_19P2_ES2, IVA_M2_19P2_ES2
  242. /* 3410 */
  243. .word IVA_M_19P2, IVA_N_19P2, IVA_FSEL_19P2, IVA_M2_19P2
  244. /* 26MHz */
  245. /* ES1 */
  246. .word IVA_M_26_ES1, IVA_N_26_ES1, IVA_FSEL_26_ES1, IVA_M2_26_ES1
  247. /* ES2 */
  248. .word IVA_M_26_ES2, IVA_N_26_ES2, IVA_FSEL_26_ES2, IVA_M2_26_ES2
  249. /* 3410 */
  250. .word IVA_M_26, IVA_N_26, IVA_FSEL_26, IVA_M2_26
  251. /* 38.4MHz */
  252. /* ES1 */
  253. .word IVA_M_38P4_ES1, IVA_N_38P4_ES1, IVA_FSEL_38P4_ES1, IVA_M2_38P4_ES1
  254. /* ES2 */
  255. .word IVA_M_38P4_ES2, IVA_N_38P4_ES2, IVA_FSEL_38P4_ES2, IVA_M2_38P4_ES2
  256. /* 3410 */
  257. .word IVA_M_38P4, IVA_N_38P4, IVA_FSEL_38P4, IVA_M2_38P4
  258. .globl get_iva_dpll_param
  259. get_iva_dpll_param:
  260. adr r0, iva_dpll_param
  261. mov pc, lr
  262. /* Core DPLL targets for L3 at 166 & L133 */
  263. core_dpll_param:
  264. /* 12MHz */
  265. /* ES1 */
  266. .word CORE_M_12_ES1, CORE_N_12_ES1, CORE_FSL_12_ES1, CORE_M2_12_ES1
  267. /* ES2 */
  268. .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
  269. /* 3410 */
  270. .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
  271. /* 13MHz */
  272. /* ES1 */
  273. .word CORE_M_13_ES1, CORE_N_13_ES1, CORE_FSL_13_ES1, CORE_M2_13_ES1
  274. /* ES2 */
  275. .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
  276. /* 3410 */
  277. .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
  278. /* 19.2MHz */
  279. /* ES1 */
  280. .word CORE_M_19P2_ES1, CORE_N_19P2_ES1, CORE_FSL_19P2_ES1, CORE_M2_19P2_ES1
  281. /* ES2 */
  282. .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
  283. /* 3410 */
  284. .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
  285. /* 26MHz */
  286. /* ES1 */
  287. .word CORE_M_26_ES1, CORE_N_26_ES1, CORE_FSL_26_ES1, CORE_M2_26_ES1
  288. /* ES2 */
  289. .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
  290. /* 3410 */
  291. .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
  292. /* 38.4MHz */
  293. /* ES1 */
  294. .word CORE_M_38P4_ES1, CORE_N_38P4_ES1, CORE_FSL_38P4_ES1, CORE_M2_38P4_ES1
  295. /* ES2 */
  296. .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
  297. /* 3410 */
  298. .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
  299. .globl get_core_dpll_param
  300. get_core_dpll_param:
  301. adr r0, core_dpll_param
  302. mov pc, lr
  303. /* PER DPLL values are same for both ES1 and ES2 */
  304. per_dpll_param:
  305. /* 12MHz */
  306. .word PER_M_12, PER_N_12, PER_FSEL_12, PER_M2_12
  307. /* 13MHz */
  308. .word PER_M_13, PER_N_13, PER_FSEL_13, PER_M2_13
  309. /* 19.2MHz */
  310. .word PER_M_19P2, PER_N_19P2, PER_FSEL_19P2, PER_M2_19P2
  311. /* 26MHz */
  312. .word PER_M_26, PER_N_26, PER_FSEL_26, PER_M2_26
  313. /* 38.4MHz */
  314. .word PER_M_38P4, PER_N_38P4, PER_FSEL_38P4, PER_M2_38P4
  315. .globl get_per_dpll_param
  316. get_per_dpll_param:
  317. adr r0, per_dpll_param
  318. mov pc, lr