head.S 5.1 KB

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