head.S 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * Common Blackfin startup code
  3. *
  4. * Copyright 2004-2008 Analog Devices Inc.
  5. *
  6. * Enter bugs at http://blackfin.uclinux.org/
  7. *
  8. * Licensed under the GPL-2 or later.
  9. */
  10. #include <linux/linkage.h>
  11. #include <linux/init.h>
  12. #include <asm/blackfin.h>
  13. #include <asm/thread_info.h>
  14. #include <asm/trace.h>
  15. __INIT
  16. #define INITIAL_STACK (L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
  17. ENTRY(__start)
  18. /* R0: argument of command line string, passed from uboot, save it */
  19. R7 = R0;
  20. /* Enable Cycle Counter and Nesting Of Interrupts */
  21. #ifdef CONFIG_BFIN_SCRATCH_REG_CYCLES
  22. R0 = SYSCFG_SNEN;
  23. #else
  24. R0 = SYSCFG_SNEN | SYSCFG_CCEN;
  25. #endif
  26. SYSCFG = R0;
  27. R0 = 0;
  28. /* Clear Out All the data and pointer Registers */
  29. R1 = R0;
  30. R2 = R0;
  31. R3 = R0;
  32. R4 = R0;
  33. R5 = R0;
  34. R6 = R0;
  35. P0 = R0;
  36. P1 = R0;
  37. P2 = R0;
  38. P3 = R0;
  39. P4 = R0;
  40. P5 = R0;
  41. LC0 = r0;
  42. LC1 = r0;
  43. L0 = r0;
  44. L1 = r0;
  45. L2 = r0;
  46. L3 = r0;
  47. /* Clear Out All the DAG Registers */
  48. B0 = r0;
  49. B1 = r0;
  50. B2 = r0;
  51. B3 = r0;
  52. I0 = r0;
  53. I1 = r0;
  54. I2 = r0;
  55. I3 = r0;
  56. M0 = r0;
  57. M1 = r0;
  58. M2 = r0;
  59. M3 = r0;
  60. /*
  61. * Clear ITEST_COMMAND and DTEST_COMMAND registers,
  62. * Leaving these as non-zero can confuse the emulator
  63. */
  64. p0.L = LO(DTEST_COMMAND);
  65. p0.H = HI(DTEST_COMMAND);
  66. [p0] = R0;
  67. [p0 + (ITEST_COMMAND - DTEST_COMMAND)] = R0;
  68. CSYNC;
  69. trace_buffer_init(p0,r0);
  70. P0 = R1;
  71. R0 = R1;
  72. /* Turn off the icache */
  73. p0.l = LO(IMEM_CONTROL);
  74. p0.h = HI(IMEM_CONTROL);
  75. R1 = [p0];
  76. R0 = ~ENICPLB;
  77. R0 = R0 & R1;
  78. [p0] = R0;
  79. SSYNC;
  80. /* Turn off the dcache */
  81. p0.l = LO(DMEM_CONTROL);
  82. p0.h = HI(DMEM_CONTROL);
  83. R1 = [p0];
  84. R0 = ~ENDCPLB;
  85. R0 = R0 & R1;
  86. [p0] = R0;
  87. SSYNC;
  88. /* in case of double faults, save a few things */
  89. p0.l = _init_retx;
  90. p0.h = _init_retx;
  91. R0 = RETX;
  92. [P0] = R0;
  93. #ifdef CONFIG_DEBUG_DOUBLEFAULT
  94. /* Only save these if we are storing them,
  95. * This happens here, since L1 gets clobbered
  96. * below
  97. */
  98. p0.l = _saved_retx;
  99. p0.h = _saved_retx;
  100. p1.l = _init_saved_retx;
  101. p1.h = _init_saved_retx;
  102. r0 = [p0];
  103. [p1] = r0;
  104. p0.l = _saved_dcplb_fault_addr;
  105. p0.h = _saved_dcplb_fault_addr;
  106. p1.l = _init_saved_dcplb_fault_addr;
  107. p1.h = _init_saved_dcplb_fault_addr;
  108. r0 = [p0];
  109. [p1] = r0;
  110. p0.l = _saved_icplb_fault_addr;
  111. p0.h = _saved_icplb_fault_addr;
  112. p1.l = _init_saved_icplb_fault_addr;
  113. p1.h = _init_saved_icplb_fault_addr;
  114. r0 = [p0];
  115. [p1] = r0;
  116. p0.l = _saved_seqstat;
  117. p0.h = _saved_seqstat;
  118. p1.l = _init_saved_seqstat;
  119. p1.h = _init_saved_seqstat;
  120. r0 = [p0];
  121. [p1] = r0;
  122. #endif
  123. /* Initialize stack pointer */
  124. sp.l = lo(INITIAL_STACK);
  125. sp.h = hi(INITIAL_STACK);
  126. fp = sp;
  127. usp = sp;
  128. #ifdef CONFIG_EARLY_PRINTK
  129. call _init_early_exception_vectors;
  130. #endif
  131. /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
  132. call _bfin_relocate_l1_mem;
  133. #ifdef CONFIG_BFIN_KERNEL_CLOCK
  134. call _start_dma_code;
  135. #endif
  136. /* This section keeps the processor in supervisor mode
  137. * during kernel boot. Switches to user mode at end of boot.
  138. * See page 3-9 of Hardware Reference manual for documentation.
  139. */
  140. /* EVT15 = _real_start */
  141. p0.l = lo(EVT15);
  142. p0.h = hi(EVT15);
  143. p1.l = _real_start;
  144. p1.h = _real_start;
  145. [p0] = p1;
  146. csync;
  147. p0.l = lo(IMASK);
  148. p0.h = hi(IMASK);
  149. p1.l = IMASK_IVG15;
  150. p1.h = 0x0;
  151. [p0] = p1;
  152. csync;
  153. raise 15;
  154. p0.l = .LWAIT_HERE;
  155. p0.h = .LWAIT_HERE;
  156. reti = p0;
  157. #if ANOMALY_05000281
  158. nop; nop; nop;
  159. #endif
  160. rti;
  161. .LWAIT_HERE:
  162. jump .LWAIT_HERE;
  163. ENDPROC(__start)
  164. /* A little BF561 glue ... */
  165. #ifndef WDOG_CTL
  166. # define WDOG_CTL WDOGA_CTL
  167. #endif
  168. ENTRY(__init_clear_bss)
  169. r2 = r2 - r1;
  170. cc = r2 == 0;
  171. if cc jump .L_bss_done;
  172. r2 >>= 2;
  173. p1 = r1;
  174. p2 = r2;
  175. lsetup (1f, 1f) lc0 = p2;
  176. 1: [p1++] = r0;
  177. .L_bss_done:
  178. rts;
  179. ENDPROC(__init_clear_bss)
  180. ENTRY(_real_start)
  181. /* Enable nested interrupts */
  182. [--sp] = reti;
  183. /* watchdog off for now */
  184. p0.l = lo(WDOG_CTL);
  185. p0.h = hi(WDOG_CTL);
  186. r0 = 0xAD6(z);
  187. w[p0] = r0;
  188. ssync;
  189. r0 = 0 (x);
  190. /* Zero out all of the fun bss regions */
  191. #if L1_DATA_A_LENGTH > 0
  192. r1.l = __sbss_l1;
  193. r1.h = __sbss_l1;
  194. r2.l = __ebss_l1;
  195. r2.h = __ebss_l1;
  196. call __init_clear_bss
  197. #endif
  198. #if L1_DATA_B_LENGTH > 0
  199. r1.l = __sbss_b_l1;
  200. r1.h = __sbss_b_l1;
  201. r2.l = __ebss_b_l1;
  202. r2.h = __ebss_b_l1;
  203. call __init_clear_bss
  204. #endif
  205. #if L2_LENGTH > 0
  206. r1.l = __sbss_l2;
  207. r1.h = __sbss_l2;
  208. r2.l = __ebss_l2;
  209. r2.h = __ebss_l2;
  210. call __init_clear_bss
  211. #endif
  212. r1.l = ___bss_start;
  213. r1.h = ___bss_start;
  214. r2.l = ___bss_stop;
  215. r2.h = ___bss_stop;
  216. call __init_clear_bss
  217. /* In case there is a NULL pointer reference,
  218. * zero out region before stext
  219. */
  220. p1 = r0;
  221. r2.l = __stext;
  222. r2.h = __stext;
  223. r2 >>= 2;
  224. p2 = r2;
  225. lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2;
  226. .L_clear_zero:
  227. [p1++] = r0;
  228. /* Pass the u-boot arguments to the global value command line */
  229. R0 = R7;
  230. call _cmdline_init;
  231. /* Load the current thread pointer and stack */
  232. sp.l = _init_thread_union;
  233. sp.h = _init_thread_union;
  234. p1 = THREAD_SIZE (z);
  235. sp = sp + p1;
  236. usp = sp;
  237. fp = sp;
  238. jump.l _start_kernel;
  239. ENDPROC(_real_start)
  240. __FINIT