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#include <linux/linkage.h>
29#include <linux/init.h>
30#include <asm/assembler.h>
31#include <asm/asm-offsets.h>
32#include <asm/hwcap.h>
33#include <asm/pgtable-hwdef.h>
34#include <asm/pgtable.h>
35#include <asm/ptrace.h>
36
37#include "proc-macros.S"
38
39
40
41
42
43
44
45
46
47#define MAX_AREA_SIZE 32768
48
49
50
51
52#define CACHE_DLINESIZE 32
53
54
55
56
57#define CACHE_DSEGMENTS 16
58
59
60
61
62#define CACHE_DENTRIES 64
63
64
65
66
67
68
69#define CACHE_DLIMIT 32768
70
71 .text
72
73
74
75ENTRY(cpu_arm1020_proc_init)
76 mov pc, lr
77
78
79
80
81ENTRY(cpu_arm1020_proc_fin)
82 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
83 bic r0, r0,
84 bic r0, r0,
85 mcr p15, 0, r0, c1, c0, 0 @ disable caches
86 mov pc, lr
87
88
89
90
91
92
93
94
95
96
97 .align 5
98 .pushsection .idmap.text, "ax"
99ENTRY(cpu_arm1020_reset)
100 mov ip,
101 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
102 mcr p15, 0, ip, c7, c10, 4 @ drain WB
103#ifdef CONFIG_MMU
104 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
105#endif
106 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
107 bic ip, ip,
108 bic ip, ip,
109 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
110 mov pc, r0
111ENDPROC(cpu_arm1020_reset)
112 .popsection
113
114
115
116
117 .align 5
118ENTRY(cpu_arm1020_do_idle)
119 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
120 mov pc, lr
121
122
123
124 .align 5
125
126
127
128
129
130
131ENTRY(arm1020_flush_icache_all)
132#ifndef CONFIG_CPU_ICACHE_DISABLE
133 mov r0,
134 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
135#endif
136 mov pc, lr
137ENDPROC(arm1020_flush_icache_all)
138
139
140
141
142
143
144
145ENTRY(arm1020_flush_user_cache_all)
146
147
148
149
150
151
152ENTRY(arm1020_flush_kern_cache_all)
153 mov r2,
154 mov ip,
155__flush_whole_cache:
156#ifndef CONFIG_CPU_DCACHE_DISABLE
157 mcr p15, 0, ip, c7, c10, 4 @ drain WB
158 mov r1,
1591: orr r3, r1,
1602: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
161 mcr p15, 0, ip, c7, c10, 4 @ drain WB
162 subs r3, r3,
163 bcs 2b @ entries 63 to 0
164 subs r1, r1,
165 bcs 1b @ segments 15 to 0
166#endif
167 tst r2,
168#ifndef CONFIG_CPU_ICACHE_DISABLE
169 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
170#endif
171 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
172 mov pc, lr
173
174
175
176
177
178
179
180
181
182
183
184ENTRY(arm1020_flush_user_cache_range)
185 mov ip,
186 sub r3, r1, r0 @ calculate total size
187 cmp r3,
188 bhs __flush_whole_cache
189
190#ifndef CONFIG_CPU_DCACHE_DISABLE
191 mcr p15, 0, ip, c7, c10, 4
1921: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
193 mcr p15, 0, ip, c7, c10, 4 @ drain WB
194 add r0, r0,
195 cmp r0, r1
196 blo 1b
197#endif
198 tst r2,
199#ifndef CONFIG_CPU_ICACHE_DISABLE
200 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
201#endif
202 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
203 mov pc, lr
204
205
206
207
208
209
210
211
212
213
214
215ENTRY(arm1020_coherent_kern_range)
216
217
218
219
220
221
222
223
224
225
226
227
228ENTRY(arm1020_coherent_user_range)
229 mov ip,
230 bic r0, r0,
231 mcr p15, 0, ip, c7, c10, 4
2321:
233#ifndef CONFIG_CPU_DCACHE_DISABLE
234 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
235 mcr p15, 0, ip, c7, c10, 4 @ drain WB
236#endif
237#ifndef CONFIG_CPU_ICACHE_DISABLE
238 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
239#endif
240 add r0, r0,
241 cmp r0, r1
242 blo 1b
243 mcr p15, 0, ip, c7, c10, 4 @ drain WB
244 mov r0,
245 mov pc, lr
246
247
248
249
250
251
252
253
254
255
256ENTRY(arm1020_flush_kern_dcache_area)
257 mov ip,
258#ifndef CONFIG_CPU_DCACHE_DISABLE
259 add r1, r0, r1
2601: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
261 mcr p15, 0, ip, c7, c10, 4 @ drain WB
262 add r0, r0,
263 cmp r0, r1
264 blo 1b
265#endif
266 mcr p15, 0, ip, c7, c10, 4 @ drain WB
267 mov pc, lr
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282arm1020_dma_inv_range:
283 mov ip,
284#ifndef CONFIG_CPU_DCACHE_DISABLE
285 tst r0,
286 bic r0, r0,
287 mcrne p15, 0, ip, c7, c10, 4
288 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
289 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
290 tst r1,
291 mcrne p15, 0, ip, c7, c10, 4
292 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
293 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
2941: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
295 add r0, r0,
296 cmp r0, r1
297 blo 1b
298#endif
299 mcr p15, 0, ip, c7, c10, 4 @ drain WB
300 mov pc, lr
301
302
303
304
305
306
307
308
309
310
311
312arm1020_dma_clean_range:
313 mov ip,
314#ifndef CONFIG_CPU_DCACHE_DISABLE
315 bic r0, r0,
3161: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
317 mcr p15, 0, ip, c7, c10, 4 @ drain WB
318 add r0, r0,
319 cmp r0, r1
320 blo 1b
321#endif
322 mcr p15, 0, ip, c7, c10, 4 @ drain WB
323 mov pc, lr
324
325
326
327
328
329
330
331
332
333ENTRY(arm1020_dma_flush_range)
334 mov ip,
335#ifndef CONFIG_CPU_DCACHE_DISABLE
336 bic r0, r0,
337 mcr p15, 0, ip, c7, c10, 4
3381: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
339 mcr p15, 0, ip, c7, c10, 4 @ drain WB
340 add r0, r0,
341 cmp r0, r1
342 blo 1b
343#endif
344 mcr p15, 0, ip, c7, c10, 4 @ drain WB
345 mov pc, lr
346
347
348
349
350
351
352
353ENTRY(arm1020_dma_map_area)
354 add r1, r1, r0
355 cmp r2,
356 beq arm1020_dma_clean_range
357 bcs arm1020_dma_inv_range
358 b arm1020_dma_flush_range
359ENDPROC(arm1020_dma_map_area)
360
361
362
363
364
365
366
367ENTRY(arm1020_dma_unmap_area)
368 mov pc, lr
369ENDPROC(arm1020_dma_unmap_area)
370
371 .globl arm1020_flush_kern_cache_louis
372 .equ arm1020_flush_kern_cache_louis, arm1020_flush_kern_cache_all
373
374 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
375 define_cache_functions arm1020
376
377 .align 5
378ENTRY(cpu_arm1020_dcache_clean_area)
379#ifndef CONFIG_CPU_DCACHE_DISABLE
380 mov ip,
3811: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
382 mcr p15, 0, ip, c7, c10, 4 @ drain WB
383 add r0, r0,
384 subs r1, r1,
385 bhi 1b
386#endif
387 mov pc, lr
388
389
390
391
392
393
394
395
396
397
398 .align 5
399ENTRY(cpu_arm1020_switch_mm)
400#ifdef CONFIG_MMU
401#ifndef CONFIG_CPU_DCACHE_DISABLE
402 mcr p15, 0, r3, c7, c10, 4
403 mov r1,
4041: mov r3,
4052: mov ip, r3, LSL
406 orr ip, ip, r1, LSL
407 mcr p15, 0, ip, c7, c14, 2 @ Clean & Inval DCache entry
408 mov ip,
409 mcr p15, 0, ip, c7, c10, 4
410 subs r3, r3,
411 cmp r3,
412 bge 2b @ entries 3F to 0
413 subs r1, r1,
414 cmp r1,
415 bge 1b @ segments 15 to 0
416
417#endif
418 mov r1,
419#ifndef CONFIG_CPU_ICACHE_DISABLE
420 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
421#endif
422 mcr p15, 0, r1, c7, c10, 4 @ drain WB
423 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
424 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
425#endif
426 mov pc, lr
427
428
429
430
431
432
433 .align 5
434ENTRY(cpu_arm1020_set_pte_ext)
435#ifdef CONFIG_MMU
436 armv3_set_pte_ext
437 mov r0, r0
438#ifndef CONFIG_CPU_DCACHE_DISABLE
439 mcr p15, 0, r0, c7, c10, 4
440 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
441#endif
442 mcr p15, 0, r0, c7, c10, 4 @ drain WB
443#endif
444 mov pc, lr
445
446 __CPUINIT
447
448 .type __arm1020_setup,
449__arm1020_setup:
450 mov r0,
451 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
452 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
453#ifdef CONFIG_MMU
454 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
455#endif
456
457 adr r5, arm1020_crval
458 ldmia r5, {r5, r6}
459 mrc p15, 0, r0, c1, c0 @ get control register v4
460 bic r0, r0, r5
461 orr r0, r0, r6
462#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
463 orr r0, r0,
464#endif
465 mov pc, lr
466 .size __arm1020_setup, . - __arm1020_setup
467
468
469
470
471
472
473 .type arm1020_crval,
474arm1020_crval:
475 crval clear=0x0000593f, mmuset=0x00003935, ucset=0x00001930
476
477 __INITDATA
478 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
479 define_processor_functions arm1020, dabort=v4t_early_abort, pabort=legacy_pabort
480
481
482 .section ".rodata"
483
484 string cpu_arch_name, "armv5t"
485 string cpu_elf_name, "v5"
486
487 .type cpu_arm1020_name,
488cpu_arm1020_name:
489 .ascii "ARM1020"
490#ifndef CONFIG_CPU_ICACHE_DISABLE
491 .ascii "i"
492#endif
493#ifndef CONFIG_CPU_DCACHE_DISABLE
494 .ascii "d"
495#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
496 .ascii "(wt)"
497#else
498 .ascii "(wb)"
499#endif
500#endif
501#ifndef CONFIG_CPU_BPREDICT_DISABLE
502 .ascii "B"
503#endif
504#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
505 .ascii "RR"
506#endif
507 .ascii "\0"
508 .size cpu_arm1020_name, . - cpu_arm1020_name
509
510 .align
511
512 .section ".proc.info.init",
513
514 .type __arm1020_proc_info,
515__arm1020_proc_info:
516 .long 0x4104a200 @ ARM 1020T (Architecture v5T)
517 .long 0xff0ffff0
518 .long PMD_TYPE_SECT | \
519 PMD_SECT_AP_WRITE | \
520 PMD_SECT_AP_READ
521 .long PMD_TYPE_SECT | \
522 PMD_SECT_AP_WRITE | \
523 PMD_SECT_AP_READ
524 b __arm1020_setup
525 .long cpu_arch_name
526 .long cpu_elf_name
527 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
528 .long cpu_arm1020_name
529 .long arm1020_processor_functions
530 .long v4wbi_tlb_fns
531 .long v4wb_user_fns
532 .long arm1020_cache_fns
533 .size __arm1020_proc_info, . - __arm1020_proc_info
534