bmips_vec.S 5.4 KB

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