bmips_vec.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2011 by Kevin Cernekee (cernekee@gmail.com)
  7. *
  8. * Reset/NMI/re-entry vectors for BMIPS processors
  9. */
  10. #include <linux/init.h>
  11. #include <asm/asm.h>
  12. #include <asm/asmmacro.h>
  13. #include <asm/cacheops.h>
  14. #include <asm/regdef.h>
  15. #include <asm/mipsregs.h>
  16. #include <asm/stackframe.h>
  17. #include <asm/addrspace.h>
  18. #include <asm/hazards.h>
  19. #include <asm/bmips.h>
  20. .macro BARRIER
  21. .set mips32
  22. _ssnop
  23. _ssnop
  24. _ssnop
  25. .set mips0
  26. .endm
  27. /***********************************************************************
  28. * Alternate CPU1 startup vector for BMIPS4350
  29. *
  30. * On some systems the bootloader has already started CPU1 and configured
  31. * it to resume execution at 0x8000_0200 (!BEV IV vector) when it is
  32. * triggered by the SW1 interrupt. If that is the case we try to move
  33. * it to a more convenient place: BMIPS_WARM_RESTART_VEC @ 0x8000_0380.
  34. ***********************************************************************/
  35. LEAF(bmips_smp_movevec)
  36. la k0, 1f
  37. li k1, CKSEG1
  38. or k0, k1
  39. jr k0
  40. 1:
  41. /* clear IV, pending IPIs */
  42. mtc0 zero, CP0_CAUSE
  43. /* re-enable IRQs to wait for SW1 */
  44. li k0, ST0_IE | ST0_BEV | STATUSF_IP1
  45. mtc0 k0, CP0_STATUS
  46. /* set up CPU1 CBR; move BASE to 0xa000_0000 */
  47. li k0, 0xff400000
  48. mtc0 k0, $22, 6
  49. li k1, CKSEG1 | BMIPS_RELO_VECTOR_CONTROL_1
  50. or k0, k1
  51. li k1, 0xa0080000
  52. sw k1, 0(k0)
  53. /* wait here for SW1 interrupt from bmips_boot_secondary() */
  54. wait
  55. la k0, bmips_reset_nmi_vec
  56. li k1, CKSEG1
  57. or k0, k1
  58. jr k0
  59. END(bmips_smp_movevec)
  60. /***********************************************************************
  61. * Reset/NMI vector
  62. * For BMIPS processors that can relocate their exception vectors, this
  63. * entire function gets copied to 0x8000_0000.
  64. ***********************************************************************/
  65. NESTED(bmips_reset_nmi_vec, PT_SIZE, sp)
  66. .set push
  67. .set noat
  68. .align 4
  69. #ifdef CONFIG_SMP
  70. /* if the NMI bit is clear, assume this is a CPU1 reset instead */
  71. li k1, (1 << 19)
  72. mfc0 k0, CP0_STATUS
  73. and k0, k1
  74. beqz k0, bmips_smp_entry
  75. #if defined(CONFIG_CPU_BMIPS5000)
  76. /* if we're not on core 0, this must be the SMP boot signal */
  77. li k1, (3 << 25)
  78. mfc0 k0, $22
  79. and k0, k1
  80. bnez k0, bmips_smp_entry
  81. #endif
  82. #endif /* CONFIG_SMP */
  83. /* nope, it's just a regular NMI */
  84. SAVE_ALL
  85. move a0, sp
  86. /* clear EXL, ERL, BEV so that TLB refills still work */
  87. mfc0 k0, CP0_STATUS
  88. li k1, ST0_ERL | ST0_EXL | ST0_BEV | ST0_IE
  89. or k0, k1
  90. xor k0, k1
  91. mtc0 k0, CP0_STATUS
  92. BARRIER
  93. /* jump to the NMI handler function */
  94. la k0, nmi_handler
  95. jr k0
  96. RESTORE_ALL
  97. .set mips3
  98. eret
  99. /***********************************************************************
  100. * CPU1 reset vector (used for the initial boot only)
  101. * This is still part of bmips_reset_nmi_vec().
  102. ***********************************************************************/
  103. #ifdef CONFIG_SMP
  104. bmips_smp_entry:
  105. /* set up CP0 STATUS; enable FPU */
  106. li k0, 0x30000000
  107. mtc0 k0, CP0_STATUS
  108. BARRIER
  109. /* set local CP0 CONFIG to make kseg0 cacheable, write-back */
  110. mfc0 k0, CP0_CONFIG
  111. ori k0, 0x07
  112. xori k0, 0x04
  113. mtc0 k0, CP0_CONFIG
  114. #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
  115. /* initialize CPU1's local I-cache */
  116. li k0, 0x80000000
  117. li k1, 0x80010000
  118. mtc0 zero, $28
  119. mtc0 zero, $28, 1
  120. BARRIER
  121. 1: cache Index_Store_Tag_I, 0(k0)
  122. addiu k0, 16
  123. bne k0, k1, 1b
  124. #elif defined(CONFIG_CPU_BMIPS5000)
  125. /* set exception vector base */
  126. la k0, ebase
  127. lw k0, 0(k0)
  128. mtc0 k0, $15, 1
  129. BARRIER
  130. #endif
  131. /* jump back to kseg0 in case we need to remap the kseg1 area */
  132. la k0, 1f
  133. jr k0
  134. 1:
  135. la k0, bmips_enable_xks01
  136. jalr k0
  137. /* use temporary stack to set up upper memory TLB */
  138. li sp, BMIPS_WARM_RESTART_VEC
  139. la k0, plat_wired_tlb_setup
  140. jalr k0
  141. /* switch to permanent stack and continue booting */
  142. .global bmips_secondary_reentry
  143. bmips_secondary_reentry:
  144. la k0, bmips_smp_boot_sp
  145. lw sp, 0(k0)
  146. la k0, bmips_smp_boot_gp
  147. lw gp, 0(k0)
  148. la k0, start_secondary
  149. jr k0
  150. #endif /* CONFIG_SMP */
  151. .align 4
  152. .global bmips_reset_nmi_vec_end
  153. bmips_reset_nmi_vec_end:
  154. END(bmips_reset_nmi_vec)
  155. .set pop
  156. .previous
  157. /***********************************************************************
  158. * CPU1 warm restart vector (used for second and subsequent boots).
  159. * Also used for S2 standby recovery (PM).
  160. * This entire function gets copied to (BMIPS_WARM_RESTART_VEC)
  161. ***********************************************************************/
  162. LEAF(bmips_smp_int_vec)
  163. .align 4
  164. mfc0 k0, CP0_STATUS
  165. ori k0, 0x01
  166. xori k0, 0x01
  167. mtc0 k0, CP0_STATUS
  168. eret
  169. .align 4
  170. .global bmips_smp_int_vec_end
  171. bmips_smp_int_vec_end:
  172. END(bmips_smp_int_vec)
  173. /***********************************************************************
  174. * XKS01 support
  175. * Certain CPUs support extending kseg0 to 1024MB.
  176. ***********************************************************************/
  177. LEAF(bmips_enable_xks01)
  178. #if defined(CONFIG_XKS01)
  179. #if defined(CONFIG_CPU_BMIPS4380)
  180. mfc0 t0, $22, 3
  181. li t1, 0x1ff0
  182. li t2, (1 << 12) | (1 << 9)
  183. or t0, t1
  184. xor t0, t1
  185. or t0, t2
  186. mtc0 t0, $22, 3
  187. BARRIER
  188. #elif defined(CONFIG_CPU_BMIPS5000)
  189. mfc0 t0, $22, 5
  190. li t1, 0x01ff
  191. li t2, (1 << 8) | (1 << 5)
  192. or t0, t1
  193. xor t0, t1
  194. or t0, t2
  195. mtc0 t0, $22, 5
  196. BARRIER
  197. #else
  198. #error Missing XKS01 setup
  199. #endif
  200. #endif /* defined(CONFIG_XKS01) */
  201. jr ra
  202. END(bmips_enable_xks01)
  203. .previous