head.S 5.0 KB

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