lowlevel_init.S 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. /* Memory subsystem address 0x7e00f120 */
  89. ldr r0, =ELFIN_MEM_SYS_CFG
  90. /* Xm0CSn2 = NFCON CS0, Xm0CSn3 = NFCON CS1 */
  91. mov r1, #S3C64XX_MEM_SYS_CFG_NAND
  92. str r1, [r0]
  93. bl mem_ctrl_asm_init
  94. /* Wakeup support. Don't know if it's going to be used, untested. */
  95. ldr r0, =(ELFIN_CLOCK_POWER_BASE + RST_STAT_OFFSET)
  96. ldr r1, [r0]
  97. bic r1, r1, #0xfffffff7
  98. cmp r1, #0x8
  99. beq wakeup_reset
  100. 1:
  101. mov lr, r12
  102. mov pc, lr
  103. wakeup_reset:
  104. /* Clear wakeup status register */
  105. ldr r0, =(ELFIN_CLOCK_POWER_BASE + WAKEUP_STAT_OFFSET)
  106. ldr r1, [r0]
  107. str r1, [r0]
  108. /* LED test */
  109. ldr r0, =ELFIN_GPIO_BASE
  110. ldr r1, =0x3000
  111. str r1, [r0, #GPNDAT_OFFSET]
  112. /* Load return address and jump to kernel */
  113. ldr r0, =(ELFIN_CLOCK_POWER_BASE + INF_REG0_OFFSET)
  114. /* r1 = physical address of s3c6400_cpu_resume function */
  115. ldr r1, [r0]
  116. /* Jump to kernel (sleep-s3c6400.S) */
  117. mov pc, r1
  118. nop
  119. nop
  120. /*
  121. * system_clock_init: Initialize core clock and bus clock.
  122. * void system_clock_init(void)
  123. */
  124. system_clock_init:
  125. ldr r0, =ELFIN_CLOCK_POWER_BASE /* 0x7e00f000 */
  126. #ifdef CONFIG_SYNC_MODE
  127. ldr r1, [r0, #OTHERS_OFFSET]
  128. mov r2, #0x40
  129. orr r1, r1, r2
  130. str r1, [r0, #OTHERS_OFFSET]
  131. nop
  132. nop
  133. nop
  134. nop
  135. nop
  136. ldr r2, =0x80
  137. orr r1, r1, r2
  138. str r1, [r0, #OTHERS_OFFSET]
  139. check_syncack:
  140. ldr r1, [r0, #OTHERS_OFFSET]
  141. ldr r2, =0xf00
  142. and r1, r1, r2
  143. cmp r1, #0xf00
  144. bne check_syncack
  145. #else /* ASYNC Mode */
  146. nop
  147. nop
  148. nop
  149. nop
  150. nop
  151. /*
  152. * This was unconditional in original Samsung sources, but it doesn't
  153. * seem to make much sense on S3C6400.
  154. */
  155. #ifndef CONFIG_S3C6400
  156. ldr r1, [r0, #OTHERS_OFFSET]
  157. bic r1, r1, #0xC0
  158. orr r1, r1, #0x40
  159. str r1, [r0, #OTHERS_OFFSET]
  160. wait_for_async:
  161. ldr r1, [r0, #OTHERS_OFFSET]
  162. and r1, r1, #0xf00
  163. cmp r1, #0x0
  164. bne wait_for_async
  165. #endif
  166. ldr r1, [r0, #OTHERS_OFFSET]
  167. bic r1, r1, #0x40
  168. str r1, [r0, #OTHERS_OFFSET]
  169. #endif
  170. mov r1, #0xff00
  171. orr r1, r1, #0xff
  172. str r1, [r0, #APLL_LOCK_OFFSET]
  173. str r1, [r0, #MPLL_LOCK_OFFSET]
  174. /* Set Clock Divider */
  175. ldr r1, [r0, #CLK_DIV0_OFFSET]
  176. bic r1, r1, #0x30000
  177. bic r1, r1, #0xff00
  178. bic r1, r1, #0xff
  179. ldr r2, =CLK_DIV_VAL
  180. orr r1, r1, r2
  181. str r1, [r0, #CLK_DIV0_OFFSET]
  182. ldr r1, =APLL_VAL
  183. str r1, [r0, #APLL_CON_OFFSET]
  184. ldr r1, =MPLL_VAL
  185. str r1, [r0, #MPLL_CON_OFFSET]
  186. /* FOUT of EPLL is 96MHz */
  187. ldr r1, =0x200203
  188. str r1, [r0, #EPLL_CON0_OFFSET]
  189. ldr r1, =0x0
  190. str r1, [r0, #EPLL_CON1_OFFSET]
  191. /* APLL, MPLL, EPLL select to Fout */
  192. ldr r1, [r0, #CLK_SRC_OFFSET]
  193. orr r1, r1, #0x7
  194. str r1, [r0, #CLK_SRC_OFFSET]
  195. /* wait at least 200us to stablize all clock */
  196. mov r1, #0x10000
  197. 1: subs r1, r1, #1
  198. bne 1b
  199. /* Synchronization for VIC port */
  200. #if defined(CONFIG_SYNC_MODE)
  201. ldr r1, [r0, #OTHERS_OFFSET]
  202. orr r1, r1, #0x20
  203. str r1, [r0, #OTHERS_OFFSET]
  204. #elif !defined(CONFIG_S3C6400)
  205. /* According to 661558um_S3C6400X_rev10.pdf 0x20 is reserved */
  206. ldr r1, [r0, #OTHERS_OFFSET]
  207. bic r1, r1, #0x20
  208. str r1, [r0, #OTHERS_OFFSET]
  209. #endif
  210. mov pc, lr
  211. #ifndef CONFIG_NAND_SPL
  212. /*
  213. * uart_asm_init: Initialize UART's pins
  214. */
  215. uart_asm_init:
  216. /* set GPIO to enable UART */
  217. ldr r0, =ELFIN_GPIO_BASE
  218. ldr r1, =0x220022
  219. str r1, [r0, #GPACON_OFFSET]
  220. mov pc, lr
  221. #endif
  222. #ifdef CONFIG_BOOT_NAND
  223. /*
  224. * NAND Interface init for SMDK6400
  225. */
  226. nand_asm_init:
  227. ldr r0, =ELFIN_NAND_BASE
  228. ldr r1, [r0, #NFCONF_OFFSET]
  229. orr r1, r1, #0x70
  230. orr r1, r1, #0x7700
  231. str r1, [r0, #NFCONF_OFFSET]
  232. ldr r1, [r0, #NFCONT_OFFSET]
  233. orr r1, r1, #0x07
  234. str r1, [r0, #NFCONT_OFFSET]
  235. mov pc, lr
  236. #endif
  237. #ifdef CONFIG_ENABLE_MMU
  238. /*
  239. * MMU Table for SMDK6400
  240. */
  241. /* form a first-level section entry */
  242. .macro FL_SECTION_ENTRY base,ap,d,c,b
  243. .word (\base << 20) | (\ap << 10) | \
  244. (\d << 5) | (1<<4) | (\c << 3) | (\b << 2) | (1<<1)
  245. .endm
  246. .section .mmudata, "a"
  247. .align 14
  248. /* the following alignment creates the mmu table at address 0x4000. */
  249. .globl mmu_table
  250. mmu_table:
  251. .set __base, 0
  252. /* 1:1 mapping for debugging */
  253. .rept 0xA00
  254. FL_SECTION_ENTRY __base, 3, 0, 0, 0
  255. .set __base, __base + 1
  256. .endr
  257. /* access is not allowed. */
  258. .rept 0xC00 - 0xA00
  259. .word 0x00000000
  260. .endr
  261. /* 128MB for SDRAM 0xC0000000 -> 0x50000000 */
  262. .set __base, 0x500
  263. .rept 0xC80 - 0xC00
  264. FL_SECTION_ENTRY __base, 3, 0, 1, 1
  265. .set __base, __base + 1
  266. .endr
  267. /* access is not allowed. */
  268. .rept 0x1000 - 0xc80
  269. .word 0x00000000
  270. .endr
  271. #endif