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
6 * Copyright (C) 2011 by Kevin Cernekee (cernekee@gmail.com)
8 * Reset/NMI/re-entry vectors for BMIPS processors
13 #include <asm/asmmacro.h>
14 #include <asm/cacheops.h>
16 #include <asm/regdef.h>
17 #include <asm/mipsregs.h>
18 #include <asm/stackframe.h>
19 #include <asm/addrspace.h>
20 #include <asm/hazards.h>
21 #include <asm/bmips.h>
31 /***********************************************************************
32 * Alternate CPU1 startup vector for BMIPS4350
34 * On some systems the bootloader has already started CPU1 and configured
35 * it to resume execution at 0x8000_0200 (!BEV IV vector) when it is
36 * triggered by the SW1 interrupt. If that is the case we try to move
37 * it to a more convenient place: BMIPS_WARM_RESTART_VEC @ 0x8000_0380.
38 ***********************************************************************/
40 LEAF(bmips_smp_movevec)
47 /* clear IV, pending IPIs */
50 /* re-enable IRQs to wait for SW1 */
51 li k0, ST0_IE | ST0_BEV | STATUSF_IP1
54 /* set up CPU1 CBR; move BASE to 0xa000_0000 */
57 /* set up relocation vector address based on thread ID */
61 or k1, CKSEG1 | BMIPS_RELO_VECTOR_CONTROL_0
66 /* wait here for SW1 interrupt from bmips_boot_secondary() */
69 la k0, bmips_reset_nmi_vec
73 END(bmips_smp_movevec)
75 /***********************************************************************
77 * For BMIPS processors that can relocate their exception vectors, this
78 * entire function gets copied to 0x8000_0000.
79 ***********************************************************************/
81 NESTED(bmips_reset_nmi_vec, PT_SIZE, sp)
87 /* if the NMI bit is clear, assume this is a CPU1 reset instead */
91 beqz k0, bmips_smp_entry
93 #if defined(CONFIG_CPU_BMIPS5000)
95 li k1, PRID_IMP_BMIPS5000
99 /* if we're not on core 0, this must be the SMP boot signal */
103 bnez k0, bmips_smp_entry
105 #endif /* CONFIG_CPU_BMIPS5000 */
106 #endif /* CONFIG_SMP */
108 /* nope, it's just a regular NMI */
112 /* clear EXL, ERL, BEV so that TLB refills still work */
114 li k1, ST0_ERL | ST0_EXL | ST0_BEV | ST0_IE
120 /* jump to the NMI handler function */
128 /***********************************************************************
129 * CPU1 reset vector (used for the initial boot only)
130 * This is still part of bmips_reset_nmi_vec().
131 ***********************************************************************/
137 /* set up CP0 STATUS; enable FPU */
142 /* set local CP0 CONFIG to make kseg0 cacheable, write-back */
150 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
151 li k1, PRID_IMP_BMIPS43XX
154 /* initialize CPU1's local I-cache */
161 1: cache Index_Store_Tag_I, 0(k0)
167 #endif /* CONFIG_CPU_BMIPS4350 || CONFIG_CPU_BMIPS4380 */
168 #if defined(CONFIG_CPU_BMIPS5000)
169 /* set exception vector base */
170 li k1, PRID_IMP_BMIPS5000
177 #endif /* CONFIG_CPU_BMIPS5000 */
179 /* jump back to kseg0 in case we need to remap the kseg1 area */
183 la k0, bmips_enable_xks01
186 /* use temporary stack to set up upper memory TLB */
187 li sp, BMIPS_WARM_RESTART_VEC
188 la k0, plat_wired_tlb_setup
191 /* switch to permanent stack and continue booting */
193 .global bmips_secondary_reentry
194 bmips_secondary_reentry:
195 la k0, bmips_smp_boot_sp
197 la k0, bmips_smp_boot_gp
199 la k0, start_secondary
202 #endif /* CONFIG_SMP */
205 .global bmips_reset_nmi_vec_end
206 bmips_reset_nmi_vec_end:
208 END(bmips_reset_nmi_vec)
213 /***********************************************************************
214 * CPU1 warm restart vector (used for second and subsequent boots).
215 * Also used for S2 standby recovery (PM).
216 * This entire function gets copied to (BMIPS_WARM_RESTART_VEC)
217 ***********************************************************************/
219 LEAF(bmips_smp_int_vec)
229 .global bmips_smp_int_vec_end
230 bmips_smp_int_vec_end:
232 END(bmips_smp_int_vec)
234 /***********************************************************************
236 * Certain CPUs support extending kseg0 to 1024MB.
237 ***********************************************************************/
239 LEAF(bmips_enable_xks01)
241 #if defined(CONFIG_XKS01)
244 #if defined(CONFIG_CPU_BMIPS4380)
245 li t1, PRID_IMP_BMIPS43XX
249 addiu t1, t0, -PRID_REV_BMIPS4380_HI
251 addiu t0, -PRID_REV_BMIPS4380_LO
256 li t2, (1 << 12) | (1 << 9)
264 #endif /* CONFIG_CPU_BMIPS4380 */
265 #if defined(CONFIG_CPU_BMIPS5000)
266 li t1, PRID_IMP_BMIPS5000
271 li t2, (1 << 8) | (1 << 5)
277 #endif /* CONFIG_CPU_BMIPS5000 */
279 #endif /* defined(CONFIG_XKS01) */
283 END(bmips_enable_xks01)