lowlevel_init.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*
  2. * Memory Setup stuff - taken from blob memsetup.S
  3. *
  4. * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
  5. * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
  6. *
  7. * Modified for the Samsung SMDK2410 by
  8. * (C) Copyright 2002
  9. * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
  10. *
  11. * (C) Copyright 2008
  12. * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
  13. *
  14. * See file CREDITS for list of people who contributed to this
  15. * project.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30. * MA 02111-1307 USA
  31. */
  32. #include <config.h>
  33. #include <version.h>
  34. #include <s3c6400.h>
  35. #ifdef CONFIG_SERIAL1
  36. #define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART0_OFFSET)
  37. #elif defined(CONFIG_SERIAL2)
  38. #define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART1_OFFSET)
  39. #else
  40. #define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART2_OFFSET)
  41. #endif
  42. _TEXT_BASE:
  43. .word TEXT_BASE
  44. .globl lowlevel_init
  45. lowlevel_init:
  46. mov r12, lr
  47. /* LED on only #8 */
  48. ldr r0, =ELFIN_GPIO_BASE
  49. ldr r1, =0x55540000
  50. str r1, [r0, #GPNCON_OFFSET]
  51. ldr r1, =0x55555555
  52. str r1, [r0, #GPNPUD_OFFSET]
  53. ldr r1, =0xf000
  54. str r1, [r0, #GPNDAT_OFFSET]
  55. /* Disable Watchdog */
  56. ldr r0, =0x7e000000 @0x7e004000
  57. orr r0, r0, #0x4000
  58. mov r1, #0
  59. str r1, [r0]
  60. /* External interrupt pending clear */
  61. ldr r0, =(ELFIN_GPIO_BASE+EINTPEND_OFFSET) /*EINTPEND*/
  62. ldr r1, [r0]
  63. str r1, [r0]
  64. ldr r0, =ELFIN_VIC0_BASE_ADDR @0x71200000
  65. ldr r1, =ELFIN_VIC1_BASE_ADDR @0x71300000
  66. /* Disable all interrupts (VIC0 and VIC1) */
  67. mvn r3, #0x0
  68. str r3, [r0, #oINTMSK]
  69. str r3, [r1, #oINTMSK]
  70. /* Set all interrupts as IRQ */
  71. mov r3, #0x0
  72. str r3, [r0, #oINTMOD]
  73. str r3, [r1, #oINTMOD]
  74. /* Pending Interrupt Clear */
  75. mov r3, #0x0
  76. str r3, [r0, #oVECTADDR]
  77. str r3, [r1, #oVECTADDR]
  78. /* init system clock */
  79. bl system_clock_init
  80. #ifndef CONFIG_NAND_SPL
  81. /* for UART */
  82. bl uart_asm_init
  83. #endif
  84. #ifdef CONFIG_BOOT_NAND
  85. /* simple init for NAND */
  86. bl nand_asm_init
  87. #endif
  88. bl mem_ctrl_asm_init
  89. /* Wakeup support. Don't know if it's going to be used, untested. */
  90. ldr r0, =(ELFIN_CLOCK_POWER_BASE + RST_STAT_OFFSET)
  91. ldr r1, [r0]
  92. bic r1, r1, #0xfffffff7
  93. cmp r1, #0x8
  94. beq wakeup_reset
  95. 1:
  96. mov lr, r12
  97. mov pc, lr
  98. wakeup_reset:
  99. /* Clear wakeup status register */
  100. ldr r0, =(ELFIN_CLOCK_POWER_BASE + WAKEUP_STAT_OFFSET)
  101. ldr r1, [r0]
  102. str r1, [r0]
  103. /* LED test */
  104. ldr r0, =ELFIN_GPIO_BASE
  105. ldr r1, =0x3000
  106. str r1, [r0, #GPNDAT_OFFSET]
  107. /* Load return address and jump to kernel */
  108. ldr r0, =(ELFIN_CLOCK_POWER_BASE + INF_REG0_OFFSET)
  109. /* r1 = physical address of s3c6400_cpu_resume function */
  110. ldr r1, [r0]
  111. /* Jump to kernel (sleep-s3c6400.S) */
  112. mov pc, r1
  113. nop
  114. nop
  115. /*
  116. * system_clock_init: Initialize core clock and bus clock.
  117. * void system_clock_init(void)
  118. */
  119. system_clock_init:
  120. ldr r0, =ELFIN_CLOCK_POWER_BASE /* 0x7e00f000 */
  121. #ifdef CONFIG_SYNC_MODE
  122. ldr r1, [r0, #OTHERS_OFFSET]
  123. mov r2, #0x40
  124. orr r1, r1, r2
  125. str r1, [r0, #OTHERS_OFFSET]
  126. nop
  127. nop
  128. nop
  129. nop
  130. nop
  131. ldr r2, =0x80
  132. orr r1, r1, r2
  133. str r1, [r0, #OTHERS_OFFSET]
  134. check_syncack:
  135. ldr r1, [r0, #OTHERS_OFFSET]
  136. ldr r2, =0xf00
  137. and r1, r1, r2
  138. cmp r1, #0xf00
  139. bne check_syncack
  140. #else /* ASYNC Mode */
  141. nop
  142. nop
  143. nop
  144. nop
  145. nop
  146. /*
  147. * This was unconditional in original Samsung sources, but it doesn't
  148. * seem to make much sense on S3C6400.
  149. */
  150. #ifndef CONFIG_S3C6400
  151. ldr r1, [r0, #OTHERS_OFFSET]
  152. bic r1, r1, #0xC0
  153. orr r1, r1, #0x40
  154. str r1, [r0, #OTHERS_OFFSET]
  155. wait_for_async:
  156. ldr r1, [r0, #OTHERS_OFFSET]
  157. and r1, r1, #0xf00
  158. cmp r1, #0x0
  159. bne wait_for_async
  160. #endif
  161. ldr r1, [r0, #OTHERS_OFFSET]
  162. bic r1, r1, #0x40
  163. str r1, [r0, #OTHERS_OFFSET]
  164. #endif
  165. mov r1, #0xff00
  166. orr r1, r1, #0xff
  167. str r1, [r0, #APLL_LOCK_OFFSET]
  168. str r1, [r0, #MPLL_LOCK_OFFSET]
  169. /* Set Clock Divider */
  170. ldr r1, [r0, #CLK_DIV0_OFFSET]
  171. bic r1, r1, #0x30000
  172. bic r1, r1, #0xff00
  173. bic r1, r1, #0xff
  174. ldr r2, =CLK_DIV_VAL
  175. orr r1, r1, r2
  176. str r1, [r0, #CLK_DIV0_OFFSET]
  177. ldr r1, =APLL_VAL
  178. str r1, [r0, #APLL_CON_OFFSET]
  179. ldr r1, =MPLL_VAL
  180. str r1, [r0, #MPLL_CON_OFFSET]
  181. /* FOUT of EPLL is 96MHz */
  182. ldr r1, =0x200203
  183. str r1, [r0, #EPLL_CON0_OFFSET]
  184. ldr r1, =0x0
  185. str r1, [r0, #EPLL_CON1_OFFSET]
  186. /* APLL, MPLL, EPLL select to Fout */
  187. ldr r1, [r0, #CLK_SRC_OFFSET]
  188. orr r1, r1, #0x7
  189. str r1, [r0, #CLK_SRC_OFFSET]
  190. /* wait at least 200us to stablize all clock */
  191. mov r1, #0x10000
  192. 1: subs r1, r1, #1
  193. bne 1b
  194. /* Synchronization for VIC port */
  195. #if defined(CONFIG_SYNC_MODE)
  196. ldr r1, [r0, #OTHERS_OFFSET]
  197. orr r1, r1, #0x20
  198. str r1, [r0, #OTHERS_OFFSET]
  199. #elif !defined(CONFIG_S3C6400)
  200. /* According to 661558um_S3C6400X_rev10.pdf 0x20 is reserved */
  201. ldr r1, [r0, #OTHERS_OFFSET]
  202. bic r1, r1, #0x20
  203. str r1, [r0, #OTHERS_OFFSET]
  204. #endif
  205. mov pc, lr
  206. #ifndef CONFIG_NAND_SPL
  207. /*
  208. * uart_asm_init: Initialize UART's pins
  209. */
  210. uart_asm_init:
  211. /* set GPIO to enable UART */
  212. ldr r0, =ELFIN_GPIO_BASE
  213. ldr r1, =0x220022
  214. str r1, [r0, #GPACON_OFFSET]
  215. mov pc, lr
  216. #endif
  217. #ifdef CONFIG_BOOT_NAND
  218. /*
  219. * NAND Interface init for SMDK6400
  220. */
  221. nand_asm_init:
  222. ldr r0, =ELFIN_NAND_BASE
  223. ldr r1, [r0, #NFCONF_OFFSET]
  224. orr r1, r1, #0x70
  225. orr r1, r1, #0x7700
  226. str r1, [r0, #NFCONF_OFFSET]
  227. ldr r1, [r0, #NFCONT_OFFSET]
  228. orr r1, r1, #0x07
  229. str r1, [r0, #NFCONT_OFFSET]
  230. mov pc, lr
  231. #endif
  232. #ifdef CONFIG_ENABLE_MMU
  233. /*
  234. * MMU Table for SMDK6400
  235. */
  236. /* form a first-level section entry */
  237. .macro FL_SECTION_ENTRY base,ap,d,c,b
  238. .word (\base << 20) | (\ap << 10) | \
  239. (\d << 5) | (1<<4) | (\c << 3) | (\b << 2) | (1<<1)
  240. .endm
  241. .section .mmudata, "a"
  242. .align 14
  243. /* the following alignment creates the mmu table at address 0x4000. */
  244. .globl mmu_table
  245. mmu_table:
  246. .set __base, 0
  247. /* 1:1 mapping for debugging */
  248. .rept 0xA00
  249. FL_SECTION_ENTRY __base, 3, 0, 0, 0
  250. .set __base, __base + 1
  251. .endr
  252. /* access is not allowed. */
  253. .rept 0xC00 - 0xA00
  254. .word 0x00000000
  255. .endr
  256. /* 128MB for SDRAM 0xC0000000 -> 0x50000000 */
  257. .set __base, 0x500
  258. .rept 0xC80 - 0xC00
  259. FL_SECTION_ENTRY __base, 3, 0, 1, 1
  260. .set __base, __base + 1
  261. .endr
  262. /* access is not allowed. */
  263. .rept 0x1000 - 0xc80
  264. .word 0x00000000
  265. .endr
  266. #endif