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)
212 /***********************************************************************
213 * CPU1 warm restart vector (used for second and subsequent boots).
214 * Also used for S2 standby recovery (PM).
215 * This entire function gets copied to (BMIPS_WARM_RESTART_VEC)
216 ***********************************************************************/
218 LEAF(bmips_smp_int_vec)
228 .global bmips_smp_int_vec_end
229 bmips_smp_int_vec_end:
231 END(bmips_smp_int_vec)
233 /***********************************************************************
235 * Certain CPUs support extending kseg0 to 1024MB.
236 ***********************************************************************/
238 LEAF(bmips_enable_xks01)
240 #if defined(CONFIG_XKS01)
243 #if defined(CONFIG_CPU_BMIPS4380)
244 li t1, PRID_IMP_BMIPS43XX
248 addiu t1, t0, -PRID_REV_BMIPS4380_HI
250 addiu t0, -PRID_REV_BMIPS4380_LO
255 li t2, (1 << 12) | (1 << 9)
263 #endif /* CONFIG_CPU_BMIPS4380 */
264 #if defined(CONFIG_CPU_BMIPS5000)
265 li t1, PRID_IMP_BMIPS5000
270 li t2, (1 << 8) | (1 << 5)
276 #endif /* CONFIG_CPU_BMIPS5000 */
278 #endif /* defined(CONFIG_XKS01) */
282 END(bmips_enable_xks01)