lowlevel_init.S 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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 CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
  35. .global save_boot_params
  36. save_boot_params:
  37. #ifdef CONFIG_SPL_BUILD
  38. ldr r4, =omap3_boot_device
  39. ldr r5, [r0, #0x4]
  40. and r5, r5, #0xff
  41. str r5, [r4]
  42. #endif
  43. bx lr
  44. .global omap3_gp_romcode_call
  45. omap3_gp_romcode_call:
  46. PUSH {r4-r12, lr} @ Save all registers from ROM code!
  47. MOV r12, r0 @ Copy the Service ID in R12
  48. MOV r0, r1 @ Copy parameter to R0
  49. mcr p15, 0, r0, c7, c10, 4 @ DSB
  50. mcr p15, 0, r0, c7, c10, 5 @ DMB
  51. .word 0xe1600070 @ SMC #0 to enter monitor - hand assembled
  52. @ because we use -march=armv5
  53. POP {r4-r12, pc}
  54. /*
  55. * Funtion for making PPA HAL API calls in secure devices
  56. * Input:
  57. * R0 - Service ID
  58. * R1 - paramer list
  59. */
  60. .global do_omap3_emu_romcode_call
  61. do_omap3_emu_romcode_call:
  62. PUSH {r4-r12, lr} @ Save all registers from ROM code!
  63. MOV r12, r0 @ Copy the Secure Service ID in R12
  64. MOV r3, r1 @ Copy the pointer to va_list in R3
  65. MOV r1, #0 @ Process ID - 0
  66. MOV r2, #OMAP3_EMU_HAL_START_HAL_CRITICAL @ Copy the pointer
  67. @ to va_list in R3
  68. MOV r6, #0xFF @ Indicate new Task call
  69. mcr p15, 0, r0, c7, c10, 4 @ DSB
  70. mcr p15, 0, r0, c7, c10, 5 @ DMB
  71. .word 0xe1600071 @ SMC #1 to call PPA service - hand assembled
  72. @ because we use -march=armv5
  73. POP {r4-r12, pc}
  74. #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_NAND_BOOT)
  75. /**************************************************************************
  76. * cpy_clk_code: relocates clock code into SRAM where its safer to execute
  77. * R1 = SRAM destination address.
  78. *************************************************************************/
  79. .global cpy_clk_code
  80. cpy_clk_code:
  81. /* Copy DPLL code into SRAM */
  82. adr r0, go_to_speed /* get addr of clock setting code */
  83. mov r2, #384 /* r2 size to copy (div by 32 bytes) */
  84. mov r1, r1 /* r1 <- dest address (passed in) */
  85. add r2, r2, r0 /* r2 <- source end address */
  86. next2:
  87. ldmia r0!, {r3 - r10} /* copy from source address [r0] */
  88. stmia r1!, {r3 - r10} /* copy to target address [r1] */
  89. cmp r0, r2 /* until source end address [r2] */
  90. bne next2
  91. mov pc, lr /* back to caller */
  92. /* ***************************************************************************
  93. * go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
  94. * -executed from SRAM.
  95. * R0 = CM_CLKEN_PLL-bypass value
  96. * R1 = CM_CLKSEL1_PLL-m, n, and divider values
  97. * R2 = CM_CLKSEL_CORE-divider values
  98. * R3 = CM_IDLEST_CKGEN - addr dpll lock wait
  99. *
  100. * Note: If core unlocks/relocks and SDRAM is running fast already it gets
  101. * confused. A reset of the controller gets it back. Taking away its
  102. * L3 when its not in self refresh seems bad for it. Normally, this
  103. * code runs from flash before SDR is init so that should be ok.
  104. ****************************************************************************/
  105. .global go_to_speed
  106. go_to_speed:
  107. stmfd sp!, {r4 - r6}
  108. /* move into fast relock bypass */
  109. ldr r4, pll_ctl_add
  110. str r0, [r4]
  111. wait1:
  112. ldr r5, [r3] /* get status */
  113. and r5, r5, #0x1 /* isolate core status */
  114. cmp r5, #0x1 /* still locked? */
  115. beq wait1 /* if lock, loop */
  116. /* set new dpll dividers _after_ in bypass */
  117. ldr r5, pll_div_add1
  118. str r1, [r5] /* set m, n, m2 */
  119. ldr r5, pll_div_add2
  120. str r2, [r5] /* set l3/l4/.. dividers*/
  121. ldr r5, pll_div_add3 /* wkup */
  122. ldr r2, pll_div_val3 /* rsm val */
  123. str r2, [r5]
  124. ldr r5, pll_div_add4 /* gfx */
  125. ldr r2, pll_div_val4
  126. str r2, [r5]
  127. ldr r5, pll_div_add5 /* emu */
  128. ldr r2, pll_div_val5
  129. str r2, [r5]
  130. /* now prepare GPMC (flash) for new dpll speed */
  131. /* flash needs to be stable when we jump back to it */
  132. ldr r5, flash_cfg3_addr
  133. ldr r2, flash_cfg3_val
  134. str r2, [r5]
  135. ldr r5, flash_cfg4_addr
  136. ldr r2, flash_cfg4_val
  137. str r2, [r5]
  138. ldr r5, flash_cfg5_addr
  139. ldr r2, flash_cfg5_val
  140. str r2, [r5]
  141. ldr r5, flash_cfg1_addr
  142. ldr r2, [r5]
  143. orr r2, r2, #0x3 /* up gpmc divider */
  144. str r2, [r5]
  145. /* lock DPLL3 and wait a bit */
  146. orr r0, r0, #0x7 /* set up for lock mode */
  147. str r0, [r4] /* lock */
  148. nop /* ARM slow at this point working at sys_clk */
  149. nop
  150. nop
  151. nop
  152. wait2:
  153. ldr r5, [r3] /* get status */
  154. and r5, r5, #0x1 /* isolate core status */
  155. cmp r5, #0x1 /* still locked? */
  156. bne wait2 /* if lock, loop */
  157. nop
  158. nop
  159. nop
  160. nop
  161. ldmfd sp!, {r4 - r6}
  162. mov pc, lr /* back to caller, locked */
  163. _go_to_speed: .word go_to_speed
  164. /* these constants need to be close for PIC code */
  165. /* The Nor has to be in the Flash Base CS0 for this condition to happen */
  166. flash_cfg1_addr:
  167. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG1)
  168. flash_cfg3_addr:
  169. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG3)
  170. flash_cfg3_val:
  171. .word STNOR_GPMC_CONFIG3
  172. flash_cfg4_addr:
  173. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG4)
  174. flash_cfg4_val:
  175. .word STNOR_GPMC_CONFIG4
  176. flash_cfg5_val:
  177. .word STNOR_GPMC_CONFIG5
  178. flash_cfg5_addr:
  179. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG5)
  180. pll_ctl_add:
  181. .word CM_CLKEN_PLL
  182. pll_div_add1:
  183. .word CM_CLKSEL1_PLL
  184. pll_div_add2:
  185. .word CM_CLKSEL_CORE
  186. pll_div_add3:
  187. .word CM_CLKSEL_WKUP
  188. pll_div_val3:
  189. .word (WKUP_RSM << 1)
  190. pll_div_add4:
  191. .word CM_CLKSEL_GFX
  192. pll_div_val4:
  193. .word (GFX_DIV << 0)
  194. pll_div_add5:
  195. .word CM_CLKSEL1_EMU
  196. pll_div_val5:
  197. .word CLSEL1_EMU_VAL
  198. #endif
  199. .globl lowlevel_init
  200. lowlevel_init:
  201. ldr sp, SRAM_STACK
  202. str ip, [sp] /* stash old link register */
  203. mov ip, lr /* save link reg across call */
  204. bl s_init /* go setup pll, mux, memory */
  205. ldr ip, [sp] /* restore save ip */
  206. mov lr, ip /* restore link reg */
  207. /* back to arch calling code */
  208. mov pc, lr
  209. /* the literal pools origin */
  210. .ltorg
  211. REG_CONTROL_STATUS:
  212. .word CONTROL_STATUS
  213. SRAM_STACK:
  214. .word LOW_LEVEL_SRAM_STACK
  215. /* DPLL(1-4) PARAM TABLES */
  216. /*
  217. * Each of the tables has M, N, FREQSEL, M2 values defined for nominal
  218. * OPP (1.2V). The fields are defined according to dpll_param struct (clock.c).
  219. * The values are defined for all possible sysclk and for ES1 and ES2.
  220. */
  221. mpu_dpll_param:
  222. /* 12MHz */
  223. /* ES1 */
  224. .word MPU_M_12_ES1, MPU_N_12_ES1, MPU_FSEL_12_ES1, MPU_M2_12_ES1
  225. /* ES2 */
  226. .word MPU_M_12_ES2, MPU_N_12_ES2, MPU_FSEL_12_ES2, MPU_M2_ES2
  227. /* 3410 */
  228. .word MPU_M_12, MPU_N_12, MPU_FSEL_12, MPU_M2_12
  229. /* 13MHz */
  230. /* ES1 */
  231. .word MPU_M_13_ES1, MPU_N_13_ES1, MPU_FSEL_13_ES1, MPU_M2_13_ES1
  232. /* ES2 */
  233. .word MPU_M_13_ES2, MPU_N_13_ES2, MPU_FSEL_13_ES2, MPU_M2_13_ES2
  234. /* 3410 */
  235. .word MPU_M_13, MPU_N_13, MPU_FSEL_13, MPU_M2_13
  236. /* 19.2MHz */
  237. /* ES1 */
  238. .word MPU_M_19P2_ES1, MPU_N_19P2_ES1, MPU_FSEL_19P2_ES1, MPU_M2_19P2_ES1
  239. /* ES2 */
  240. .word MPU_M_19P2_ES2, MPU_N_19P2_ES2, MPU_FSEL_19P2_ES2, MPU_M2_19P2_ES2
  241. /* 3410 */
  242. .word MPU_M_19P2, MPU_N_19P2, MPU_FSEL_19P2, MPU_M2_19P2
  243. /* 26MHz */
  244. /* ES1 */
  245. .word MPU_M_26_ES1, MPU_N_26_ES1, MPU_FSEL_26_ES1, MPU_M2_26_ES1
  246. /* ES2 */
  247. .word MPU_M_26_ES2, MPU_N_26_ES2, MPU_FSEL_26_ES2, MPU_M2_26_ES2
  248. /* 3410 */
  249. .word MPU_M_26, MPU_N_26, MPU_FSEL_26, MPU_M2_26
  250. /* 38.4MHz */
  251. /* ES1 */
  252. .word MPU_M_38P4_ES1, MPU_N_38P4_ES1, MPU_FSEL_38P4_ES1, MPU_M2_38P4_ES1
  253. /* ES2 */
  254. .word MPU_M_38P4_ES2, MPU_N_38P4_ES2, MPU_FSEL_38P4_ES2, MPU_M2_38P4_ES2
  255. /* 3410 */
  256. .word MPU_M_38P4, MPU_N_38P4, MPU_FSEL_38P4, MPU_M2_38P4
  257. .globl get_mpu_dpll_param
  258. get_mpu_dpll_param:
  259. adr r0, mpu_dpll_param
  260. mov pc, lr
  261. iva_dpll_param:
  262. /* 12MHz */
  263. /* ES1 */
  264. .word IVA_M_12_ES1, IVA_N_12_ES1, IVA_FSEL_12_ES1, IVA_M2_12_ES1
  265. /* ES2 */
  266. .word IVA_M_12_ES2, IVA_N_12_ES2, IVA_FSEL_12_ES2, IVA_M2_12_ES2
  267. /* 3410 */
  268. .word IVA_M_12, IVA_N_12, IVA_FSEL_12, IVA_M2_12
  269. /* 13MHz */
  270. /* ES1 */
  271. .word IVA_M_13_ES1, IVA_N_13_ES1, IVA_FSEL_13_ES1, IVA_M2_13_ES1
  272. /* ES2 */
  273. .word IVA_M_13_ES2, IVA_N_13_ES2, IVA_FSEL_13_ES2, IVA_M2_13_ES2
  274. /* 3410 */
  275. .word IVA_M_13, IVA_N_13, IVA_FSEL_13, IVA_M2_13
  276. /* 19.2MHz */
  277. /* ES1 */
  278. .word IVA_M_19P2_ES1, IVA_N_19P2_ES1, IVA_FSEL_19P2_ES1, IVA_M2_19P2_ES1
  279. /* ES2 */
  280. .word IVA_M_19P2_ES2, IVA_N_19P2_ES2, IVA_FSEL_19P2_ES2, IVA_M2_19P2_ES2
  281. /* 3410 */
  282. .word IVA_M_19P2, IVA_N_19P2, IVA_FSEL_19P2, IVA_M2_19P2
  283. /* 26MHz */
  284. /* ES1 */
  285. .word IVA_M_26_ES1, IVA_N_26_ES1, IVA_FSEL_26_ES1, IVA_M2_26_ES1
  286. /* ES2 */
  287. .word IVA_M_26_ES2, IVA_N_26_ES2, IVA_FSEL_26_ES2, IVA_M2_26_ES2
  288. /* 3410 */
  289. .word IVA_M_26, IVA_N_26, IVA_FSEL_26, IVA_M2_26
  290. /* 38.4MHz */
  291. /* ES1 */
  292. .word IVA_M_38P4_ES1, IVA_N_38P4_ES1, IVA_FSEL_38P4_ES1, IVA_M2_38P4_ES1
  293. /* ES2 */
  294. .word IVA_M_38P4_ES2, IVA_N_38P4_ES2, IVA_FSEL_38P4_ES2, IVA_M2_38P4_ES2
  295. /* 3410 */
  296. .word IVA_M_38P4, IVA_N_38P4, IVA_FSEL_38P4, IVA_M2_38P4
  297. .globl get_iva_dpll_param
  298. get_iva_dpll_param:
  299. adr r0, iva_dpll_param
  300. mov pc, lr
  301. /* Core DPLL targets for L3 at 166 & L133 */
  302. core_dpll_param:
  303. /* 12MHz */
  304. /* ES1 */
  305. .word CORE_M_12_ES1, CORE_N_12_ES1, CORE_FSL_12_ES1, CORE_M2_12_ES1
  306. /* ES2 */
  307. .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
  308. /* 3410 */
  309. .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
  310. /* 13MHz */
  311. /* ES1 */
  312. .word CORE_M_13_ES1, CORE_N_13_ES1, CORE_FSL_13_ES1, CORE_M2_13_ES1
  313. /* ES2 */
  314. .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
  315. /* 3410 */
  316. .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
  317. /* 19.2MHz */
  318. /* ES1 */
  319. .word CORE_M_19P2_ES1, CORE_N_19P2_ES1, CORE_FSL_19P2_ES1, CORE_M2_19P2_ES1
  320. /* ES2 */
  321. .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
  322. /* 3410 */
  323. .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
  324. /* 26MHz */
  325. /* ES1 */
  326. .word CORE_M_26_ES1, CORE_N_26_ES1, CORE_FSL_26_ES1, CORE_M2_26_ES1
  327. /* ES2 */
  328. .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
  329. /* 3410 */
  330. .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
  331. /* 38.4MHz */
  332. /* ES1 */
  333. .word CORE_M_38P4_ES1, CORE_N_38P4_ES1, CORE_FSL_38P4_ES1, CORE_M2_38P4_ES1
  334. /* ES2 */
  335. .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
  336. /* 3410 */
  337. .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
  338. .globl get_core_dpll_param
  339. get_core_dpll_param:
  340. adr r0, core_dpll_param
  341. mov pc, lr
  342. /* PER DPLL values are same for both ES1 and ES2 */
  343. per_dpll_param:
  344. /* 12MHz */
  345. .word PER_M_12, PER_N_12, PER_FSEL_12, PER_M2_12
  346. /* 13MHz */
  347. .word PER_M_13, PER_N_13, PER_FSEL_13, PER_M2_13
  348. /* 19.2MHz */
  349. .word PER_M_19P2, PER_N_19P2, PER_FSEL_19P2, PER_M2_19P2
  350. /* 26MHz */
  351. .word PER_M_26, PER_N_26, PER_FSEL_26, PER_M2_26
  352. /* 38.4MHz */
  353. .word PER_M_38P4, PER_N_38P4, PER_FSEL_38P4, PER_M2_38P4
  354. .globl get_per_dpll_param
  355. get_per_dpll_param:
  356. adr r0, per_dpll_param
  357. mov pc, lr
  358. /* PER2 DPLL values */
  359. per2_dpll_param:
  360. /* 12MHz */
  361. .word PER2_M_12, PER2_N_12, PER2_FSEL_12, PER2_M2_12
  362. /* 13MHz */
  363. .word PER2_M_13, PER2_N_13, PER2_FSEL_13, PER2_M2_13
  364. /* 19.2MHz */
  365. .word PER2_M_19P2, PER2_N_19P2, PER2_FSEL_19P2, PER2_M2_19P2
  366. /* 26MHz */
  367. .word PER2_M_26, PER2_N_26, PER2_FSEL_26, PER2_M2_26
  368. /* 38.4MHz */
  369. .word PER2_M_38P4, PER2_N_38P4, PER2_FSEL_38P4, PER2_M2_38P4
  370. .globl get_per2_dpll_param
  371. get_per2_dpll_param:
  372. adr r0, per2_dpll_param
  373. mov pc, lr
  374. /*
  375. * Tables for 36XX/37XX devices
  376. *
  377. */
  378. mpu_36x_dpll_param:
  379. /* 12MHz */
  380. .word 50, 0, 0, 1
  381. /* 13MHz */
  382. .word 600, 12, 0, 1
  383. /* 19.2MHz */
  384. .word 125, 3, 0, 1
  385. /* 26MHz */
  386. .word 300, 12, 0, 1
  387. /* 38.4MHz */
  388. .word 125, 7, 0, 1
  389. iva_36x_dpll_param:
  390. /* 12MHz */
  391. .word 130, 2, 0, 1
  392. /* 13MHz */
  393. .word 20, 0, 0, 1
  394. /* 19.2MHz */
  395. .word 325, 11, 0, 1
  396. /* 26MHz */
  397. .word 10, 0, 0, 1
  398. /* 38.4MHz */
  399. .word 325, 23, 0, 1
  400. core_36x_dpll_param:
  401. /* 12MHz */
  402. .word 100, 2, 0, 1
  403. /* 13MHz */
  404. .word 400, 12, 0, 1
  405. /* 19.2MHz */
  406. .word 375, 17, 0, 1
  407. /* 26MHz */
  408. .word 200, 12, 0, 1
  409. /* 38.4MHz */
  410. .word 375, 35, 0, 1
  411. per_36x_dpll_param:
  412. /* SYSCLK M N M2 M3 M4 M5 M6 m2DIV */
  413. .word 12000, 360, 4, 9, 16, 5, 4, 3, 1
  414. .word 13000, 864, 12, 9, 16, 9, 4, 3, 1
  415. .word 19200, 360, 7, 9, 16, 5, 4, 3, 1
  416. .word 26000, 432, 12, 9, 16, 9, 4, 3, 1
  417. .word 38400, 360, 15, 9, 16, 5, 4, 3, 1
  418. .globl get_36x_mpu_dpll_param
  419. get_36x_mpu_dpll_param:
  420. adr r0, mpu_36x_dpll_param
  421. mov pc, lr
  422. .globl get_36x_iva_dpll_param
  423. get_36x_iva_dpll_param:
  424. adr r0, iva_36x_dpll_param
  425. mov pc, lr
  426. .globl get_36x_core_dpll_param
  427. get_36x_core_dpll_param:
  428. adr r0, core_36x_dpll_param
  429. mov pc, lr
  430. .globl get_36x_per_dpll_param
  431. get_36x_per_dpll_param:
  432. adr r0, per_36x_dpll_param
  433. mov pc, lr