lowlevel_init.S 13 KB

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