1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 Stefan Roese <sr@denx.de>
7 #include <asm-offsets.h>
8 #include <asm/cacheops.h>
9 #include <asm/regdef.h>
10 #include <asm/mipsregs.h>
11 #include <asm/addrspace.h>
13 #include <mach/octeon-model.h>
15 #define COP0_CVMCTL_REG $9,7 /* Cavium control */
16 #define COP0_CVMMEMCTL_REG $11,7 /* Cavium memory control */
17 #define COP0_PROC_ID_REG $15,0
23 /* Set LMEMSZ in CVMMEMCTL register */
24 dmfc0 a0, COP0_CVMMEMCTL_REG
26 mfc0 a4, COP0_PROC_ID_REG
27 li a5, OCTEON_CN63XX_PASS1_0 /* Octeon cn63xx pass1 chip id */
29 ori a0, 0x104 /* setup 4 lines of scratch */
30 ori a6, a5, 8 /* Octeon cn63xx pass2 chip id */
34 ins a0, a6, 11, 4 /* Set WBTHRESH=4 as per Core-14752 errata */
36 dmtc0 a0, COP0_CVMMEMCTL_REG
38 /* Set REPUN bit in CVMCTL register */
39 dmfc0 a0, COP0_CVMCTL_REG
40 ori a0, 1<<14 /* enable fixup of unaligned mem access */
41 dmtc0 a0, COP0_CVMCTL_REG
47 LEAF(mips_mach_early_init)
55 /* Get the actual address that we are running at */
57 dsubu t3, ra, a7 /* t3 now has reloc offset */
60 daddu t0, t1, t3 /* t0 now has actual address of _start */
62 /* Calculate end address of copy loop */
64 daddiu t2, t2, 0x4000 /* Increase size to include appended DTB */
66 ins t2, zero, 0, 7 /* Round up to cache line for memcpy */
68 /* Copy ourself to the L2 cache from flash, 32 bytes at a time */
86 * Return to start.S now running from TEXT_BASE, which points
87 * to DRAM address space, which effectively is L2 cache now.
88 * This speeds up the init process extremely, especially the
91 dsubu s0, s0, t3 /* Fixup return address with reloc offset */
92 jr.hb s0 /* Jump back with hazard barrier */
95 END(mips_mach_early_init)
100 * From Marvell original bootvector setup
103 /* Enable 64-bit addressing, set ERL (should already be set) */
106 /* Core-14345, clear L1 Dcache virtual tags if the core hit an NMI */
110 * Needed for Linux kernel booting, otherwise it hangs while
111 * zero'ing all of CVMSEG
113 dmfc0 a0, COP0_CVMMEMCTL_REG
115 ori a0, 0x104 /* setup 4 lines of scratch */
116 dmtc0 a0, COP0_CVMMEMCTL_REG
119 * Load parameters and entry point
121 PTR_LA t9, nmi_handler_para
130 /* Finally jump to entry point (start kernel etc) */
137 * Add here some space for the NMI parameters (entry point and args)
139 .globl nmi_handler_para
141 .dword 0 // entry-point