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) 2005-2008 Cavium Networks, Inc
8 #ifndef __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H
9 #define __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H
11 #define CP0_CVMCTL_REG $9, 7
12 #define CP0_CVMMEMCTL_REG $11,7
13 #define CP0_PRID_REG $15, 0
14 #define CP0_DCACHE_ERR_REG $27, 1
15 #define CP0_PRID_OCTEON_PASS1 0x000d0000
16 #define CP0_PRID_OCTEON_CN30XX 0x000d0200
18 .macro kernel_entry_setup
19 # Registers set by bootloader:
20 # (only 32 bits set by bootloader, all addresses are physical
21 # addresses, and need to have the appropriate memory region set
24 # a1 = argv (kseg0 compat addr)
25 # a2 = 1 if init core, zero otherwise
26 # a3 = address of boot descriptor block
29 # Read the cavium mem control register
30 dmfc0 v0
, CP0_CVMMEMCTL_REG
31 # Clear the lower 6 bits, the CVMSEG size
33 ori v0
, CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
34 dmtc0 v0
, CP0_CVMMEMCTL_REG
# Write the cavium mem control register
35 dmfc0 v0
, CP0_CVMCTL_REG
# Read the cavium control register
36 # Disable unaligned load/store support but leave HW fixup enabled
37 # Needed for octeon specific memcpy
40 # First clear off CvmCtl[IPPCI] bit and move the performance
41 # counters interrupt to IRQ 6
48 xor t1
, t1
, 0x9000 # 63-P1
51 xor t1
, t1
, 0x9008 # 63-P2
54 xor t1
, t1
, 0x9100 # 68-P1
57 xor t1
, t1
, 0x9200 # 66-PX
58 bnez t1
, 5f
# Skip WAR for others.
60 slti t1
, t1
, 2 # 66-P1.2 and later good.
63 4: # core-16057 work around
64 or v0
, v0
, 0x2000 # Set IPREF bit.
66 5: # No core-16057 work around
67 # Write the cavium control register
68 dmtc0 v0
, CP0_CVMCTL_REG
70 # Flush dcache after config change
72 # Zero all of CVMSEG to make sure parity is correct
73 dli v0
, CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
82 # OCTEON II or better have bit 15 set. Clear the error bits.
85 bge t1
, v0
, 1f
# OCTEON III has no DCACHE_ERR_REG COP0
87 dmtc0 v0
, CP0_DCACHE_ERR_REG
91 # Jump the master to kernel_entry
92 bne a2
, zero
, octeon_main_processor
98 # All cores other than the master need to wait here for SMP bootstrap
102 octeon_spin_wait_boot
:
103 #ifdef CONFIG_RELOCATABLE
104 PTR_LA t0
, octeon_processor_relocated_kernel_entry
112 #endif /* CONFIG_RELOCATABLE */
114 # This is the variable where the next core to boot is stored
115 PTR_LA t0
, octeon_processor_boot
116 # Get the core id of the next to be booted
118 # Keep looping if it isn't me
119 bne t1, v0, octeon_spin_wait_boot
121 # Get my GP from the global variable
122 PTR_LA t0, octeon_processor_gp
124 # Get my SP from the global variable
125 PTR_LA t0, octeon_processor_sp
127 # Set the SP global variable to zero so the master knows we've started
135 # Jump to the normal Linux SMP entry point
138 #else /* CONFIG_SMP */
141 # Someone tried to boot SMP with a non SMP kernel. All extra cores
146 b octeon_wait_forever
149 #endif /* CONFIG_SMP */
150 octeon_main_processor
:
155 * Do SMP slave processor setup necessary before we can safely execute C code.
157 .macro smp_slave_setup
160 #endif /* __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H */