head.S 4.5 KB

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