1 /* MN10300 CPU core caching routines, using direct tag flushing
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #include <linux/sys.h>
13 #include <linux/linkage.h>
16 #include <asm/cache.h>
17 #include <asm/irqflags.h>
22 .globl mn10300_dcache_flush
23 .globl mn10300_dcache_flush_page
24 .globl mn10300_dcache_flush_range
25 .globl mn10300_dcache_flush_range2
26 .globl mn10300_dcache_flush_inv
27 .globl mn10300_dcache_flush_inv_page
28 .globl mn10300_dcache_flush_inv_range
29 .globl mn10300_dcache_flush_inv_range2
31 mn10300_dcache_flush = mn10300_local_dcache_flush
32 mn10300_dcache_flush_page = mn10300_local_dcache_flush_page
33 mn10300_dcache_flush_range = mn10300_local_dcache_flush_range
34 mn10300_dcache_flush_range2 = mn10300_local_dcache_flush_range2
35 mn10300_dcache_flush_inv = mn10300_local_dcache_flush_inv
36 mn10300_dcache_flush_inv_page = mn10300_local_dcache_flush_inv_page
37 mn10300_dcache_flush_inv_range = mn10300_local_dcache_flush_inv_range
38 mn10300_dcache_flush_inv_range2 = mn10300_local_dcache_flush_inv_range2
40 #endif /* !CONFIG_SMP */
42 ###############################################################################
44 # void mn10300_local_dcache_flush(void)
45 # Flush the entire data cache back to RAM
47 ###############################################################################
49 .globl mn10300_local_dcache_flush
50 .type mn10300_local_dcache_flush,@function
51 mn10300_local_dcache_flush:
54 beq mn10300_local_dcache_flush_end
56 # read the addresses tagged in the cache's tag RAM and attempt to flush
57 # those addresses specifically
58 # - we rely on the hardware to filter out invalid tag entry addresses
59 mov DCACHE_TAG(0,0),a0 # dcache tag RAM access address
60 mov DCACHE_PURGE(0,0),a1 # dcache purge request address
61 mov L1_CACHE_NWAYS*L1_CACHE_NENTRIES,d1 # total number of entries
63 mn10300_local_dcache_flush_loop:
65 and L1_CACHE_TAG_MASK,d0
66 or L1_CACHE_TAG_VALID,d0 # retain valid entries in the
68 mov d0,(a1) # conditional purge
73 bne mn10300_local_dcache_flush_loop
75 mn10300_local_dcache_flush_end:
77 .size mn10300_local_dcache_flush,.-mn10300_local_dcache_flush
79 ###############################################################################
81 # void mn10300_local_dcache_flush_page(unsigned long start)
82 # void mn10300_local_dcache_flush_range(unsigned long start, unsigned long end)
83 # void mn10300_local_dcache_flush_range2(unsigned long start, unsigned long size)
84 # Flush a range of addresses on a page in the dcache
86 ###############################################################################
88 .globl mn10300_local_dcache_flush_page
89 .globl mn10300_local_dcache_flush_range
90 .globl mn10300_local_dcache_flush_range2
91 .type mn10300_local_dcache_flush_page,@function
92 .type mn10300_local_dcache_flush_range,@function
93 .type mn10300_local_dcache_flush_range2,@function
94 mn10300_local_dcache_flush_page:
97 mn10300_local_dcache_flush_range2:
99 mn10300_local_dcache_flush_range:
104 beq mn10300_local_dcache_flush_range_end
107 cmp MN10300_DCACHE_FLUSH_BORDER,a0
111 bra mn10300_local_dcache_flush
114 # round start addr down
115 and L1_CACHE_TAG_MASK,d0
118 add L1_CACHE_BYTES,d1 # round end addr up
119 and L1_CACHE_TAG_MASK,d1
121 # write a request to flush all instances of an address from the cache
122 mov DCACHE_PURGE(0,0),a0
124 and L1_CACHE_TAG_ENTRY,d0
125 add d0,a0 # starting dcache purge control
129 lsr L1_CACHE_SHIFT,d1 # total number of entries to
132 or L1_CACHE_TAG_VALID,a1 # retain valid entries in the
135 mn10300_local_dcache_flush_range_loop:
136 mov a1,(L1_CACHE_WAYDISP*0,a0) # conditionally purge this line
139 add L1_CACHE_BYTES,a0
140 add L1_CACHE_BYTES,a1
141 and ~L1_CACHE_WAYDISP,a0 # make sure way stay on way 0
143 bne mn10300_local_dcache_flush_range_loop
145 mn10300_local_dcache_flush_range_end:
148 .size mn10300_local_dcache_flush_page,.-mn10300_local_dcache_flush_page
149 .size mn10300_local_dcache_flush_range,.-mn10300_local_dcache_flush_range
150 .size mn10300_local_dcache_flush_range2,.-mn10300_local_dcache_flush_range2
152 ###############################################################################
154 # void mn10300_local_dcache_flush_inv(void)
155 # Flush the entire data cache and invalidate all entries
157 ###############################################################################
159 .globl mn10300_local_dcache_flush_inv
160 .type mn10300_local_dcache_flush_inv,@function
161 mn10300_local_dcache_flush_inv:
164 beq mn10300_local_dcache_flush_inv_end
166 mov L1_CACHE_NENTRIES,d1
169 mn10300_local_dcache_flush_inv_loop:
170 mov (DCACHE_PURGE_WAY0(0),a1),d0 # unconditional purge
171 mov (DCACHE_PURGE_WAY1(0),a1),d0 # unconditional purge
172 mov (DCACHE_PURGE_WAY2(0),a1),d0 # unconditional purge
173 mov (DCACHE_PURGE_WAY3(0),a1),d0 # unconditional purge
175 add L1_CACHE_BYTES,a1
177 bne mn10300_local_dcache_flush_inv_loop
179 mn10300_local_dcache_flush_inv_end:
181 .size mn10300_local_dcache_flush_inv,.-mn10300_local_dcache_flush_inv
183 ###############################################################################
185 # void mn10300_local_dcache_flush_inv_page(unsigned long start)
186 # void mn10300_local_dcache_flush_inv_range(unsigned long start, unsigned long end)
187 # void mn10300_local_dcache_flush_inv_range2(unsigned long start, unsigned long size)
188 # Flush and invalidate a range of addresses on a page in the dcache
190 ###############################################################################
192 .globl mn10300_local_dcache_flush_inv_page
193 .globl mn10300_local_dcache_flush_inv_range
194 .globl mn10300_local_dcache_flush_inv_range2
195 .type mn10300_local_dcache_flush_inv_page,@function
196 .type mn10300_local_dcache_flush_inv_range,@function
197 .type mn10300_local_dcache_flush_inv_range2,@function
198 mn10300_local_dcache_flush_inv_page:
199 and ~(PAGE_SIZE-1),d0
201 mn10300_local_dcache_flush_inv_range2:
203 mn10300_local_dcache_flush_inv_range:
208 beq mn10300_local_dcache_flush_inv_range_end
211 cmp MN10300_DCACHE_FLUSH_INV_BORDER,a0
215 bra mn10300_local_dcache_flush_inv
218 and L1_CACHE_TAG_MASK,d0 # round start addr down
221 add L1_CACHE_BYTES,d1 # round end addr up
222 and L1_CACHE_TAG_MASK,d1
224 # write a request to flush and invalidate all instances of an address
226 mov DCACHE_PURGE(0,0),a0
228 and L1_CACHE_TAG_ENTRY,d0
229 add d0,a0 # starting dcache purge control
233 lsr L1_CACHE_SHIFT,d1 # total number of entries to
236 mn10300_local_dcache_flush_inv_range_loop:
237 mov a1,(L1_CACHE_WAYDISP*0,a0) # conditionally purge this line
240 add L1_CACHE_BYTES,a0
241 add L1_CACHE_BYTES,a1
242 and ~L1_CACHE_WAYDISP,a0 # make sure way stay on way 0
244 bne mn10300_local_dcache_flush_inv_range_loop
246 mn10300_local_dcache_flush_inv_range_end:
248 .size mn10300_local_dcache_flush_inv_page,.-mn10300_local_dcache_flush_inv_page
249 .size mn10300_local_dcache_flush_inv_range,.-mn10300_local_dcache_flush_inv_range
250 .size mn10300_local_dcache_flush_inv_range2,.-mn10300_local_dcache_flush_inv_range2