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/hwcap.h>
32#include <asm/pgtable-hwdef.h>
33#include <asm/pgtable.h>
34#include <asm/page.h>
35#include <asm/ptrace.h>
36#include "proc-macros.S"
37
38
39
40
41
42
43
44
45
46#define CACHE_DLIMIT 16384
47
48
49
50
51#define CACHE_DLINESIZE 32
52
53 .text
54
55
56
57ENTRY(cpu_arm926_proc_init)
58 ret lr
59
60
61
62
63ENTRY(cpu_arm926_proc_fin)
64 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
65 bic r0, r0,
66 bic r0, r0,
67 mcr p15, 0, r0, c1, c0, 0 @ disable caches
68 ret lr
69
70
71
72
73
74
75
76
77
78
79 .align 5
80 .pushsection .idmap.text, "ax"
81ENTRY(cpu_arm926_reset)
82 mov ip,
83 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
84 mcr p15, 0, ip, c7, c10, 4 @ drain WB
85#ifdef CONFIG_MMU
86 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
87#endif
88 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
89 bic ip, ip,
90 bic ip, ip,
91 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
92 ret r0
93ENDPROC(cpu_arm926_reset)
94 .popsection
95
96
97
98
99
100
101 .align 10
102ENTRY(cpu_arm926_do_idle)
103 mov r0,
104 mrc p15, 0, r1, c1, c0, 0 @ Read control register
105 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
106 bic r2, r1,
107 mrs r3, cpsr @ Disable FIQs while Icache
108 orr ip, r3,
109 msr cpsr_c, ip
110 mcr p15, 0, r2, c1, c0, 0 @ Disable I cache
111 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
112 mcr p15, 0, r1, c1, c0, 0 @ Restore ICache enable
113 msr cpsr_c, r3 @ Restore FIQ state
114 ret lr
115
116
117
118
119
120
121ENTRY(arm926_flush_icache_all)
122 mov r0,
123 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
124 ret lr
125ENDPROC(arm926_flush_icache_all)
126
127
128
129
130
131
132
133ENTRY(arm926_flush_user_cache_all)
134
135
136
137
138
139
140
141ENTRY(arm926_flush_kern_cache_all)
142 mov r2,
143 mov ip,
144__flush_whole_cache:
145#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
146 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
147#else
1481: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
149 bne 1b
150#endif
151 tst r2,
152 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
153 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
154 ret lr
155
156
157
158
159
160
161
162
163
164
165
166ENTRY(arm926_flush_user_cache_range)
167 mov ip,
168 sub r3, r1, r0 @ calculate total size
169 cmp r3,
170 bgt __flush_whole_cache
1711: tst r2,
172#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
173 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
174 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
175 add r0, r0,
176 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
177 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
178 add r0, r0,
179#else
180 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
181 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
182 add r0, r0,
183 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
184 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
185 add r0, r0,
186#endif
187 cmp r0, r1
188 blo 1b
189 tst r2,
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(arm926_coherent_kern_range)
204
205
206
207
208
209
210
211
212
213
214
215
216ENTRY(arm926_coherent_user_range)
217 bic r0, r0,
2181: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
219 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
220 add r0, r0,
221 cmp r0, r1
222 blo 1b
223 mcr p15, 0, r0, c7, c10, 4 @ drain WB
224 mov r0,
225 ret lr
226
227
228
229
230
231
232
233
234
235
236ENTRY(arm926_flush_kern_dcache_area)
237 add r1, r0, r1
2381: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
239 add r0, r0,
240 cmp r0, r1
241 blo 1b
242 mov r0,
243 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
244 mcr p15, 0, r0, c7, c10, 4 @ drain WB
245 ret lr
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260arm926_dma_inv_range:
261#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
262 tst r0,
263 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
264 tst r1,
265 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
266#endif
267 bic r0, r0,
2681: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
269 add r0, r0,
270 cmp r0, r1
271 blo 1b
272 mcr p15, 0, r0, c7, c10, 4 @ drain WB
273 ret lr
274
275
276
277
278
279
280
281
282
283
284
285arm926_dma_clean_range:
286#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
287 bic r0, r0,
2881: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
289 add r0, r0,
290 cmp r0, r1
291 blo 1b
292#endif
293 mcr p15, 0, r0, c7, c10, 4 @ drain WB
294 ret lr
295
296
297
298
299
300
301
302
303
304ENTRY(arm926_dma_flush_range)
305 bic r0, r0,
3061:
307#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
308 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
309#else
310 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
311#endif
312 add r0, r0,
313 cmp r0, r1
314 blo 1b
315 mcr p15, 0, r0, c7, c10, 4 @ drain WB
316 ret lr
317
318
319
320
321
322
323
324ENTRY(arm926_dma_map_area)
325 add r1, r1, r0
326 cmp r2,
327 beq arm926_dma_clean_range
328 bcs arm926_dma_inv_range
329 b arm926_dma_flush_range
330ENDPROC(arm926_dma_map_area)
331
332
333
334
335
336
337
338ENTRY(arm926_dma_unmap_area)
339 ret lr
340ENDPROC(arm926_dma_unmap_area)
341
342 .globl arm926_flush_kern_cache_louis
343 .equ arm926_flush_kern_cache_louis, arm926_flush_kern_cache_all
344
345 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
346 define_cache_functions arm926
347
348ENTRY(cpu_arm926_dcache_clean_area)
349#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
3501: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
351 add r0, r0,
352 subs r1, r1,
353 bhi 1b
354#endif
355 mcr p15, 0, r0, c7, c10, 4 @ drain WB
356 ret lr
357
358
359
360
361
362
363
364
365
366
367 .align 5
368ENTRY(cpu_arm926_switch_mm)
369#ifdef CONFIG_MMU
370 mov ip,
371#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
372 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
373#else
374@ && 'Clean & Invalidate whole DCache'
3751: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
376 bne 1b
377#endif
378 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
379 mcr p15, 0, ip, c7, c10, 4 @ drain WB
380 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
381 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
382#endif
383 ret lr
384
385
386
387
388
389
390 .align 5
391ENTRY(cpu_arm926_set_pte_ext)
392#ifdef CONFIG_MMU
393 armv3_set_pte_ext
394 mov r0, r0
395#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
396 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
397#endif
398 mcr p15, 0, r0, c7, c10, 4 @ drain WB
399#endif
400 ret lr
401
402
403.globl cpu_arm926_suspend_size
404.equ cpu_arm926_suspend_size, 4 * 3
405#ifdef CONFIG_ARM_CPU_SUSPEND
406ENTRY(cpu_arm926_do_suspend)
407 stmfd sp!, {r4 - r6, lr}
408 mrc p15, 0, r4, c13, c0, 0 @ PID
409 mrc p15, 0, r5, c3, c0, 0 @ Domain ID
410 mrc p15, 0, r6, c1, c0, 0 @ Control register
411 stmia r0, {r4 - r6}
412 ldmfd sp!, {r4 - r6, pc}
413ENDPROC(cpu_arm926_do_suspend)
414
415ENTRY(cpu_arm926_do_resume)
416 mov ip,
417 mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs
418 mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches
419 ldmia r0, {r4 - r6}
420 mcr p15, 0, r4, c13, c0, 0 @ PID
421 mcr p15, 0, r5, c3, c0, 0 @ Domain ID
422 mcr p15, 0, r1, c2, c0, 0 @ TTB address
423 mov r0, r6 @ control register
424 b cpu_resume_mmu
425ENDPROC(cpu_arm926_do_resume)
426#endif
427
428 .type __arm926_setup,
429__arm926_setup:
430 mov r0,
431 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
432 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
433#ifdef CONFIG_MMU
434 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
435#endif
436
437
438#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
439 mov r0,
440 mcr p15, 7, r0, c15, c0, 0
441#endif
442
443 adr r5, arm926_crval
444 ldmia r5, {r5, r6}
445 mrc p15, 0, r0, c1, c0 @ get control register v4
446 bic r0, r0, r5
447 orr r0, r0, r6
448#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
449 orr r0, r0,
450#endif
451 ret lr
452 .size __arm926_setup, . - __arm926_setup
453
454
455
456
457
458
459
460 .type arm926_crval,
461arm926_crval:
462 crval clear=0x00007f3f, mmuset=0x00003135, ucset=0x00001134
463
464 __INITDATA
465
466 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
467 define_processor_functions arm926, dabort=v5tj_early_abort, pabort=legacy_pabort, suspend=1
468
469 .section ".rodata"
470
471 string cpu_arch_name, "armv5tej"
472 string cpu_elf_name, "v5"
473 string cpu_arm926_name, "ARM926EJ-S"
474
475 .align
476
477 .section ".proc.info.init",
478
479 .type __arm926_proc_info,
480__arm926_proc_info:
481 .long 0x41069260 @ ARM926EJ-S (v5TEJ)
482 .long 0xff0ffff0
483 .long PMD_TYPE_SECT | \
484 PMD_SECT_BUFFERABLE | \
485 PMD_SECT_CACHEABLE | \
486 PMD_BIT4 | \
487 PMD_SECT_AP_WRITE | \
488 PMD_SECT_AP_READ
489 .long PMD_TYPE_SECT | \
490 PMD_BIT4 | \
491 PMD_SECT_AP_WRITE | \
492 PMD_SECT_AP_READ
493 initfn __arm926_setup, __arm926_proc_info
494 .long cpu_arch_name
495 .long cpu_elf_name
496 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
497 .long cpu_arm926_name
498 .long arm926_processor_functions
499 .long v4wbi_tlb_fns
500 .long v4wb_user_fns
501 .long arm926_cache_fns
502 .size __arm926_proc_info, . - __arm926_proc_info
503