head.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. trace_buffer_init(p0,r0);
  61. P0 = R1;
  62. R0 = R1;
  63. /* Turn off the icache */
  64. p0.l = LO(IMEM_CONTROL);
  65. p0.h = HI(IMEM_CONTROL);
  66. R1 = [p0];
  67. R0 = ~ENICPLB;
  68. R0 = R0 & R1;
  69. [p0] = R0;
  70. SSYNC;
  71. /* Turn off the dcache */
  72. p0.l = LO(DMEM_CONTROL);
  73. p0.h = HI(DMEM_CONTROL);
  74. R1 = [p0];
  75. R0 = ~ENDCPLB;
  76. R0 = R0 & R1;
  77. [p0] = R0;
  78. SSYNC;
  79. /* Save RETX, in case of doublefault */
  80. p0.l = ___retx;
  81. p0.h = ___retx;
  82. R0 = RETX;
  83. [P0] = R0;
  84. /* Initialize stack pointer */
  85. sp.l = lo(INITIAL_STACK);
  86. sp.h = hi(INITIAL_STACK);
  87. fp = sp;
  88. usp = sp;
  89. #ifdef CONFIG_EARLY_PRINTK
  90. call _init_early_exception_vectors;
  91. #endif
  92. /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
  93. call _bf53x_relocate_l1_mem;
  94. #ifdef CONFIG_BFIN_KERNEL_CLOCK
  95. call _start_dma_code;
  96. #endif
  97. /* This section keeps the processor in supervisor mode
  98. * during kernel boot. Switches to user mode at end of boot.
  99. * See page 3-9 of Hardware Reference manual for documentation.
  100. */
  101. /* EVT15 = _real_start */
  102. p0.l = lo(EVT15);
  103. p0.h = hi(EVT15);
  104. p1.l = _real_start;
  105. p1.h = _real_start;
  106. [p0] = p1;
  107. csync;
  108. p0.l = lo(IMASK);
  109. p0.h = hi(IMASK);
  110. p1.l = IMASK_IVG15;
  111. p1.h = 0x0;
  112. [p0] = p1;
  113. csync;
  114. raise 15;
  115. p0.l = .LWAIT_HERE;
  116. p0.h = .LWAIT_HERE;
  117. reti = p0;
  118. #if ANOMALY_05000281
  119. nop; nop; nop;
  120. #endif
  121. rti;
  122. .LWAIT_HERE:
  123. jump .LWAIT_HERE;
  124. ENDPROC(__start)
  125. /* A little BF561 glue ... */
  126. #ifndef WDOG_CTL
  127. # define WDOG_CTL WDOGA_CTL
  128. #endif
  129. ENTRY(_real_start)
  130. /* Enable nested interrupts */
  131. [--sp] = reti;
  132. /* watchdog off for now */
  133. p0.l = lo(WDOG_CTL);
  134. p0.h = hi(WDOG_CTL);
  135. r0 = 0xAD6(z);
  136. w[p0] = r0;
  137. ssync;
  138. /* Zero out the bss region
  139. * Note: this will fail if bss is 0 bytes ...
  140. */
  141. r0 = 0 (z);
  142. r1.l = ___bss_start;
  143. r1.h = ___bss_start;
  144. r2.l = ___bss_stop;
  145. r2.h = ___bss_stop;
  146. r2 = r2 - r1;
  147. r2 >>= 2;
  148. p1 = r1;
  149. p2 = r2;
  150. lsetup (.L_clear_bss, .L_clear_bss) lc0 = p2;
  151. .L_clear_bss:
  152. [p1++] = r0;
  153. /* In case there is a NULL pointer reference,
  154. * zero out region before stext
  155. */
  156. p1 = r0;
  157. r2.l = __stext;
  158. r2.h = __stext;
  159. r2 >>= 2;
  160. p2 = r2;
  161. lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2;
  162. .L_clear_zero:
  163. [p1++] = r0;
  164. /* Pass the u-boot arguments to the global value command line */
  165. R0 = R7;
  166. call _cmdline_init;
  167. /* Load the current thread pointer and stack */
  168. sp.l = _init_thread_union;
  169. sp.h = _init_thread_union;
  170. p1 = THREAD_SIZE (z);
  171. sp = sp + p1;
  172. usp = sp;
  173. fp = sp;
  174. jump.l _start_kernel;
  175. ENDPROC(_real_start)
  176. __FINIT