lowlevel_init.S 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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. #include <linux/linkage.h>
  34. _TEXT_BASE:
  35. .word CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
  36. #ifdef CONFIG_SPL_BUILD
  37. ENTRY(save_boot_params)
  38. ldr r4, =omap3_boot_device
  39. ldr r5, [r0, #0x4]
  40. and r5, r5, #0xff
  41. str r5, [r4]
  42. bx lr
  43. ENDPROC(save_boot_params)
  44. #endif
  45. ENTRY(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. ENDPROC(omap3_gp_romcode_call)
  55. /*
  56. * Funtion for making PPA HAL API calls in secure devices
  57. * Input:
  58. * R0 - Service ID
  59. * R1 - paramer list
  60. */
  61. ENTRY(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. ENDPROC(do_omap3_emu_romcode_call)
  75. #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_NAND_BOOT)
  76. /**************************************************************************
  77. * cpy_clk_code: relocates clock code into SRAM where its safer to execute
  78. * R1 = SRAM destination address.
  79. *************************************************************************/
  80. ENTRY(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. ENDPROC(cpy_clk_code)
  93. /* ***************************************************************************
  94. * go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
  95. * -executed from SRAM.
  96. * R0 = CM_CLKEN_PLL-bypass value
  97. * R1 = CM_CLKSEL1_PLL-m, n, and divider values
  98. * R2 = CM_CLKSEL_CORE-divider values
  99. * R3 = CM_IDLEST_CKGEN - addr dpll lock wait
  100. *
  101. * Note: If core unlocks/relocks and SDRAM is running fast already it gets
  102. * confused. A reset of the controller gets it back. Taking away its
  103. * L3 when its not in self refresh seems bad for it. Normally, this
  104. * code runs from flash before SDR is init so that should be ok.
  105. ****************************************************************************/
  106. ENTRY(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. ENDPROC(go_to_speed)
  164. _go_to_speed: .word go_to_speed
  165. /* these constants need to be close for PIC code */
  166. /* The Nor has to be in the Flash Base CS0 for this condition to happen */
  167. flash_cfg1_addr:
  168. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG1)
  169. flash_cfg3_addr:
  170. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG3)
  171. flash_cfg3_val:
  172. .word STNOR_GPMC_CONFIG3
  173. flash_cfg4_addr:
  174. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG4)
  175. flash_cfg4_val:
  176. .word STNOR_GPMC_CONFIG4
  177. flash_cfg5_val:
  178. .word STNOR_GPMC_CONFIG5
  179. flash_cfg5_addr:
  180. .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG5)
  181. pll_ctl_add:
  182. .word CM_CLKEN_PLL
  183. pll_div_add1:
  184. .word CM_CLKSEL1_PLL
  185. pll_div_add2:
  186. .word CM_CLKSEL_CORE
  187. pll_div_add3:
  188. .word CM_CLKSEL_WKUP
  189. pll_div_val3:
  190. .word (WKUP_RSM << 1)
  191. pll_div_add4:
  192. .word CM_CLKSEL_GFX
  193. pll_div_val4:
  194. .word (GFX_DIV << 0)
  195. pll_div_add5:
  196. .word CM_CLKSEL1_EMU
  197. pll_div_val5:
  198. .word CLSEL1_EMU_VAL
  199. #endif
  200. ENTRY(lowlevel_init)
  201. ldr sp, SRAM_STACK
  202. str ip, [sp] /* stash ip register */
  203. mov ip, lr /* save link reg across call */
  204. #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_ONENAND_BOOT)
  205. /*
  206. * No need to copy/exec the clock code - DPLL adjust already done
  207. * in NAND/oneNAND Boot.
  208. */
  209. ldr r1, =SRAM_CLK_CODE
  210. bl cpy_clk_code
  211. #endif /* NAND Boot */
  212. mov lr, ip /* restore link reg */
  213. ldr ip, [sp] /* restore save ip */
  214. /* tail-call s_init to setup pll, mux, memory */
  215. b s_init
  216. ENDPROC(lowlevel_init)
  217. /* the literal pools origin */
  218. .ltorg
  219. REG_CONTROL_STATUS:
  220. .word CONTROL_STATUS
  221. SRAM_STACK:
  222. .word LOW_LEVEL_SRAM_STACK
  223. /* DPLL(1-4) PARAM TABLES */
  224. /*
  225. * Each of the tables has M, N, FREQSEL, M2 values defined for nominal
  226. * OPP (1.2V). The fields are defined according to dpll_param struct (clock.c).
  227. * The values are defined for all possible sysclk and for ES1 and ES2.
  228. */
  229. mpu_dpll_param:
  230. /* 12MHz */
  231. /* ES1 */
  232. .word MPU_M_12_ES1, MPU_N_12_ES1, MPU_FSEL_12_ES1, MPU_M2_12_ES1
  233. /* ES2 */
  234. .word MPU_M_12_ES2, MPU_N_12_ES2, MPU_FSEL_12_ES2, MPU_M2_ES2
  235. /* 3410 */
  236. .word MPU_M_12, MPU_N_12, MPU_FSEL_12, MPU_M2_12
  237. /* 13MHz */
  238. /* ES1 */
  239. .word MPU_M_13_ES1, MPU_N_13_ES1, MPU_FSEL_13_ES1, MPU_M2_13_ES1
  240. /* ES2 */
  241. .word MPU_M_13_ES2, MPU_N_13_ES2, MPU_FSEL_13_ES2, MPU_M2_13_ES2
  242. /* 3410 */
  243. .word MPU_M_13, MPU_N_13, MPU_FSEL_13, MPU_M2_13
  244. /* 19.2MHz */
  245. /* ES1 */
  246. .word MPU_M_19P2_ES1, MPU_N_19P2_ES1, MPU_FSEL_19P2_ES1, MPU_M2_19P2_ES1
  247. /* ES2 */
  248. .word MPU_M_19P2_ES2, MPU_N_19P2_ES2, MPU_FSEL_19P2_ES2, MPU_M2_19P2_ES2
  249. /* 3410 */
  250. .word MPU_M_19P2, MPU_N_19P2, MPU_FSEL_19P2, MPU_M2_19P2
  251. /* 26MHz */
  252. /* ES1 */
  253. .word MPU_M_26_ES1, MPU_N_26_ES1, MPU_FSEL_26_ES1, MPU_M2_26_ES1
  254. /* ES2 */
  255. .word MPU_M_26_ES2, MPU_N_26_ES2, MPU_FSEL_26_ES2, MPU_M2_26_ES2
  256. /* 3410 */
  257. .word MPU_M_26, MPU_N_26, MPU_FSEL_26, MPU_M2_26
  258. /* 38.4MHz */
  259. /* ES1 */
  260. .word MPU_M_38P4_ES1, MPU_N_38P4_ES1, MPU_FSEL_38P4_ES1, MPU_M2_38P4_ES1
  261. /* ES2 */
  262. .word MPU_M_38P4_ES2, MPU_N_38P4_ES2, MPU_FSEL_38P4_ES2, MPU_M2_38P4_ES2
  263. /* 3410 */
  264. .word MPU_M_38P4, MPU_N_38P4, MPU_FSEL_38P4, MPU_M2_38P4
  265. .globl get_mpu_dpll_param
  266. get_mpu_dpll_param:
  267. adr r0, mpu_dpll_param
  268. mov pc, lr
  269. iva_dpll_param:
  270. /* 12MHz */
  271. /* ES1 */
  272. .word IVA_M_12_ES1, IVA_N_12_ES1, IVA_FSEL_12_ES1, IVA_M2_12_ES1
  273. /* ES2 */
  274. .word IVA_M_12_ES2, IVA_N_12_ES2, IVA_FSEL_12_ES2, IVA_M2_12_ES2
  275. /* 3410 */
  276. .word IVA_M_12, IVA_N_12, IVA_FSEL_12, IVA_M2_12
  277. /* 13MHz */
  278. /* ES1 */
  279. .word IVA_M_13_ES1, IVA_N_13_ES1, IVA_FSEL_13_ES1, IVA_M2_13_ES1
  280. /* ES2 */
  281. .word IVA_M_13_ES2, IVA_N_13_ES2, IVA_FSEL_13_ES2, IVA_M2_13_ES2
  282. /* 3410 */
  283. .word IVA_M_13, IVA_N_13, IVA_FSEL_13, IVA_M2_13
  284. /* 19.2MHz */
  285. /* ES1 */
  286. .word IVA_M_19P2_ES1, IVA_N_19P2_ES1, IVA_FSEL_19P2_ES1, IVA_M2_19P2_ES1
  287. /* ES2 */
  288. .word IVA_M_19P2_ES2, IVA_N_19P2_ES2, IVA_FSEL_19P2_ES2, IVA_M2_19P2_ES2
  289. /* 3410 */
  290. .word IVA_M_19P2, IVA_N_19P2, IVA_FSEL_19P2, IVA_M2_19P2
  291. /* 26MHz */
  292. /* ES1 */
  293. .word IVA_M_26_ES1, IVA_N_26_ES1, IVA_FSEL_26_ES1, IVA_M2_26_ES1
  294. /* ES2 */
  295. .word IVA_M_26_ES2, IVA_N_26_ES2, IVA_FSEL_26_ES2, IVA_M2_26_ES2
  296. /* 3410 */
  297. .word IVA_M_26, IVA_N_26, IVA_FSEL_26, IVA_M2_26
  298. /* 38.4MHz */
  299. /* ES1 */
  300. .word IVA_M_38P4_ES1, IVA_N_38P4_ES1, IVA_FSEL_38P4_ES1, IVA_M2_38P4_ES1
  301. /* ES2 */
  302. .word IVA_M_38P4_ES2, IVA_N_38P4_ES2, IVA_FSEL_38P4_ES2, IVA_M2_38P4_ES2
  303. /* 3410 */
  304. .word IVA_M_38P4, IVA_N_38P4, IVA_FSEL_38P4, IVA_M2_38P4
  305. .globl get_iva_dpll_param
  306. get_iva_dpll_param:
  307. adr r0, iva_dpll_param
  308. mov pc, lr
  309. /* Core DPLL targets for L3 at 166 & L133 */
  310. core_dpll_param:
  311. /* 12MHz */
  312. /* ES1 */
  313. .word CORE_M_12_ES1, CORE_N_12_ES1, CORE_FSL_12_ES1, CORE_M2_12_ES1
  314. /* ES2 */
  315. .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
  316. /* 3410 */
  317. .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
  318. /* 13MHz */
  319. /* ES1 */
  320. .word CORE_M_13_ES1, CORE_N_13_ES1, CORE_FSL_13_ES1, CORE_M2_13_ES1
  321. /* ES2 */
  322. .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
  323. /* 3410 */
  324. .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
  325. /* 19.2MHz */
  326. /* ES1 */
  327. .word CORE_M_19P2_ES1, CORE_N_19P2_ES1, CORE_FSL_19P2_ES1, CORE_M2_19P2_ES1
  328. /* ES2 */
  329. .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
  330. /* 3410 */
  331. .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
  332. /* 26MHz */
  333. /* ES1 */
  334. .word CORE_M_26_ES1, CORE_N_26_ES1, CORE_FSL_26_ES1, CORE_M2_26_ES1
  335. /* ES2 */
  336. .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
  337. /* 3410 */
  338. .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
  339. /* 38.4MHz */
  340. /* ES1 */
  341. .word CORE_M_38P4_ES1, CORE_N_38P4_ES1, CORE_FSL_38P4_ES1, CORE_M2_38P4_ES1
  342. /* ES2 */
  343. .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
  344. /* 3410 */
  345. .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
  346. .globl get_core_dpll_param
  347. get_core_dpll_param:
  348. adr r0, core_dpll_param
  349. mov pc, lr
  350. /* PER DPLL values are same for both ES1 and ES2 */
  351. per_dpll_param:
  352. /* 12MHz */
  353. .word PER_M_12, PER_N_12, PER_FSEL_12, PER_M2_12
  354. /* 13MHz */
  355. .word PER_M_13, PER_N_13, PER_FSEL_13, PER_M2_13
  356. /* 19.2MHz */
  357. .word PER_M_19P2, PER_N_19P2, PER_FSEL_19P2, PER_M2_19P2
  358. /* 26MHz */
  359. .word PER_M_26, PER_N_26, PER_FSEL_26, PER_M2_26
  360. /* 38.4MHz */
  361. .word PER_M_38P4, PER_N_38P4, PER_FSEL_38P4, PER_M2_38P4
  362. .globl get_per_dpll_param
  363. get_per_dpll_param:
  364. adr r0, per_dpll_param
  365. mov pc, lr
  366. /* PER2 DPLL values */
  367. per2_dpll_param:
  368. /* 12MHz */
  369. .word PER2_M_12, PER2_N_12, PER2_FSEL_12, PER2_M2_12
  370. /* 13MHz */
  371. .word PER2_M_13, PER2_N_13, PER2_FSEL_13, PER2_M2_13
  372. /* 19.2MHz */
  373. .word PER2_M_19P2, PER2_N_19P2, PER2_FSEL_19P2, PER2_M2_19P2
  374. /* 26MHz */
  375. .word PER2_M_26, PER2_N_26, PER2_FSEL_26, PER2_M2_26
  376. /* 38.4MHz */
  377. .word PER2_M_38P4, PER2_N_38P4, PER2_FSEL_38P4, PER2_M2_38P4
  378. .globl get_per2_dpll_param
  379. get_per2_dpll_param:
  380. adr r0, per2_dpll_param
  381. mov pc, lr
  382. /*
  383. * Tables for 36XX/37XX devices
  384. *
  385. */
  386. mpu_36x_dpll_param:
  387. /* 12MHz */
  388. .word 50, 0, 0, 1
  389. /* 13MHz */
  390. .word 600, 12, 0, 1
  391. /* 19.2MHz */
  392. .word 125, 3, 0, 1
  393. /* 26MHz */
  394. .word 300, 12, 0, 1
  395. /* 38.4MHz */
  396. .word 125, 7, 0, 1
  397. iva_36x_dpll_param:
  398. /* 12MHz */
  399. .word 130, 2, 0, 1
  400. /* 13MHz */
  401. .word 20, 0, 0, 1
  402. /* 19.2MHz */
  403. .word 325, 11, 0, 1
  404. /* 26MHz */
  405. .word 10, 0, 0, 1
  406. /* 38.4MHz */
  407. .word 325, 23, 0, 1
  408. core_36x_dpll_param:
  409. /* 12MHz */
  410. .word 100, 2, 0, 1
  411. /* 13MHz */
  412. .word 400, 12, 0, 1
  413. /* 19.2MHz */
  414. .word 375, 17, 0, 1
  415. /* 26MHz */
  416. .word 200, 12, 0, 1
  417. /* 38.4MHz */
  418. .word 375, 35, 0, 1
  419. per_36x_dpll_param:
  420. /* SYSCLK M N M2 M3 M4 M5 M6 m2DIV */
  421. .word 12000, 360, 4, 9, 16, 5, 4, 3, 1
  422. .word 13000, 864, 12, 9, 16, 9, 4, 3, 1
  423. .word 19200, 360, 7, 9, 16, 5, 4, 3, 1
  424. .word 26000, 432, 12, 9, 16, 9, 4, 3, 1
  425. .word 38400, 360, 15, 9, 16, 5, 4, 3, 1
  426. ENTRY(get_36x_mpu_dpll_param)
  427. adr r0, mpu_36x_dpll_param
  428. mov pc, lr
  429. ENDPROC(get_36x_mpu_dpll_param)
  430. ENTRY(get_36x_iva_dpll_param)
  431. adr r0, iva_36x_dpll_param
  432. mov pc, lr
  433. ENDPROC(get_36x_iva_dpll_param)
  434. ENTRY(get_36x_core_dpll_param)
  435. adr r0, core_36x_dpll_param
  436. mov pc, lr
  437. ENDPROC(get_36x_core_dpll_param)
  438. ENTRY(get_36x_per_dpll_param)
  439. adr r0, per_36x_dpll_param
  440. mov pc, lr
  441. ENDPROC(get_36x_per_dpll_param)