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
11 #include <linux/init.h>
14 #include <asm/asmmacro.h>
15 #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>
33 /***********************************************************************
34 * Alternate CPU1 startup vector for BMIPS4350
36 * On some systems the bootloader has already started CPU1 and configured
37 * it to resume execution at 0x8000_0200 (!BEV IV vector) when it is
38 * triggered by the SW1 interrupt. If that is the case we try to move
39 * it to a more convenient place: BMIPS_WARM_RESTART_VEC @ 0x8000_0380.
40 ***********************************************************************/
42 LEAF(bmips_smp_movevec)
49 /* clear IV, pending IPIs */
52 /* re-enable IRQs to wait for SW1 */
53 li k0, ST0_IE | ST0_BEV | STATUSF_IP1
56 /* set up CPU1 CBR; move BASE to 0xa000_0000 */
59 li k1, CKSEG1 | BMIPS_RELO_VECTOR_CONTROL_1
64 /* wait here for SW1 interrupt from bmips_boot_secondary() */
67 la k0, bmips_reset_nmi_vec
71 END(bmips_smp_movevec)
73 /***********************************************************************
75 * For BMIPS processors that can relocate their exception vectors, this
76 * entire function gets copied to 0x8000_0000.
77 ***********************************************************************/
79 NESTED(bmips_reset_nmi_vec, PT_SIZE, sp)
85 /* if the NMI bit is clear, assume this is a CPU1 reset instead */
89 beqz k0, bmips_smp_entry
91 #if defined(CONFIG_CPU_BMIPS5000)
92 /* if we're not on core 0, this must be the SMP boot signal */
96 bnez k0, bmips_smp_entry
98 #endif /* CONFIG_SMP */
100 /* nope, it's just a regular NMI */
104 /* clear EXL, ERL, BEV so that TLB refills still work */
106 li k1, ST0_ERL | ST0_EXL | ST0_BEV | ST0_IE
112 /* jump to the NMI handler function */
120 /***********************************************************************
121 * CPU1 reset vector (used for the initial boot only)
122 * This is still part of bmips_reset_nmi_vec().
123 ***********************************************************************/
129 /* set up CP0 STATUS; enable FPU */
134 /* set local CP0 CONFIG to make kseg0 cacheable, write-back */
140 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
141 /* initialize CPU1's local I-cache */
148 1: cache Index_Store_Tag_I, 0(k0)
151 #elif defined(CONFIG_CPU_BMIPS5000)
152 /* set exception vector base */
159 /* jump back to kseg0 in case we need to remap the kseg1 area */
163 la k0, bmips_enable_xks01
166 /* use temporary stack to set up upper memory TLB */
167 li sp, BMIPS_WARM_RESTART_VEC
168 la k0, plat_wired_tlb_setup
171 /* switch to permanent stack and continue booting */
173 .global bmips_secondary_reentry
174 bmips_secondary_reentry:
175 la k0, bmips_smp_boot_sp
177 la k0, bmips_smp_boot_gp
179 la k0, start_secondary
182 #endif /* CONFIG_SMP */
185 .global bmips_reset_nmi_vec_end
186 bmips_reset_nmi_vec_end:
188 END(bmips_reset_nmi_vec)
193 /***********************************************************************
194 * CPU1 warm restart vector (used for second and subsequent boots).
195 * Also used for S2 standby recovery (PM).
196 * This entire function gets copied to (BMIPS_WARM_RESTART_VEC)
197 ***********************************************************************/
199 LEAF(bmips_smp_int_vec)
209 .global bmips_smp_int_vec_end
210 bmips_smp_int_vec_end:
212 END(bmips_smp_int_vec)
214 /***********************************************************************
216 * Certain CPUs support extending kseg0 to 1024MB.
217 ***********************************************************************/
221 LEAF(bmips_enable_xks01)
223 #if defined(CONFIG_XKS01)
225 #if defined(CONFIG_CPU_BMIPS4380)
228 li t2, (1 << 12) | (1 << 9)
234 #elif defined(CONFIG_CPU_BMIPS5000)
237 li t2, (1 << 8) | (1 << 5)
245 #error Missing XKS01 setup
249 #endif /* defined(CONFIG_XKS01) */
253 END(bmips_enable_xks01)