start.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. * Note: _armboot_end_data and _armboot_end are defined
  63. * by the (board-dependent) linker script.
  64. * _armboot_end_data is the first usable FLASH address after armboot
  65. */
  66. .globl _armboot_end_data
  67. _armboot_end_data:
  68. .word armboot_end_data
  69. .globl _armboot_end
  70. _armboot_end:
  71. .word armboot_end
  72. #ifdef CONFIG_USE_IRQ
  73. /* IRQ stack memory (calculated at run-time) */
  74. .globl IRQ_STACK_START
  75. IRQ_STACK_START:
  76. .word 0x0badc0de
  77. /* IRQ stack memory (calculated at run-time) */
  78. .globl FIQ_STACK_START
  79. FIQ_STACK_START:
  80. .word 0x0badc0de
  81. #endif
  82. /*
  83. * the actual reset code
  84. */
  85. reset:
  86. /*
  87. * set the cpu to SVC32 mode
  88. */
  89. mrs r0,cpsr
  90. bic r0,r0,#0x1f
  91. orr r0,r0,#0x13
  92. msr cpsr,r0
  93. /*
  94. * we do sys-critical inits only at reboot,
  95. * not when booting from ram!
  96. */
  97. #ifdef CONFIG_INIT_CRITICAL
  98. bl cpu_init_crit
  99. /*
  100. * before relocating, we have to setup RAM timing
  101. * because memory timing is board-dependend, you will
  102. * find a memsetup.S in your board directory.
  103. */
  104. bl memsetup
  105. #endif
  106. relocate: /* relocate U-Boot to RAM */
  107. adr r0, _start /* r0 <- current position of code */
  108. ldr r1, _TEXT_BASE /* test if we run from flash or RAM */
  109. cmp r0, r1 /* don't reloc during debug */
  110. beq stack_setup
  111. ldr r2, _armboot_start
  112. ldr r3, _armboot_end
  113. sub r2, r3, r2 /* r2 <- size of armboot */
  114. add r2, r0, r2 /* r2 <- source end address */
  115. copy_loop:
  116. ldmia r0!, {r3-r10} /* copy from source address [r0] */
  117. stmia r1!, {r3-r10} /* copy to target address [r1] */
  118. cmp r0, r2 /* until source end addreee [r2] */
  119. ble copy_loop
  120. /*
  121. now copy to sram the interrupt vector
  122. */
  123. adr r0, real_vectors
  124. add r2, r0, #1024
  125. ldr r1, =0x0c000000
  126. add r1, r1, #0x08
  127. vector_copy_loop:
  128. ldmia r0!, {r3-r10}
  129. stmia r1!, {r3-r10}
  130. cmp r0, r2
  131. ble vector_copy_loop
  132. /* Set up the stack */
  133. stack_setup:
  134. ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
  135. sub r0, r0, #CFG_MALLOC_LEN /* malloc area */
  136. sub r0, r0, #CFG_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