start.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Startup Code for S3C44B0 CPU-core
  3. *
  4. * (C) Copyright 2004
  5. * DAVE Srl
  6. *
  7. * http://www.dave-tech.it
  8. * http://www.wawnet.biz
  9. * mailto:info@wawnet.biz
  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. /*
  32. * Jump vector table
  33. */
  34. .globl _start
  35. _start: b reset
  36. add pc, pc, #0x0c000000
  37. add pc, pc, #0x0c000000
  38. add pc, pc, #0x0c000000
  39. add pc, pc, #0x0c000000
  40. add pc, pc, #0x0c000000
  41. add pc, pc, #0x0c000000
  42. add pc, pc, #0x0c000000
  43. .balignl 16,0xdeadbeef
  44. /*
  45. *************************************************************************
  46. *
  47. * Startup Code (reset vector)
  48. *
  49. * do important init only if we don't start from memory!
  50. * relocate u-boot to ram
  51. * setup stack
  52. * jump to second stage
  53. *
  54. *************************************************************************
  55. */
  56. _TEXT_BASE:
  57. .word TEXT_BASE
  58. .globl _armboot_start
  59. _armboot_start:
  60. .word _start
  61. /*
  62. * These are defined in the board-specific linker script.
  63. */
  64. .globl _bss_start
  65. _bss_start:
  66. .word __bss_start
  67. .globl _bss_end
  68. _bss_end:
  69. .word _end
  70. #ifdef CONFIG_USE_IRQ
  71. /* IRQ stack memory (calculated at run-time) */
  72. .globl IRQ_STACK_START
  73. IRQ_STACK_START:
  74. .word 0x0badc0de
  75. /* IRQ stack memory (calculated at run-time) */
  76. .globl FIQ_STACK_START
  77. FIQ_STACK_START:
  78. .word 0x0badc0de
  79. #endif
  80. /*
  81. * the actual reset code
  82. */
  83. reset:
  84. /*
  85. * set the cpu to SVC32 mode
  86. */
  87. mrs r0,cpsr
  88. bic r0,r0,#0x1f
  89. orr r0,r0,#0x13
  90. msr cpsr,r0
  91. /*
  92. * we do sys-critical inits only at reboot,
  93. * not when booting from ram!
  94. */
  95. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  96. bl cpu_init_crit
  97. /*
  98. * before relocating, we have to setup RAM timing
  99. * because memory timing is board-dependend, you will
  100. * find a lowlevel_init.S in your board directory.
  101. */
  102. bl lowlevel_init
  103. #endif
  104. #ifndef CONFIG_SKIP_RELOCATE_UBOOT
  105. relocate: /* relocate U-Boot to RAM */
  106. adr r0, _start /* r0 <- current position of code */
  107. ldr r1, _TEXT_BASE /* test if we run from flash or RAM */
  108. cmp r0, r1 /* don't reloc during debug */
  109. beq stack_setup
  110. ldr r2, _armboot_start
  111. ldr r3, _bss_start
  112. sub r2, r3, r2 /* r2 <- size of armboot */
  113. add r2, r0, r2 /* r2 <- source end address */
  114. copy_loop:
  115. ldmia r0!, {r3-r10} /* copy from source address [r0] */
  116. stmia r1!, {r3-r10} /* copy to target address [r1] */
  117. cmp r0, r2 /* until source end addreee [r2] */
  118. ble copy_loop
  119. /*
  120. now copy to sram the interrupt vector
  121. */
  122. adr r0, real_vectors
  123. add r2, r0, #1024
  124. ldr r1, =0x0c000000
  125. add r1, r1, #0x08
  126. vector_copy_loop:
  127. ldmia r0!, {r3-r10}
  128. stmia r1!, {r3-r10}
  129. cmp r0, r2
  130. ble vector_copy_loop
  131. #endif /* CONFIG_SKIP_RELOCATE_UBOOT */
  132. /* Set up the stack */
  133. stack_setup:
  134. ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
  135. sub r0, r0, #CONFIG_SYS_MALLOC_LEN /* malloc area */
  136. sub r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo */
  137. #ifdef CONFIG_USE_IRQ
  138. sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
  139. #endif
  140. sub sp, r0, #12 /* leave 3 words for abort-stack */
  141. ldr pc, _start_armboot
  142. _start_armboot: .word start_armboot
  143. /*
  144. *************************************************************************
  145. *
  146. * CPU_init_critical registers
  147. *
  148. * setup important registers
  149. * setup memory timing
  150. *
  151. *************************************************************************
  152. */
  153. #define INTCON (0x01c00000+0x200000)
  154. #define INTMSK (0x01c00000+0x20000c)
  155. #define LOCKTIME (0x01c00000+0x18000c)
  156. #define PLLCON (0x01c00000+0x180000)
  157. #define CLKCON (0x01c00000+0x180004)
  158. #define WTCON (0x01c00000+0x130000)
  159. cpu_init_crit:
  160. /* disable watch dog */
  161. ldr r0, =WTCON
  162. ldr r1, =0x0
  163. str r1, [r0]
  164. /*
  165. * mask all IRQs by clearing all bits in the INTMRs
  166. */
  167. ldr r1,=INTMSK
  168. ldr r0, =0x03fffeff
  169. str r0, [r1]
  170. ldr r1, =INTCON
  171. ldr r0, =0x05
  172. str r0, [r1]
  173. /* Set Clock Control Register */
  174. ldr r1, =LOCKTIME
  175. ldrb r0, =800
  176. strb r0, [r1]
  177. ldr r1, =PLLCON
  178. #if CONFIG_S3C44B0_CLOCK_SPEED==66
  179. ldr r0, =0x34031 /* 66MHz (Quartz=11MHz) */
  180. #elif CONFIG_S3C44B0_CLOCK_SPEED==75
  181. ldr r0, =0x610c1 /*B2: Xtal=20mhz Fclk=75MHz */
  182. #else
  183. # error CONFIG_S3C44B0_CLOCK_SPEED undefined
  184. #endif
  185. str r0, [r1]
  186. ldr r1,=CLKCON
  187. ldr r0, =0x7ff8
  188. str r0, [r1]
  189. mov pc, lr
  190. /*************************************************/
  191. /* interrupt vectors */
  192. /*************************************************/
  193. real_vectors:
  194. b reset
  195. b undefined_instruction
  196. b software_interrupt
  197. b prefetch_abort
  198. b data_abort
  199. b not_used
  200. b irq
  201. b fiq
  202. /*************************************************/
  203. undefined_instruction:
  204. mov r6, #3
  205. b reset
  206. software_interrupt:
  207. mov r6, #4
  208. b reset
  209. prefetch_abort:
  210. mov r6, #5
  211. b reset
  212. data_abort:
  213. mov r6, #6
  214. b reset
  215. not_used:
  216. /* we *should* never reach this */
  217. mov r6, #7
  218. b reset
  219. irq:
  220. mov r6, #8
  221. b reset
  222. fiq:
  223. mov r6, #9
  224. b reset