lowlevel_init.S 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. /*
  2. * Lowlevel setup for SMDKV310 board based on EXYNOS4210
  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, =EXYNOS4_GPIO_PART1_BASE
  43. ldr r6, =EXYNOS4_GPIO_PART2_BASE
  44. /* check reset status */
  45. ldr r0, =(EXYNOS4_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 arch_cpu_init
  75. bl tzpc_init
  76. pop {pc}
  77. wakeup_reset:
  78. bl system_clock_init
  79. bl mem_ctrl_asm_init
  80. bl arch_cpu_init
  81. bl tzpc_init
  82. exit_wakeup:
  83. /* Load return address and jump to kernel */
  84. ldr r0, =(EXYNOS4_POWER_BASE + 0x800) @ INFORM0
  85. /* r1 = physical address of exynos4210_cpu_resume function */
  86. ldr r1, [r0]
  87. /* Jump to kernel*/
  88. mov pc, r1
  89. nop
  90. nop
  91. /*
  92. * system_clock_init: Initialize core clock and bus clock.
  93. * void system_clock_init(void)
  94. */
  95. system_clock_init:
  96. push {lr}
  97. ldr r0, =EXYNOS4_CLOCK_BASE
  98. /* APLL(1), MPLL(1), CORE(0), HPM(0) */
  99. ldr r1, =0x0101
  100. ldr r2, =0x14200 @CLK_SRC_CPU
  101. str r1, [r0, r2]
  102. /* wait ?us */
  103. mov r1, #0x10000
  104. 2: subs r1, r1, #1
  105. bne 2b
  106. ldr r1, =0x00
  107. ldr r2, =0x0C210 @CLK_SRC_TOP0
  108. str r1, [r0, r2]
  109. ldr r1, =0x00
  110. ldr r2, =0x0C214 @CLK_SRC_TOP1_OFFSET
  111. str r1, [r0, r2]
  112. /* DMC */
  113. ldr r1, =0x00
  114. ldr r2, =0x10200 @CLK_SRC_DMC_OFFSET
  115. str r1, [r0, r2]
  116. /*CLK_SRC_LEFTBUS */
  117. ldr r1, =0x00
  118. ldr r2, =0x04200 @CLK_SRC_LEFTBUS_OFFSET
  119. str r1, [r0, r2]
  120. /*CLK_SRC_RIGHTBUS */
  121. ldr r1, =0x00
  122. ldr r2, =0x08200 @CLK_SRC_RIGHTBUS_OFFSET
  123. str r1, [r0, r2]
  124. /* SATA: SCLKMPLL(0), MMC[0:4]: SCLKMPLL(6) */
  125. ldr r1, =0x066666
  126. ldr r2, =0x0C240 @ CLK_SRC_FSYS
  127. str r1, [r0, r2]
  128. /* UART[0:4], PWM: SCLKMPLL(6) */
  129. ldr r1, =0x06666666
  130. ldr r2, =0x0C250 @CLK_SRC_PERIL0_OFFSET
  131. str r1, [r0, r2]
  132. /* wait ?us */
  133. mov r1, #0x10000
  134. 3: subs r1, r1, #1
  135. bne 3b
  136. /*
  137. * CLK_DIV_CPU0:
  138. *
  139. * PCLK_DBG_RATIO[20] 0x1
  140. * ATB_RATIO[16] 0x3
  141. * PERIPH_RATIO[12] 0x3
  142. * COREM1_RATIO[8] 0x7
  143. * COREM0_RATIO[4] 0x3
  144. */
  145. ldr r1, =0x0133730
  146. ldr r2, =0x14500 @CLK_DIV_CPU0_OFFSET
  147. str r1, [r0, r2]
  148. /* CLK_DIV_CPU1: COPY_RATIO [0] 0x3 */
  149. ldr r1, =0x03
  150. ldr r2, =0x14504 @CLK_DIV_CPU1_OFFSET
  151. str r1, [r0, r2]
  152. /*
  153. * CLK_DIV_DMC0:
  154. *
  155. * CORE_TIMERS_RATIO[28] 0x1
  156. * COPY2_RATIO[24] 0x3
  157. * DMCP_RATIO[20] 0x1
  158. * DMCD_RATIO[16] 0x1
  159. * DMC_RATIO[12] 0x1
  160. * DPHY_RATIO[8] 0x1
  161. * ACP_PCLK_RATIO[4] 0x1
  162. * ACP_RATIO[0] 0x3
  163. */
  164. ldr r1, =0x13111113
  165. ldr r2, =0x010500 @CLK_DIV_DMC0_OFFSET
  166. str r1, [r0, r2]
  167. /*
  168. * CLK_DIV_DMC1:
  169. *
  170. * DPM_RATIO[24] 0x1
  171. * DVSEM_RATIO[16] 0x1
  172. * PWI_RATIO[8] 0x1
  173. */
  174. ldr r1, =0x01010100
  175. ldr r2, =0x010504 @CLK_DIV_DMC1_OFFSET
  176. str r1, [r0, r2]
  177. /*
  178. * CLK_DIV_LEFRBUS:
  179. *
  180. * GPL_RATIO[4] 0x1
  181. * GDL_RATIO[0] 0x3
  182. */
  183. ldr r1, =0x013
  184. ldr r2, =0x04500 @CLK_DIV_LEFTBUS_OFFSET
  185. str r1, [r0, r2]
  186. /*
  187. * CLK_DIV_RIGHTBUS:
  188. *
  189. * GPR_RATIO[4] 0x1
  190. * GDR_RATIO[0] 0x3
  191. */
  192. ldr r1, =0x013
  193. ldr r2, =0x08500 @CLK_DIV_RIGHTBUS_OFFSET
  194. str r1, [r0, r2]
  195. /*
  196. * CLK_DIV_TOP:
  197. *
  198. * ONENAND_RATIO[16] 0x0
  199. * ACLK_133_RATIO[12] 0x5
  200. * ACLK_160_RATIO[8] 0x4
  201. * ACLK_100_RATIO[4] 0x7
  202. * ACLK_200_RATIO[0] 0x3
  203. */
  204. ldr r1, =0x05473
  205. ldr r2, =0x0C510 @CLK_DIV_TOP_OFFSET
  206. str r1, [r0, r2]
  207. /* MMC[0:1] */
  208. ldr r1, =0x000f000f /* 800(MPLL) / (15 + 1) */
  209. ldr r2, =0x0C544 @ CLK_DIV_FSYS1
  210. str r1, [r0, r2]
  211. /* MMC[2:3] */
  212. ldr r1, =0x000f000f /* 800(MPLL) / (15 + 1) */
  213. ldr r2, =0x0C548 @ CLK_DIV_FSYS2
  214. str r1, [r0, r2]
  215. /* MMC4 */
  216. ldr r1, =0x000f /* 800(MPLL) / (15 + 1) */
  217. ldr r2, =0x0C54C @ CLK_DIV_FSYS3
  218. str r1, [r0, r2]
  219. /* wait ?us */
  220. mov r1, #0x10000
  221. 4: subs r1, r1, #1
  222. bne 4b
  223. /*
  224. * CLK_DIV_PERIL0:
  225. *
  226. * UART5_RATIO[20] 8
  227. * UART4_RATIO[16] 8
  228. * UART3_RATIO[12] 8
  229. * UART2_RATIO[8] 8
  230. * UART1_RATIO[4] 8
  231. * UART0_RATIO[0] 8
  232. */
  233. ldr r1, =0x774777
  234. ldr r2, =0x0C550 @CLK_DIV_PERIL0_OFFSET
  235. str r1, [r0, r2]
  236. /* SLIMBUS: ???, PWM */
  237. ldr r1, =0x8
  238. ldr r2, =0x0C55C @ CLK_DIV_PERIL3
  239. str r1, [r0, r2]
  240. /* Set PLL locktime */
  241. ldr r1, =0x01C20
  242. ldr r2, =0x014000 @APLL_LOCK_OFFSET
  243. str r1, [r0, r2]
  244. ldr r1, =0x01C20
  245. ldr r2, =0x014008 @MPLL_LOCK_OFFSET
  246. str r1, [r0, r2]
  247. ldr r1, =0x01C20
  248. ldr r2, =0x0C010 @EPLL_LOCK_OFFSET
  249. str r1, [r0, r2]
  250. ldr r1, =0x01C20
  251. ldr r2, =0x0C020 @VPLL_LOCK_OFFSET
  252. str r1, [r0, r2]
  253. /*
  254. * APLL_CON1:
  255. *
  256. * APLL_AFC_ENB[31] 0x1
  257. * APLL_AFC[0] 0xC
  258. */
  259. ldr r1, =0x8000000C
  260. ldr r2, =0x014104 @APLL_CON1_OFFSET
  261. str r1, [r0, r2]
  262. /*
  263. * APLL_CON0:
  264. *
  265. * APLL_MDIV[16] 0xFA
  266. * APLL_PDIV[8] 0x6
  267. * APLL_SDIV[0] 0x1
  268. */
  269. ldr r1, =0x80FA0601
  270. ldr r2, =0x014100 @APLL_CON0_OFFSET
  271. str r1, [r0, r2]
  272. /*
  273. * MPLL_CON1:
  274. *
  275. * MPLL_AFC_ENB[31] 0x1
  276. * MPLL_AFC[0] 0x1C
  277. */
  278. ldr r1, =0x0000001C
  279. ldr r2, =0x01410C @MPLL_CON1_OFFSET
  280. str r1, [r0, r2]
  281. /*
  282. * MPLL_CON0:
  283. *
  284. * MPLL_MDIV[16] 0xC8
  285. * MPLL_PDIV[8] 0x6
  286. * MPLL_SDIV[0] 0x1
  287. */
  288. ldr r1, =0x80C80601
  289. ldr r2, =0x014108 @MPLL_CON0_OFFSET
  290. str r1, [r0, r2]
  291. /* EPLL */
  292. ldr r1, =0x0
  293. ldr r2, =0x0C114 @EPLL_CON1_OFFSET
  294. str r1, [r0, r2]
  295. /*
  296. * EPLL_CON0:
  297. *
  298. * EPLL_MDIV[16] 0x30
  299. * EPLL_PDIV[8] 0x3
  300. * EPLL_SDIV[0] 0x2
  301. */
  302. ldr r1, =0x80300302
  303. ldr r2, =0x0C110 @EPLL_CON0_OFFSET
  304. str r1, [r0, r2]
  305. /*
  306. * VPLL_CON1:
  307. *
  308. * VPLL_MRR[24] 0x11
  309. * VPLL_MFR[16] 0x0
  310. * VPLL_K[0] 0x400
  311. */
  312. ldr r1, =0x11000400
  313. ldr r2, =0x0C124 @VPLL_CON1_OFFSET
  314. str r1, [r0, r2]
  315. /*
  316. * VPLL_CON0:
  317. *
  318. * VPLL_MDIV[16] 0x35
  319. * VPLL_PDIV[8] 0x3
  320. * VPLL_SDIV[0] 0x2
  321. */
  322. ldr r1, =0x80350302
  323. ldr r2, =0x0C120 @VPLL_CON0_OFFSET
  324. str r1, [r0, r2]
  325. /* wait ?us */
  326. mov r1, #0x30000
  327. 3: subs r1, r1, #1
  328. bne 3b
  329. pop {pc}
  330. /*
  331. * uart_asm_init: Initialize UART in asm mode, 115200bps fixed.
  332. * void uart_asm_init(void)
  333. */
  334. .globl uart_asm_init
  335. uart_asm_init:
  336. /* setup UART0-UART3 GPIOs (part1) */
  337. mov r0, r7
  338. ldr r1, =0x22222222
  339. str r1, [r0, #0x00] @ EXYNOS4_GPIO_A0_OFFSET
  340. ldr r1, =0x00222222
  341. str r1, [r0, #0x20] @ EXYNOS4_GPIO_A1_OFFSET
  342. ldr r0, =EXYNOS4_UART_BASE
  343. add r0, r0, #EXYNOS4_DEFAULT_UART_OFFSET
  344. ldr r1, =0x3C5
  345. str r1, [r0, #0x4]
  346. ldr r1, =0x111
  347. str r1, [r0, #0x8]
  348. ldr r1, =0x3
  349. str r1, [r0, #0x0]
  350. ldr r1, =0x35
  351. str r1, [r0, #0x28]
  352. ldr r1, =0x4
  353. str r1, [r0, #0x2c]
  354. mov pc, lr
  355. nop
  356. nop
  357. nop