lowlevel_init.S 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. /*
  2. * Lowlevel setup for SMDKV310 board based on S5PC210
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <config.h>
  25. #include <version.h>
  26. #include <asm/arch/cpu.h>
  27. /*
  28. * Register usages:
  29. *
  30. * r5 has zero always
  31. * r7 has GPIO part1 base 0x11400000
  32. * r6 has GPIO part2 base 0x11000000
  33. */
  34. #define MEM_DLLl_ON
  35. _TEXT_BASE:
  36. .word CONFIG_SYS_TEXT_BASE
  37. .globl lowlevel_init
  38. lowlevel_init:
  39. push {lr}
  40. /* r5 has always zero */
  41. mov r5, #0
  42. ldr r7, =S5PC210_GPIO_PART1_BASE
  43. ldr r6, =S5PC210_GPIO_PART2_BASE
  44. /* check reset status */
  45. ldr r0, =(S5PC210_POWER_BASE + 0x81C) @ INFORM7
  46. ldr r1, [r0]
  47. /* AFTR wakeup reset */
  48. ldr r2, =S5P_CHECK_DIDLE
  49. cmp r1, r2
  50. beq exit_wakeup
  51. /* Sleep wakeup reset */
  52. ldr r2, =S5P_CHECK_SLEEP
  53. cmp r1, r2
  54. beq wakeup_reset
  55. /*
  56. * If U-boot is already running in ram, no need to relocate U-Boot.
  57. * Memory controller must be configured before relocating U-Boot
  58. * in ram.
  59. */
  60. ldr r0, =0x00ffffff /* r0 <- Mask Bits*/
  61. bic r1, pc, r0 /* pc <- current addr of code */
  62. /* r1 <- unmasked bits of pc */
  63. ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */
  64. bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
  65. cmp r1, r2 /* compare r1, r2 */
  66. beq 1f /* r0 == r1 then skip sdram init */
  67. /* init system clock */
  68. bl system_clock_init
  69. /* Memory initialize */
  70. bl mem_ctrl_asm_init
  71. 1:
  72. /* for UART */
  73. bl uart_asm_init
  74. bl tzpc_init
  75. pop {pc}
  76. wakeup_reset:
  77. bl system_clock_init
  78. bl mem_ctrl_asm_init
  79. bl tzpc_init
  80. exit_wakeup:
  81. /* Load return address and jump to kernel */
  82. ldr r0, =(S5PC210_POWER_BASE + 0x800) @ INFORM0
  83. /* r1 = physical address of s5pc210_cpu_resume function */
  84. ldr r1, [r0]
  85. /* Jump to kernel*/
  86. mov pc, r1
  87. nop
  88. nop
  89. /*
  90. * system_clock_init: Initialize core clock and bus clock.
  91. * void system_clock_init(void)
  92. */
  93. system_clock_init:
  94. push {lr}
  95. ldr r0, =S5PC210_CLOCK_BASE
  96. /* APLL(1), MPLL(1), CORE(0), HPM(0) */
  97. ldr r1, =0x0101
  98. ldr r2, =0x14200 @CLK_SRC_CPU
  99. str r1, [r0, r2]
  100. /* wait ?us */
  101. mov r1, #0x10000
  102. 2: subs r1, r1, #1
  103. bne 2b
  104. ldr r1, =0x00
  105. ldr r2, =0x0C210 @CLK_SRC_TOP0
  106. str r1, [r0, r2]
  107. ldr r1, =0x00
  108. ldr r2, =0x0C214 @CLK_SRC_TOP1_OFFSET
  109. str r1, [r0, r2]
  110. /* DMC */
  111. ldr r1, =0x00
  112. ldr r2, =0x10200 @CLK_SRC_DMC_OFFSET
  113. str r1, [r0, r2]
  114. /*CLK_SRC_LEFTBUS */
  115. ldr r1, =0x00
  116. ldr r2, =0x04200 @CLK_SRC_LEFTBUS_OFFSET
  117. str r1, [r0, r2]
  118. /*CLK_SRC_RIGHTBUS */
  119. ldr r1, =0x00
  120. ldr r2, =0x08200 @CLK_SRC_RIGHTBUS_OFFSET
  121. str r1, [r0, r2]
  122. /* SATA: SCLKMPLL(0), MMC[0:4]: SCLKMPLL(6) */
  123. ldr r1, =0x066666
  124. ldr r2, =0x0C240 @ CLK_SRC_FSYS
  125. str r1, [r0, r2]
  126. /* UART[0:4], PWM: SCLKMPLL(6) */
  127. ldr r1, =0x06666666
  128. ldr r2, =0x0C250 @CLK_SRC_PERIL0_OFFSET
  129. str r1, [r0, r2]
  130. /* wait ?us */
  131. mov r1, #0x10000
  132. 3: subs r1, r1, #1
  133. bne 3b
  134. /*
  135. * CLK_DIV_CPU0:
  136. *
  137. * PCLK_DBG_RATIO[20] 0x1
  138. * ATB_RATIO[16] 0x3
  139. * PERIPH_RATIO[12] 0x3
  140. * COREM1_RATIO[8] 0x7
  141. * COREM0_RATIO[4] 0x3
  142. */
  143. ldr r1, =0x01133730
  144. ldr r2, =0x14500 @CLK_DIV_CPU0_OFFSET
  145. str r1, [r0, r2]
  146. /* CLK_DIV_CPU1: COPY_RATIO [0] 0x3 */
  147. ldr r1, =0x03
  148. ldr r2, =0x14504 @CLK_DIV_CPU1_OFFSET
  149. str r1, [r0, r2]
  150. /*
  151. * CLK_DIV_DMC0:
  152. *
  153. * CORE_TIMERS_RATIO[28] 0x1
  154. * COPY2_RATIO[24] 0x3
  155. * DMCP_RATIO[20] 0x1
  156. * DMCD_RATIO[16] 0x1
  157. * DMC_RATIO[12] 0x1
  158. * DPHY_RATIO[8] 0x1
  159. * ACP_PCLK_RATIO[4] 0x1
  160. * ACP_RATIO[0] 0x3
  161. */
  162. ldr r1, =0x13111113
  163. ldr r2, =0x010500 @CLK_DIV_DMC0_OFFSET
  164. str r1, [r0, r2]
  165. /*
  166. * CLK_DIV_DMC1:
  167. *
  168. * DPM_RATIO[24] 0x1
  169. * DVSEM_RATIO[16] 0x1
  170. * PWI_RATIO[8] 0x1
  171. */
  172. ldr r1, =0x01010100
  173. ldr r2, =0x010504 @CLK_DIV_DMC1_OFFSET
  174. str r1, [r0, r2]
  175. /*
  176. * CLK_DIV_LEFRBUS:
  177. *
  178. * GPL_RATIO[4] 0x1
  179. * GDL_RATIO[0] 0x3
  180. */
  181. ldr r1, =0x013
  182. ldr r2, =0x04500 @CLK_DIV_LEFTBUS_OFFSET
  183. str r1, [r0, r2]
  184. /*
  185. * CLK_DIV_RIGHTBUS:
  186. *
  187. * GPR_RATIO[4] 0x1
  188. * GDR_RATIO[0] 0x3
  189. */
  190. ldr r1, =0x013
  191. ldr r2, =0x08500 @CLK_DIV_RIGHTBUS_OFFSET
  192. str r1, [r0, r2]
  193. /*
  194. * CLK_DIV_TOP:
  195. *
  196. * ONENAND_RATIO[16] 0x0
  197. * ACLK_133_RATIO[12] 0x5
  198. * ACLK_160_RATIO[8] 0x4
  199. * ACLK_100_RATIO[4] 0x7
  200. * ACLK_200_RATIO[0] 0x3
  201. */
  202. ldr r1, =0x05473
  203. ldr r2, =0x0C510 @CLK_DIV_TOP_OFFSET
  204. str r1, [r0, r2]
  205. /* MMC[0:1] */
  206. ldr r1, =0x000f000f /* 800(MPLL) / (15 + 1) */
  207. ldr r2, =0x0C544 @ CLK_DIV_FSYS1
  208. str r1, [r0, r2]
  209. /* MMC[2:3] */
  210. ldr r1, =0x000f020f /* 800(MPLL) / (15 + 1) */
  211. ldr r2, =0x0C548 @ CLK_DIV_FSYS2
  212. str r1, [r0, r2]
  213. /* MMC4 */
  214. ldr r1, =0x000f /* 800(MPLL) / (15 + 1) */
  215. ldr r2, =0x0C54C @ CLK_DIV_FSYS3
  216. str r1, [r0, r2]
  217. /* wait ?us */
  218. mov r1, #0x10000
  219. 4: subs r1, r1, #1
  220. bne 4b
  221. /*
  222. * CLK_DIV_PERIL0:
  223. *
  224. * UART5_RATIO[20] 8
  225. * UART4_RATIO[16] 8
  226. * UART3_RATIO[12] 8
  227. * UART2_RATIO[8] 8
  228. * UART1_RATIO[4] 8
  229. * UART0_RATIO[0] 8
  230. */
  231. ldr r1, =0x774777
  232. ldr r2, =0x0C550 @CLK_DIV_PERIL0_OFFSET
  233. str r1, [r0, r2]
  234. /* SLIMBUS: ???, PWM */
  235. ldr r1, =0x8
  236. ldr r2, =0x0C55C @ CLK_DIV_PERIL3
  237. str r1, [r0, r2]
  238. /* Set PLL locktime */
  239. ldr r1, =0x01C20
  240. ldr r2, =0x014000 @APLL_LOCK_OFFSET
  241. str r1, [r0, r2]
  242. ldr r1, =0x01C20
  243. ldr r2, =0x014008 @MPLL_LOCK_OFFSET
  244. str r1, [r0, r2]
  245. ldr r1, =0x01C20
  246. ldr r2, =0x0C010 @EPLL_LOCK_OFFSET
  247. str r1, [r0, r2]
  248. ldr r1, =0x01C20
  249. ldr r2, =0x0C020 @VPLL_LOCK_OFFSET
  250. str r1, [r0, r2]
  251. /*
  252. * APLL_CON1:
  253. *
  254. * APLL_AFC_ENB[31] 0x1
  255. * APLL_AFC[0] 0xC
  256. */
  257. ldr r1, =0x8000000C
  258. ldr r2, =0x014104 @APLL_CON1_OFFSET
  259. str r1, [r0, r2]
  260. /*
  261. * APLL_CON0:
  262. *
  263. * APLL_MDIV[16] 0xFA
  264. * APLL_PDIV[8] 0x6
  265. * APLL_SDIV[0] 0x1
  266. */
  267. ldr r1, =0x80FA0601
  268. ldr r2, =0x014100 @APLL_CON0_OFFSET
  269. str r1, [r0, r2]
  270. /*
  271. * MPLL_CON1:
  272. *
  273. * MPLL_AFC_ENB[31] 0x1
  274. * MPLL_AFC[0] 0x1C
  275. */
  276. ldr r1, =0x0000001C
  277. ldr r2, =0x01410C @MPLL_CON1_OFFSET
  278. str r1, [r0, r2]
  279. /*
  280. * MPLL_CON0:
  281. *
  282. * MPLL_MDIV[16] 0xC8
  283. * MPLL_PDIV[8] 0x6
  284. * MPLL_SDIV[0] 0x1
  285. */
  286. ldr r1, =0x80C80601
  287. ldr r2, =0x014108 @MPLL_CON0_OFFSET
  288. str r1, [r0, r2]
  289. /* EPLL */
  290. ldr r1, =0x0
  291. ldr r2, =0x0C114 @EPLL_CON1_OFFSET
  292. str r1, [r0, r2]
  293. /*
  294. * EPLL_CON0:
  295. *
  296. * EPLL_MDIV[16] 0x30
  297. * EPLL_PDIV[8] 0x3
  298. * EPLL_SDIV[0] 0x2
  299. */
  300. ldr r1, =0x80300302
  301. ldr r2, =0x0C110 @EPLL_CON0_OFFSET
  302. str r1, [r0, r2]
  303. /*
  304. * VPLL_CON1:
  305. *
  306. * VPLL_MRR[24] 0x11
  307. * VPLL_MFR[16] 0x0
  308. * VPLL_K[0] 0x400
  309. */
  310. ldr r1, =0x11000400
  311. ldr r2, =0x0C124 @VPLL_CON1_OFFSET
  312. str r1, [r0, r2]
  313. /*
  314. * VPLL_CON0:
  315. *
  316. * VPLL_MDIV[16] 0x35
  317. * VPLL_PDIV[8] 0x3
  318. * VPLL_SDIV[0] 0x2
  319. */
  320. ldr r1, =0x80350302
  321. ldr r2, =0x0C120 @VPLL_CON0_OFFSET
  322. str r1, [r0, r2]
  323. /* wait ?us */
  324. mov r1, #0x30000
  325. 3: subs r1, r1, #1
  326. bne 3b
  327. pop {pc}
  328. /*
  329. * uart_asm_init: Initialize UART in asm mode, 115200bps fixed.
  330. * void uart_asm_init(void)
  331. */
  332. .globl uart_asm_init
  333. uart_asm_init:
  334. /* setup UART0-UART3 GPIOs (part1) */
  335. mov r0, r7
  336. ldr r1, =0x22222222
  337. str r1, [r0, #0x00] @ S5PC210_GPIO_A0_OFFSET
  338. ldr r1, =0x00222222
  339. str r1, [r0, #0x20] @ S5PC210_GPIO_A1_OFFSET
  340. ldr r0, =S5PC210_UART_BASE
  341. add r0, r0, #S5PC210_DEFAULT_UART_OFFSET
  342. ldr r1, =0x3C5
  343. str r1, [r0, #0x4]
  344. ldr r1, =0x111
  345. str r1, [r0, #0x8]
  346. ldr r1, =0x3
  347. str r1, [r0, #0x0]
  348. ldr r1, =0x35
  349. str r1, [r0, #0x28]
  350. ldr r1, =0x4
  351. str r1, [r0, #0x2c]
  352. mov pc, lr
  353. nop
  354. nop
  355. nop
  356. /* Setting TZPC[TrustZone Protection Controller] */
  357. tzpc_init:
  358. ldr r0, =0x10110000
  359. mov r1, #0x0
  360. str r1, [r0]
  361. mov r1, #0xff
  362. str r1, [r0, #0x0804]
  363. str r1, [r0, #0x0810]
  364. str r1, [r0, #0x081C]
  365. str r1, [r0, #0x0828]
  366. ldr r0, =0x10120000
  367. mov r1, #0x0
  368. str r1, [r0]
  369. mov r1, #0xff
  370. str r1, [r0, #0x0804]
  371. str r1, [r0, #0x0810]
  372. str r1, [r0, #0x081C]
  373. str r1, [r0, #0x0828]
  374. ldr r0, =0x10130000
  375. mov r1, #0x0
  376. str r1, [r0]
  377. mov r1, #0xff
  378. str r1, [r0, #0x0804]
  379. str r1, [r0, #0x0810]
  380. str r1, [r0, #0x081C]
  381. str r1, [r0, #0x0828]
  382. ldr r0, =0x10140000
  383. mov r1, #0x0
  384. str r1, [r0]
  385. mov r1, #0xff
  386. str r1, [r0, #0x0804]
  387. str r1, [r0, #0x0810]
  388. str r1, [r0, #0x081C]
  389. str r1, [r0, #0x0828]
  390. ldr r0, =0x10150000
  391. mov r1, #0x0
  392. str r1, [r0]
  393. mov r1, #0xff
  394. str r1, [r0, #0x0804]
  395. str r1, [r0, #0x0810]
  396. str r1, [r0, #0x081C]
  397. str r1, [r0, #0x0828]
  398. ldr r0, =0x10160000
  399. mov r1, #0x0
  400. str r1, [r0]
  401. mov r1, #0xff
  402. str r1, [r0, #0x0804]
  403. str r1, [r0, #0x0810]
  404. str r1, [r0, #0x081C]
  405. str r1, [r0, #0x0828]
  406. mov pc, lr