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 */
93 #if defined(CONFIG_CPU_BMIPS5000)
95 li k1, PRID_IMP_BMIPS5000
96 /* mask with PRID_IMP_BMIPS5000 to cover both variants */
97 andi k0, PRID_IMP_BMIPS5000
100 /* if we're not on core 0, this must be the SMP boot signal */
104 bnez k0, bmips_smp_entry
106 #endif /* CONFIG_CPU_BMIPS5000 */
107 #endif /* CONFIG_SMP */
109 /* nope, it's just a regular NMI */
113 /* clear EXL, ERL, BEV so that TLB refills still work */
115 li k1, ST0_ERL | ST0_EXL | ST0_BEV | ST0_IE
121 /* jump to the NMI handler function */
132 #if defined(CONFIG_CPU_BMIPS5000)
135 li k1, PRID_IMP_BMIPS5200
136 bne k0, k1, bmips_smp_entry
138 /* if running on TP 1, jump to bmips_smp_entry */
142 bnez k1, bmips_smp_entry
146 * running on TP0, can not be core 0 (the boot core).
147 * Check for soft reset. Indicates a warm boot
152 beqz k0, bmips_smp_entry
156 * Cache init is only done on TP0
158 la k0, bmips_5xxx_init
166 /***********************************************************************
167 * CPU1 reset vector (used for the initial boot only)
168 * This is still part of bmips_reset_nmi_vec().
169 ***********************************************************************/
173 /* set up CP0 STATUS; enable FPU */
178 /* set local CP0 CONFIG to make kseg0 cacheable, write-back */
186 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
187 li k1, PRID_IMP_BMIPS43XX
190 /* initialize CPU1's local I-cache */
197 1: cache Index_Store_Tag_I, 0(k0)
203 #endif /* CONFIG_CPU_BMIPS4350 || CONFIG_CPU_BMIPS4380 */
204 #if defined(CONFIG_CPU_BMIPS5000)
205 /* mask with PRID_IMP_BMIPS5000 to cover both variants */
206 li k1, PRID_IMP_BMIPS5000
207 andi k0, PRID_IMP_BMIPS5000
210 /* set exception vector base */
215 #endif /* CONFIG_CPU_BMIPS5000 */
217 /* jump back to kseg0 in case we need to remap the kseg1 area */
221 la k0, bmips_enable_xks01
224 /* use temporary stack to set up upper memory TLB */
225 li sp, BMIPS_WARM_RESTART_VEC
226 la k0, plat_wired_tlb_setup
229 /* switch to permanent stack and continue booting */
231 .global bmips_secondary_reentry
232 bmips_secondary_reentry:
233 la k0, bmips_smp_boot_sp
235 la k0, bmips_smp_boot_gp
237 la k0, start_secondary
240 #endif /* CONFIG_SMP */
243 .global bmips_reset_nmi_vec_end
244 bmips_reset_nmi_vec_end:
246 END(bmips_reset_nmi_vec)
250 /***********************************************************************
251 * CPU1 warm restart vector (used for second and subsequent boots).
252 * Also used for S2 standby recovery (PM).
253 * This entire function gets copied to (BMIPS_WARM_RESTART_VEC)
254 ***********************************************************************/
256 LEAF(bmips_smp_int_vec)
266 .global bmips_smp_int_vec_end
267 bmips_smp_int_vec_end:
269 END(bmips_smp_int_vec)
271 /***********************************************************************
273 * Certain CPUs support extending kseg0 to 1024MB.
274 ***********************************************************************/
276 LEAF(bmips_enable_xks01)
278 #if defined(CONFIG_XKS01)
281 #if defined(CONFIG_CPU_BMIPS4380)
282 li t1, PRID_IMP_BMIPS43XX
286 addiu t1, t0, -PRID_REV_BMIPS4380_HI
288 addiu t0, -PRID_REV_BMIPS4380_LO
293 li t2, (1 << 12) | (1 << 9)
301 #endif /* CONFIG_CPU_BMIPS4380 */
302 #if defined(CONFIG_CPU_BMIPS5000)
303 li t1, PRID_IMP_BMIPS5000
304 /* mask with PRID_IMP_BMIPS5000 to cover both variants */
305 andi t2, PRID_IMP_BMIPS5000
310 li t2, (1 << 8) | (1 << 5)
316 #endif /* CONFIG_CPU_BMIPS5000 */
318 #endif /* defined(CONFIG_XKS01) */
322 END(bmips_enable_xks01)