1#include <config.h>
2#include <mpc86xx.h>
3
4#include <ppc_asm.tmpl>
5#include <ppc_defs.h>
6
7#include <asm/cache.h>
8#include <asm/mmu.h>
9
10#ifndef CACHE_LINE_SIZE
11# define CACHE_LINE_SIZE L1_CACHE_BYTES
12#endif
13
14
15#define LG_CACHE_LINE_SIZE 7
16
17#define LG_CACHE_LINE_SIZE 5
18
19#define LG_CACHE_LINE_SIZE 4
20
21#define LG_CACHE_LINE_SIZE 3
22#else
23
24#endif
25
26
27
28
29
30
31
32
33
34_GLOBAL(invalidate_l1_instruction_cache)
35
36 mfspr r3,HID0
37 ori r3,r3,HID0_ICFI
38 mtspr HID0,r3
39 isync
40 blr
41
42
43
44
45_GLOBAL(invalidate_l1_data_cache)
46 mfspr r3,HID0
47 ori r3,r3,HID0_DCFI
48 mtspr HID0,r3
49 isync
50 blr
51
52
53
54
55_GLOBAL(flush_dcache)
56 lis r3,0
57 lis r5,CACHE_LINE_SIZE
58flush:
59 cmp 0,1,r3,r5
60 bge done
61 lwz r5,0(r3)
62 lis r5,CACHE_LINE_SIZE
63 addi r3,r3,0x4
64 b flush
65done:
66 blr
67
68
69
70
71
72
73
74_GLOBAL(flush_icache_range)
75 li r5,CACHE_LINE_SIZE-1
76 andc r3,r3,r5
77 subf r4,r3,r4
78 add r4,r4,r5
79 srwi. r4,r4,LG_CACHE_LINE_SIZE
80 beqlr
81 mtctr r4
82 mr r6,r3
831: dcbst 0,r3
84 addi r3,r3,CACHE_LINE_SIZE
85 bdnz 1b
86 sync
87 mtctr r4
882: icbi 0,r6
89 addi r6,r6,CACHE_LINE_SIZE
90 bdnz 2b
91 sync
92 isync
93 blr
94
95
96
97
98
99
100
101_GLOBAL(clean_dcache_range)
102 li r5,CACHE_LINE_SIZE-1
103 andc r3,r3,r5
104 subf r4,r3,r4
105 add r4,r4,r5
106 srwi. r4,r4,LG_CACHE_LINE_SIZE
107 beqlr
108 mtctr r4
109
110 sync
1111: dcbst 0,r3
112 addi r3,r3,CACHE_LINE_SIZE
113 bdnz 1b
114 sync
115 blr
116
117
118
119
120
121
122
123
124_GLOBAL(__flush_page_to_ram)
125 rlwinm r3,r3,0,0,19
126 li r4,4096/CACHE_LINE_SIZE
127 mtctr r4
128 mr r6,r3
1290: dcbst 0,r3
130 addi r3,r3,CACHE_LINE_SIZE
131 bdnz 0b
132 sync
133 mtctr r4
1341: icbi 0,r6
135 addi r6,r6,CACHE_LINE_SIZE
136 bdnz 1b
137 sync
138 isync
139 blr
140
141
142
143
144
145
146
147
148_GLOBAL(__flush_icache_page)
149 li r4,4096/CACHE_LINE_SIZE
150 mtctr r4
1511: icbi 0,r3
152 addi r3,r3,CACHE_LINE_SIZE
153 bdnz 1b
154 sync
155 isync
156 blr
157
158
159
160
161
162
163_GLOBAL(clear_page)
164 li r0,4096/CACHE_LINE_SIZE
165 mtctr r0
1661: dcbz 0,r3
167 addi r3,r3,CACHE_LINE_SIZE
168 bdnz 1b
169 blr
170
171
172
173
174_GLOBAL(icache_enable)
175 mfspr r3, HID0
176 li r5, HID0_ICFI|HID0_ILOCK
177 andc r3, r3, r5
178 ori r3, r3, HID0_ICE
179 ori r5, r3, HID0_ICFI
180 mtspr HID0, r5
181 mtspr HID0, r3
182 isync
183 blr
184
185
186
187
188_GLOBAL(icache_disable)
189 mflr r4
190 bl invalidate_l1_instruction_cache
191 sync
192 mtlr r4
193 mfspr r3, HID0
194 li r5, 0
195 ori r5, r5, HID0_ICE
196 andc r3, r3, r5
197 mtspr HID0, r3
198 isync
199 blr
200
201
202
203
204_GLOBAL(icache_status)
205 mfspr r3, HID0
206 andi. r3, r3, HID0_ICE
207 blr
208
209
210_GLOBAL(l1dcache_enable)
211 mfspr r3, HID0
212 li r5, HID0_DCFI|HID0_DLOCK
213 andc r3, r3, r5
214 mtspr HID0, r3
215 ori r3, r3, HID0_DCE
216 ori r5, r3, HID0_DCFI
217 mtspr HID0, r5
218 mtspr HID0, r3
219 sync
220 blr
221
222
223
224
225
226_GLOBAL(dcache_enable)
227 mfspr r3, HID0
228 li r5, HID0_DCFI|HID0_DLOCK
229 andc r3, r3, r5
230 mtspr HID0, r3
231 ori r3, r3, HID0_DCE
232 ori r5, r3, HID0_DCFI
233 mtspr HID0, r5
234 mtspr HID0, r3
235 sync
236#ifdef CONFIG_SYS_L2
237 mflr r5
238 bl l2cache_enable
239 sync
240 mtlr r5
241#endif
242 blr
243
244
245
246
247
248
249
250_GLOBAL(dcache_disable)
251 mflr r4
252 bl flush_dcache
253 sync
254 mfspr r3, HID0
255 li r5, HID0_DCFI|HID0_DLOCK
256 andc r3, r3, r5
257 mtspr HID0, r3
258 li r5, HID0_DCE|HID0_DCFI
259 andc r3, r3, r5
260 mtspr HID0, r3
261 sync
262#ifdef CONFIG_SYS_L2
263 bl l2cache_disable_no_flush
264#endif
265 mtlr r4
266 blr
267
268
269
270
271_GLOBAL(dcache_status)
272 mfspr r3, HID0
273 andi. r3, r3, HID0_DCE
274 blr
275
276
277
278
279_GLOBAL(l2cache_invalidate)
280 mfspr r3, l2cr
281 rlwinm. r3, r3, 0, 0, 0
282 beq 1f
283
284 mfspr r3, l2cr
285 rlwinm r3, r3, 0, 1, 31
286
287#ifdef CONFIG_ALTIVEC
288 dssall
289#endif
290 sync
291 mtspr l2cr, r3
292 sync
2931: mfspr r3, l2cr
294 oris r3, r3, L2CR_L2I@h
295 mtspr l2cr, r3
296
297invl2:
298 mfspr r3, l2cr
299 andis. r3, r3, L2CR_L2I@h
300 bne invl2
301 blr
302
303
304
305
306
307_GLOBAL(l2cache_enable)
308 mflr r4
309 bl l2cache_invalidate
310 sync
311 lis r3, L2_ENABLE@h
312 ori r3, r3, L2_ENABLE@l
313 mtspr l2cr, r3
314 isync
315 mtlr r4
316 blr
317
318
319
320
321
322_GLOBAL(l2cache_disable)
323 mflr r4
324 bl flush_dcache
325 sync
326 mtlr r4
327l2cache_disable_no_flush:
328 lis r3, L2_INIT@h
329 ori r3, r3, L2_INIT@l
330 mtspr l2cr, r3
331 isync
332 blr
333