]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h
21732c3066356da63dd693ef6743aed44a58a7ba
[karo-tx-linux.git] / arch / mips / include / asm / mach-cavium-octeon / kernel-entry-init.h
1 /*
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
4  * for more details.
5  *
6  * Copyright (C) 2005-2008 Cavium Networks, Inc
7  */
8 #ifndef __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H
9 #define __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H
10
11
12 #define CP0_CYCLE_COUNTER $9, 6
13 #define CP0_CVMCTL_REG $9, 7
14 #define CP0_CVMMEMCTL_REG $11,7
15 #define CP0_PRID_REG $15, 0
16 #define CP0_PRID_OCTEON_PASS1 0x000d0000
17 #define CP0_PRID_OCTEON_CN30XX 0x000d0200
18
19 .macro  kernel_entry_setup
20         # Registers set by bootloader:
21         # (only 32 bits set by bootloader, all addresses are physical
22         # addresses, and need to have the appropriate memory region set
23         # by the kernel
24         # a0 = argc
25         # a1 = argv (kseg0 compat addr)
26         # a2 = 1 if init core, zero otherwise
27         # a3 = address of boot descriptor block
28         .set push
29         .set arch=octeon
30         # Read the cavium mem control register
31         dmfc0   v0, CP0_CVMMEMCTL_REG
32         # Clear the lower 6 bits, the CVMSEG size
33         dins    v0, $0, 0, 6
34         ori     v0, CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
35         dmtc0   v0, CP0_CVMMEMCTL_REG   # Write the cavium mem control register
36         dmfc0   v0, CP0_CVMCTL_REG      # Read the cavium control register
37         # Disable unaligned load/store support but leave HW fixup enabled
38         # Needed for octeon specific memcpy
39         or  v0, v0, 0x5001
40         xor v0, v0, 0x1001
41         # Read the processor ID register
42         mfc0 v1, CP0_PRID_REG
43         # Disable instruction prefetching (Octeon Pass1 errata)
44         or  v0, v0, 0x2000
45         # Skip reenable of prefetching for Octeon Pass1
46         beq v1, CP0_PRID_OCTEON_PASS1, skip
47         nop
48         # Reenable instruction prefetching, not on Pass1
49         xor v0, v0, 0x2000
50         # Strip off pass number off of processor id
51         srl v1, 8
52         sll v1, 8
53         # CN30XX needs some extra stuff turned off for better performance
54         bne v1, CP0_PRID_OCTEON_CN30XX, skip
55         nop
56         # CN30XX Use random Icache replacement
57         or  v0, v0, 0x400
58         # CN30XX Disable instruction prefetching
59         or  v0, v0, 0x2000
60 skip:
61         # First clear off CvmCtl[IPPCI] bit and move the performance
62         # counters interrupt to IRQ 6
63         li      v1, ~(7 << 7)
64         and     v0, v0, v1
65         ori     v0, v0, (6 << 7)
66
67         mfc0    v1, CP0_PRID_REG
68         and     t1, v1, 0xfff8
69         xor     t1, t1, 0x9000          # 63-P1
70         beqz    t1, 4f
71         and     t1, v1, 0xfff8
72         xor     t1, t1, 0x9008          # 63-P2
73         beqz    t1, 4f
74         and     t1, v1, 0xfff8
75         xor     t1, t1, 0x9100          # 68-P1
76         beqz    t1, 4f
77         and     t1, v1, 0xff00
78         xor     t1, t1, 0x9200          # 66-PX
79         bnez    t1, 5f                  # Skip WAR for others.
80         and     t1, v1, 0x00ff
81         slti    t1, t1, 2               # 66-P1.2 and later good.
82         beqz    t1, 5f
83
84 4:      # core-16057 work around
85         or      v0, v0, 0x2000          # Set IPREF bit.
86
87 5:      # No core-16057 work around
88         # Write the cavium control register
89         dmtc0   v0, CP0_CVMCTL_REG
90         sync
91         # Flush dcache after config change
92         cache   9, 0($0)
93         # Get my core id
94         rdhwr   v0, $0
95         # Jump the master to kernel_entry
96         bne     a2, zero, octeon_main_processor
97         nop
98
99 #ifdef CONFIG_SMP
100
101         #
102         # All cores other than the master need to wait here for SMP bootstrap
103         # to begin
104         #
105
106         # This is the variable where the next core to boot os stored
107         PTR_LA  t0, octeon_processor_boot
108 octeon_spin_wait_boot:
109         # Get the core id of the next to be booted
110         LONG_L  t1, (t0)
111         # Keep looping if it isn't me
112         bne t1, v0, octeon_spin_wait_boot
113         nop
114         # Get my GP from the global variable
115         PTR_LA  t0, octeon_processor_gp
116         LONG_L  gp, (t0)
117         # Get my SP from the global variable
118         PTR_LA  t0, octeon_processor_sp
119         LONG_L  sp, (t0)
120         # Set the SP global variable to zero so the master knows we've started
121         LONG_S  zero, (t0)
122 #ifdef __OCTEON__
123         syncw
124         syncw
125 #else
126         sync
127 #endif
128         # Jump to the normal Linux SMP entry point
129         j   smp_bootstrap
130         nop
131 #else /* CONFIG_SMP */
132
133         #
134         # Someone tried to boot SMP with a non SMP kernel. All extra cores
135         # will halt here.
136         #
137 octeon_wait_forever:
138         wait
139         b   octeon_wait_forever
140         nop
141
142 #endif /* CONFIG_SMP */
143 octeon_main_processor:
144         .set pop
145 .endm
146
147 /*
148  * Do SMP slave processor setup necessary before we can savely execute C code.
149  */
150         .macro  smp_slave_setup
151         .endm
152
153 #endif /* __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H */