1 /* *********************************************************************
2 * P5064 Board Support Package
4 * L1 Cache initialization File: rm5200_l1cache.S
6 * This module contains code to initialize the L1 cache.
8 * Note: all the routines in this module rely on registers only,
9 * since DRAM may not be active yet.
11 * Author: Mitch Lichtenberg (mpl@broadcom.com)
13 *********************************************************************
15 * Copyright 2000,2001,2002,2003
16 * Broadcom Corporation. All rights reserved.
18 * This software is furnished under license and may be used and
19 * copied only in accordance with the following terms and
20 * conditions. Subject to these conditions, you may download,
21 * copy, install, use, modify and distribute modified or unmodified
22 * copies of this software in source and/or binary form. No title
23 * or ownership is transferred hereby.
25 * 1) Any source code used, modified or distributed must reproduce
26 * and retain this copyright notice and list of conditions
27 * as they appear in the source file.
29 * 2) No right is granted to use any trade name, trademark, or
30 * logo of Broadcom Corporation. The "Broadcom Corporation"
31 * name may not be used to endorse or promote products derived
32 * from this software without the prior written permission of
33 * Broadcom Corporation.
35 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
36 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
37 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
39 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
40 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
41 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
42 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
43 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
44 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
45 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
46 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
47 * THE POSSIBILITY OF SUCH DAMAGE.
48 ********************************************************************* */
56 /* *********************************************************************
58 ********************************************************************* */
60 #define L1CACHE_NUMWAYS 4
61 #define L1CACHE_NUMIDX 256
62 #define L1CACHE_LINESIZE 32
63 #define L1CACHE_IDXHIGH (L1CACHE_LINESIZE*L1CACHE_NUMWAYS*L1CACHE_NUMIDX)
65 #define L1CACHEOP(cachename,op) ((cachename) | ((op) << 2))
67 #define L1C_OP_IDXINVAL 0
68 #define L1C_OP_IDXLOADTAG 1
69 #define L1C_OP_IDXSTORETAG 2
70 #define L1C_OP_IMPLRSVD 3
71 #define L1C_OP_HITINVAL 4
73 #define L1C_OP_HITWRITEBACK 6
74 #define L1C_OP_FETCHLOCK 7
83 /* *********************************************************************
84 * RM5200_L1CACHE_INIT()
86 * Initialize the L1 Cache tags to be "invalid"
96 ********************************************************************* */
99 #define FILLBASE 0x9fc00000 /* was K0BASE */
101 LEAF(rm5200_l1cache_init)
104 * Determine the cache sizes
109 /* work out primary i-cache size */
116 /* work out primary d-cache size */
124 * The caches may be in an indeterminate state,
125 * so we force good parity into them by doing an
126 * invalidate, load/fill, invalidate for each line.
129 /* disable all i/u and cache exceptions */
140 /* disable secondary cache and set zero tag */
151 * Assume bottom of ROM will generate good parity for the
152 * primary caches (max 32K)
156 * Initialise primary instruction cache.
161 addu a1,a0,icachesize # limit = base + icachesize
163 cache Index_Store_Tag_I,-4(a0) # clear tag
165 cache Fill_I,-4(a0) # fill data line
168 cache Index_Store_Tag_I,-4(a0) # BDSLOT: clear tag
172 * Initialise primary data cache.
173 * (for 2-way set caches, we do it in 3 passes).
176 /* 1: initialise dcache tags */
179 addu a1,a0,dcachesize # limit = base + dcachesize
182 cache Index_Store_Tag_D,-4(a0) # BDSLOT: clear tag
185 /* 2: fill dcache data */
188 addu a1,a0,dcachesize # limit = base + dcachesize
191 lw zero,-4(a0) # BDSLOT: fill line
194 /* 3: clear dcache tags */
197 addu a1,a0,dcachesize # limit = base + dcachesize
200 cache Index_Store_Tag_D,-4(a0) # BDSLOT: clear tag
208 END(rm5200_l1cache_init)
211 /* *********************************************************************
212 * RM5200_L1CACHE_INVAL_I()
214 * Invalidate the L1 ICache
224 ********************************************************************* */
227 LEAF(rm5200_l1cache_inval_i)
230 * Determine the ICache size
237 li icachesize,0x1000 /* t2 */
241 * Invalidate primary instruction cache.
245 addu t1,t0,icachesize # limit = base + icachesize
246 1: cache L1CACHEOP(L1C_I,L1C_OP_IDXINVAL),0(t0)
252 END(rm5200_l1cache_inval_i)
255 /* *********************************************************************
256 * RM5200_L1CACHE_FLUSH_D()
258 * Flush the entire L1 DCache (write dirty lines back to memory)
268 ********************************************************************* */
271 LEAF(rm5200_l1cache_flush_d)
274 * Determine the DCache size
281 li dcachesize,0x1000 /* t3 */
289 addu t1,t0,dcachesize # limit = base + icachesize
290 1: cache L1CACHEOP(L1C_D,L1C_OP_IDXINVAL),0(t0)
297 END(rm5200_l1cache_flush_d)
300 /* *********************************************************************
302 ********************************************************************* */