1 /* *********************************************************************
2 * RM7000 Board Support Package
4 * L2 Cache initialization File: rm7000_l2cache.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 ********************************************************************* */
55 /* *********************************************************************
57 ********************************************************************* */
59 #define L2CACHE_NUMWAYS 4
60 #define L2CACHE_NUMIDX 128 /* RM7000 has only 16K */
61 #define L2CACHE_LINESIZE 32
62 #define L2CACHE_IDXHIGH (L2CACHE_LINESIZE*L2CACHE_NUMWAYS*L2CACHE_NUMIDX)
64 #define L2CACHEOP(cachename,op) ((cachename) | ((op) << 2))
66 #define L2C_OP_IDXINVAL 0
67 #define L2C_OP_IDXLOADTAG 1
68 #define L2C_OP_IDXSTORETAG 2
69 #define L2C_OP_IMPLRSVD 3
70 #define L2C_OP_HITINVAL 4
72 #define L2C_OP_HITWRITEBACK 6
73 #define L2C_OP_FETCHLOCK 7
79 /* *********************************************************************
80 * RM7000_L2CACHE_INIT()
82 * Initialize the L1 Cache tags to be "invalid"
92 ********************************************************************* */
95 LEAF(rm7000_l2cache_init)
102 li t3,L2CACHE_IDXHIGH
105 1: cache L2CACHEOP(L2C,L2C_OP_IDXSTORETAG),0(t2)
106 addu t2,L2CACHE_LINESIZE
109 dmtc0 zero,C0_TAGLO,2
110 dmtc0 zero,C0_TAGHI,2
114 1: cache L2CACHEOP(L2C,L2C_OP_IDXSTORETAG),0(t2)
115 addu t2,L2CACHE_LINESIZE
125 END(rm7000_l2cache_init)
128 /* *********************************************************************
129 * RM7000_L2CACHE_INVAL_I()
131 * Invalidate the L1 ICache
141 ********************************************************************* */
144 LEAF(rm7000_l2cache_inval_i)
148 li t3,L2CACHE_IDXHIGH
151 1: cache L2CACHEOP(L2C,L2C_OP_IDXINVAL),0(t2)
152 addu t2,L2CACHE_LINESIZE
157 END(rm7000_l2cache_inval_i)
160 /* *********************************************************************
161 * RM7000_L2CACHE_FLUSH_D()
163 * Flush the entire L1 DCache (write dirty lines back to memory)
173 ********************************************************************* */
176 LEAF(rm7000_l2cache_flush)
179 li t3,L2CACHE_IDXHIGH
183 1: cache L2CACHEOP(L2C,L2C_OP_IDXINVAL),0(t2)
184 addu t2,L2CACHE_LINESIZE
189 END(rm7000_l2cache_flush)
192 /* *********************************************************************
194 ********************************************************************* */