start.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. #ifdef CONFIG_INIT_CRITICAL
  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 memsetup.S in your board directory.
  101. */
  102. bl memsetup
  103. #endif
  104. relocate: /* relocate U-Boot to RAM */
  105. adr r0, _start /* r0 <- current position of code */
  106. ldr r1, _TEXT_BASE /* test if we run from flash or RAM */
  107. cmp r0, r1 /* don't reloc during debug */
  108. beq stack_setup
  109. ldr r2, _armboot_start
  110. ldr r3, _bss_start
  111. sub r2, r3, r2 /* r2 <- size of armboot */
  112. add r2, r0, r2 /* r2 <- source end address */
  113. copy_loop:
  114. ldmia r0!, {r3-r10} /* copy from source address [r0] */
  115. stmia r1!, {r3-r10} /* copy to target address [r1] */
  116. cmp r0, r2 /* until source end addreee [r2] */
  117. ble copy_loop
  118. /*
  119. now copy to sram the interrupt vector
  120. */
  121. adr r0, real_vectors
  122. add r2, r0, #1024
  123. ldr r1, =0x0c000000
  124. add r1, r1, #0x08
  125. vector_copy_loop:
  126. ldmia r0!, {r3-r10}
  127. stmia r1!, {r3-r10}
  128. cmp r0, r2
  129. ble vector_copy_loop
  130. /* Set up the stack */
  131. stack_setup:
  132. ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
  133. sub r0, r0, #CFG_MALLOC_LEN /* malloc area */
  134. sub r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo */
  135. #ifdef CONFIG_USE_IRQ
  136. sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
  137. #endif
  138. sub sp, r0, #12 /* leave 3 words for abort-stack */
  139. ldr pc, _start_armboot
  140. _start_armboot: .word start_armboot
  141. /*
  142. *************************************************************************
  143. *
  144. * CPU_init_critical registers
  145. *
  146. * setup important registers
  147. * setup memory timing
  148. *
  149. *************************************************************************
  150. */
  151. #define INTCON (0x01c00000+0x200000)
  152. #define INTMSK (0x01c00000+0x20000c)
  153. #define LOCKTIME (0x01c00000+0x18000c)
  154. #define PLLCON (0x01c00000+0x180000)
  155. #define CLKCON (0x01c00000+0x180004)
  156. #define WTCON (0x01c00000+0x130000)
  157. cpu_init_crit:
  158. /* disable watch dog */
  159. ldr r0, =WTCON
  160. ldr r1, =0x0
  161. str r1, [r0]
  162. /*
  163. * mask all IRQs by clearing all bits in the INTMRs
  164. */
  165. ldr r1,=INTMSK
  166. ldr r0, =0x03fffeff
  167. str r0, [r1]
  168. ldr r1, =INTCON
  169. ldr r0, =0x05
  170. str r0, [r1]
  171. /* Set Clock Control Register */
  172. ldr r1, =LOCKTIME
  173. ldrb r0, =800
  174. strb r0, [r1]
  175. ldr r1, =PLLCON
  176. #if CONFIG_S3C44B0_CLOCK_SPEED==66
  177. ldr r0, =0x34031 /* 66MHz (Quartz=11MHz) */
  178. #elif CONFIG_S3C44B0_CLOCK_SPEED==75
  179. ldr r0, =0x610c1 /*B2: Xtal=20mhz Fclk=75MHz */
  180. #else
  181. # error CONFIG_S3C44B0_CLOCK_SPEED undefined
  182. #endif
  183. str r0, [r1]
  184. ldr r1,=CLKCON
  185. ldr r0, =0x7ff8
  186. str r0, [r1]
  187. mov pc, lr
  188. /*************************************************/
  189. /* interrupt vectors */
  190. /*************************************************/
  191. real_vectors:
  192. b reset
  193. b undefined_instruction
  194. b software_interrupt
  195. b prefetch_abort
  196. b data_abort
  197. b not_used
  198. b irq
  199. b fiq
  200. /*************************************************/
  201. undefined_instruction:
  202. mov r6, #3
  203. b reset
  204. software_interrupt:
  205. mov r6, #4
  206. b reset
  207. prefetch_abort:
  208. mov r6, #5
  209. b reset
  210. data_abort:
  211. mov r6, #6
  212. b reset
  213. not_used:
  214. /* we *should* never reach this */
  215. mov r6, #7
  216. b reset
  217. irq:
  218. mov r6, #8
  219. b reset
  220. fiq:
  221. mov r6, #9
  222. b reset