1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52#include <linux/linkage.h>
53#include <linux/init.h>
54#include <asm/assembler.h>
55#include <asm/hwcap.h>
56#include <asm/pgtable-hwdef.h>
57#include <asm/pgtable.h>
58#include <asm/page.h>
59#include <asm/ptrace.h>
60#include "proc-macros.S"
61
62
63
64
65#define CACHE_DLINESIZE 16
66
67
68
69
70#define CACHE_DSEGMENTS 2
71
72
73
74
75#define CACHE_DENTRIES 256
76
77
78
79
80
81
82#define CACHE_DLIMIT 8192
83
84 .text
85
86
87
88ENTRY(cpu_arm925_proc_init)
89 ret lr
90
91
92
93
94ENTRY(cpu_arm925_proc_fin)
95 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
96 bic r0, r0,
97 bic r0, r0,
98 mcr p15, 0, r0, c1, c0, 0 @ disable caches
99 ret lr
100
101
102
103
104
105
106
107
108
109
110 .align 5
111 .pushsection .idmap.text, "ax"
112ENTRY(cpu_arm925_reset)
113
114 mov ip,
115 orr ip, ip,
116 orr ip, ip,
117 mov r4,
118 strh r4, [ip,
119ENDPROC(cpu_arm925_reset)
120 .popsection
121
122 mov ip,
123 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
124 mcr p15, 0, ip, c7, c10, 4 @ drain WB
125#ifdef CONFIG_MMU
126 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
127#endif
128 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
129 bic ip, ip,
130 bic ip, ip,
131 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
132 ret r0
133
134
135
136
137
138
139 .align 10
140ENTRY(cpu_arm925_do_idle)
141 mov r0,
142 mrc p15, 0, r1, c1, c0, 0 @ Read control register
143 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
144 bic r2, r1,
145 mcr p15, 0, r2, c1, c0, 0 @ Disable I cache
146 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
147 mcr p15, 0, r1, c1, c0, 0 @ Restore ICache enable
148 ret lr
149
150
151
152
153
154
155ENTRY(arm925_flush_icache_all)
156 mov r0,
157 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
158 ret lr
159ENDPROC(arm925_flush_icache_all)
160
161
162
163
164
165
166
167ENTRY(arm925_flush_user_cache_all)
168
169
170
171
172
173
174
175ENTRY(arm925_flush_kern_cache_all)
176 mov r2,
177 mov ip,
178__flush_whole_cache:
179#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
180 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
181#else
182
183 mov r3,
1842: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
185 subs r3, r3,
186 bcs 2b @ entries 255 to 0
187#endif
188 tst r2,
189 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
190 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
191 ret lr
192
193
194
195
196
197
198
199
200
201
202
203ENTRY(arm925_flush_user_cache_range)
204 mov ip,
205 sub r3, r1, r0 @ calculate total size
206 cmp r3,
207 bgt __flush_whole_cache
2081: tst r2,
209#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
210 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
211 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
212 add r0, r0,
213 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
214 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
215 add r0, r0,
216#else
217 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
218 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
219 add r0, r0,
220 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
221 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
222 add r0, r0,
223#endif
224 cmp r0, r1
225 blo 1b
226 tst r2,
227 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
228 ret lr
229
230
231
232
233
234
235
236
237
238
239
240ENTRY(arm925_coherent_kern_range)
241
242
243
244
245
246
247
248
249
250
251
252
253ENTRY(arm925_coherent_user_range)
254 bic r0, r0,
2551: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
256 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
257 add r0, r0,
258 cmp r0, r1
259 blo 1b
260 mcr p15, 0, r0, c7, c10, 4 @ drain WB
261 mov r0,
262 ret lr
263
264
265
266
267
268
269
270
271
272
273ENTRY(arm925_flush_kern_dcache_area)
274 add r1, r0, r1
2751: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
276 add r0, r0,
277 cmp r0, r1
278 blo 1b
279 mov r0,
280 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
281 mcr p15, 0, r0, c7, c10, 4 @ drain WB
282 ret lr
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297arm925_dma_inv_range:
298#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
299 tst r0,
300 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
301 tst r1,
302 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
303#endif
304 bic r0, r0,
3051: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
306 add r0, r0,
307 cmp r0, r1
308 blo 1b
309 mcr p15, 0, r0, c7, c10, 4 @ drain WB
310 ret lr
311
312
313
314
315
316
317
318
319
320
321
322arm925_dma_clean_range:
323#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
324 bic r0, r0,
3251: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
326 add r0, r0,
327 cmp r0, r1
328 blo 1b
329#endif
330 mcr p15, 0, r0, c7, c10, 4 @ drain WB
331 ret lr
332
333
334
335
336
337
338
339
340
341ENTRY(arm925_dma_flush_range)
342 bic r0, r0,
3431:
344#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
345 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
346#else
347 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
348#endif
349 add r0, r0,
350 cmp r0, r1
351 blo 1b
352 mcr p15, 0, r0, c7, c10, 4 @ drain WB
353 ret lr
354
355
356
357
358
359
360
361ENTRY(arm925_dma_map_area)
362 add r1, r1, r0
363 cmp r2,
364 beq arm925_dma_clean_range
365 bcs arm925_dma_inv_range
366 b arm925_dma_flush_range
367ENDPROC(arm925_dma_map_area)
368
369
370
371
372
373
374
375ENTRY(arm925_dma_unmap_area)
376 ret lr
377ENDPROC(arm925_dma_unmap_area)
378
379 .globl arm925_flush_kern_cache_louis
380 .equ arm925_flush_kern_cache_louis, arm925_flush_kern_cache_all
381
382 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
383 define_cache_functions arm925
384
385ENTRY(cpu_arm925_dcache_clean_area)
386#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
3871: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
388 add r0, r0,
389 subs r1, r1,
390 bhi 1b
391#endif
392 mcr p15, 0, r0, c7, c10, 4 @ drain WB
393 ret lr
394
395
396
397
398
399
400
401
402
403
404 .align 5
405ENTRY(cpu_arm925_switch_mm)
406#ifdef CONFIG_MMU
407 mov ip,
408#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
409 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
410#else
411
412 mov r3,
4132: mcr p15, 0, r3, c7, c14, 2 @ clean & invalidate D index
414 subs r3, r3,
415 bcs 2b @ entries 255 to 0
416#endif
417 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
418 mcr p15, 0, ip, c7, c10, 4 @ drain WB
419 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
420 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
421#endif
422 ret lr
423
424
425
426
427
428
429 .align 5
430ENTRY(cpu_arm925_set_pte_ext)
431#ifdef CONFIG_MMU
432 armv3_set_pte_ext
433 mov r0, r0
434#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
435 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
436#endif
437 mcr p15, 0, r0, c7, c10, 4 @ drain WB
438#endif
439 ret lr
440
441 .type __arm925_setup,
442__arm925_setup:
443 mov r0,
444
445
446 orr r0,r0,
447 mcr p15, 0, r0, c15, c1, 0 @ write TI config register
448
449 mov r0,
450 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
451 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
452#ifdef CONFIG_MMU
453 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
454#endif
455
456#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
457 mov r0,
458 mcr p15, 7, r0, c15, c0, 0
459#endif
460
461 adr r5, arm925_crval
462 ldmia r5, {r5, r6}
463 mrc p15, 0, r0, c1, c0 @ get control register v4
464 bic r0, r0, r5
465 orr r0, r0, r6
466#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
467 orr r0, r0,
468#endif
469 ret lr
470 .size __arm925_setup, . - __arm925_setup
471
472
473
474
475
476
477
478 .type arm925_crval,
479arm925_crval:
480 crval clear=0x00007f3f, mmuset=0x0000313d, ucset=0x00001130
481
482 __INITDATA
483 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
484 define_processor_functions arm925, dabort=v4t_early_abort, pabort=legacy_pabort
485
486 .section ".rodata"
487
488 string cpu_arch_name, "armv4t"
489 string cpu_elf_name, "v4"
490 string cpu_arm925_name, "ARM925T"
491
492 .align
493
494 .section ".proc.info.init",
495
496.macro arm925_proc_info name:req, cpu_val:req, cpu_mask:req, cpu_name:req, cache
497 .type __\name\()_proc_info,
498__\name\()_proc_info:
499 .long \cpu_val
500 .long \cpu_mask
501 .long PMD_TYPE_SECT | \
502 PMD_SECT_CACHEABLE | \
503 PMD_BIT4 | \
504 PMD_SECT_AP_WRITE | \
505 PMD_SECT_AP_READ
506 .long PMD_TYPE_SECT | \
507 PMD_BIT4 | \
508 PMD_SECT_AP_WRITE | \
509 PMD_SECT_AP_READ
510 initfn __arm925_setup, __\name\()_proc_info
511 .long cpu_arch_name
512 .long cpu_elf_name
513 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
514 .long cpu_arm925_name
515 .long arm925_processor_functions
516 .long v4wbi_tlb_fns
517 .long v4wb_user_fns
518 .long arm925_cache_fns
519 .size __\name\()_proc_info, . - __\name\()_proc_info
520.endm
521
522 arm925_proc_info arm925, 0x54029250, 0xfffffff0, cpu_arm925_name
523 arm925_proc_info arm915, 0x54029150, 0xfffffff0, cpu_arm925_name
524