1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <linux/linkage.h>
24#include <linux/init.h>
25#include <asm/assembler.h>
26#include <asm/hwcap.h>
27#include <asm/pgtable.h>
28#include <asm/pgtable-hwdef.h>
29#include <asm/page.h>
30#include <asm/ptrace.h>
31#include "proc-macros.S"
32
33
34
35
36
37#define MAX_AREA_SIZE 32768
38
39
40
41
42#define CACHELINESIZE 32
43
44
45
46
47#define CACHESIZE 32768
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64#define CLEAN_ADDR 0xfffe0000
65
66
67
68
69
70
71 .macro cpwait, rd
72 mrc p15, 0, \rd, c2, c0, 0 @ arbitrary read of cp15
73 mov \rd, \rd @ wait for completion
74 sub pc, pc,
75 .endm
76
77 .macro cpwait_ret, lr, rd
78 mrc p15, 0, \rd, c2, c0, 0 @ arbitrary read of cp15
79 sub pc, \lr, \rd, LSR
80 @ flush instruction pipeline
81 .endm
82
83
84
85
86
87
88 .macro clean_d_cache, rd, rs
89 ldr \rs, =clean_addr
90 ldr \rd, [\rs]
91 eor \rd, \rd,
92 str \rd, [\rs]
93 add \rs, \rd,
941: mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
95 add \rd, \rd,
96 mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
97 add \rd, \rd,
98 mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
99 add \rd, \rd,
100 mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
101 add \rd, \rd,
102 teq \rd, \rs
103 bne 1b
104 .endm
105
106 .data
107 .align 2
108clean_addr: .word CLEAN_ADDR
109
110 .text
111
112
113
114
115
116
117ENTRY(cpu_xscale_proc_init)
118 @ enable write buffer coalescing. Some bootloader disable it
119 mrc p15, 0, r1, c1, c0, 1
120 bic r1, r1,
121 mcr p15, 0, r1, c1, c0, 1
122 ret lr
123
124
125
126
127ENTRY(cpu_xscale_proc_fin)
128 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
129 bic r0, r0,
130 bic r0, r0,
131 mcr p15, 0, r0, c1, c0, 0 @ disable caches
132 ret lr
133
134
135
136
137
138
139
140
141
142
143
144
145 .align 5
146 .pushsection .idmap.text, "ax"
147ENTRY(cpu_xscale_reset)
148 mov r1,
149 msr cpsr_c, r1 @ reset CPSR
150 mcr p15, 0, r1, c10, c4, 1 @ unlock I-TLB
151 mcr p15, 0, r1, c8, c5, 0 @ invalidate I-TLB
152 mrc p15, 0, r1, c1, c0, 0 @ ctrl register
153 bic r1, r1,
154 bic r1, r1,
155 sub pc, pc,
156 @ *** cache line aligned ***
157 mcr p15, 0, r1, c1, c0, 0 @ ctrl register
158 bic r1, r1,
159 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches & BTB
160 mcr p15, 0, r1, c1, c0, 0 @ ctrl register
161 @ CAUTION: MMU turned off from this point. We count on the pipeline
162 @ already containing those two last instructions to survive.
163 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
164 ret r0
165ENDPROC(cpu_xscale_reset)
166 .popsection
167
168
169
170
171
172
173
174
175
176
177
178 .align 5
179
180ENTRY(cpu_xscale_do_idle)
181 mov r0,
182 mcr p14, 0, r0, c7, c0, 0 @ Go to IDLE
183 ret lr
184
185
186
187
188
189
190
191
192ENTRY(xscale_flush_icache_all)
193 mov r0,
194 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
195 ret lr
196ENDPROC(xscale_flush_icache_all)
197
198
199
200
201
202
203
204ENTRY(xscale_flush_user_cache_all)
205
206
207
208
209
210
211
212ENTRY(xscale_flush_kern_cache_all)
213 mov r2,
214 mov ip,
215__flush_whole_cache:
216 clean_d_cache r0, r1
217 tst r2,
218 mcrne p15, 0, ip, c7, c5, 0 @ Invalidate I cache & BTB
219 mcrne p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
220 ret lr
221
222
223
224
225
226
227
228
229
230
231
232 .align 5
233ENTRY(xscale_flush_user_cache_range)
234 mov ip,
235 sub r3, r1, r0 @ calculate total size
236 cmp r3,
237 bhs __flush_whole_cache
238
2391: tst r2,
240 mcrne p15, 0, r0, c7, c5, 1 @ Invalidate I cache line
241 mcr p15, 0, r0, c7, c10, 1 @ Clean D cache line
242 mcr p15, 0, r0, c7, c6, 1 @ Invalidate D cache line
243 add r0, r0,
244 cmp r0, r1
245 blo 1b
246 tst r2,
247 mcrne p15, 0, ip, c7, c5, 6 @ Invalidate BTB
248 mcrne p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
249 ret lr
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264ENTRY(xscale_coherent_kern_range)
265 bic r0, r0,
2661: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
267 add r0, r0,
268 cmp r0, r1
269 blo 1b
270 mov r0,
271 mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB
272 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
273 ret lr
274
275
276
277
278
279
280
281
282
283
284
285ENTRY(xscale_coherent_user_range)
286 bic r0, r0,
2871: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
288 mcr p15, 0, r0, c7, c5, 1 @ Invalidate I cache entry
289 add r0, r0,
290 cmp r0, r1
291 blo 1b
292 mov r0,
293 mcr p15, 0, r0, c7, c5, 6 @ Invalidate BTB
294 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
295 ret lr
296
297
298
299
300
301
302
303
304
305
306ENTRY(xscale_flush_kern_dcache_area)
307 add r1, r0, r1
3081: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
309 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
310 add r0, r0,
311 cmp r0, r1
312 blo 1b
313 mov r0,
314 mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB
315 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
316 ret lr
317
318
319
320
321
322
323
324
325
326
327
328
329xscale_dma_inv_range:
330 tst r0,
331 bic r0, r0,
332 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
333 tst r1,
334 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
3351: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
336 add r0, r0,
337 cmp r0, r1
338 blo 1b
339 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
340 ret lr
341
342
343
344
345
346
347
348
349
350xscale_dma_clean_range:
351 bic r0, r0,
3521: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
353 add r0, r0,
354 cmp r0, r1
355 blo 1b
356 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
357 ret lr
358
359
360
361
362
363
364
365
366
367ENTRY(xscale_dma_flush_range)
368 bic r0, r0,
3691: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
370 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
371 add r0, r0,
372 cmp r0, r1
373 blo 1b
374 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
375 ret lr
376
377
378
379
380
381
382
383ENTRY(xscale_dma_map_area)
384 add r1, r1, r0
385 cmp r2,
386 beq xscale_dma_clean_range
387 bcs xscale_dma_inv_range
388 b xscale_dma_flush_range
389ENDPROC(xscale_dma_map_area)
390
391
392
393
394
395
396
397ENTRY(xscale_80200_A0_A1_dma_map_area)
398 add r1, r1, r0
399 teq r2,
400 beq xscale_dma_clean_range
401 b xscale_dma_flush_range
402ENDPROC(xscale_80200_A0_A1_dma_map_area)
403
404
405
406
407
408
409
410ENTRY(xscale_dma_unmap_area)
411 ret lr
412ENDPROC(xscale_dma_unmap_area)
413
414 .globl xscale_flush_kern_cache_louis
415 .equ xscale_flush_kern_cache_louis, xscale_flush_kern_cache_all
416
417 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
418 define_cache_functions xscale
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433.macro a0_alias basename
434 .globl xscale_80200_A0_A1_\basename
435 .type xscale_80200_A0_A1_\basename , %function
436 .equ xscale_80200_A0_A1_\basename , xscale_\basename
437.endm
438
439
440
441
442
443 a0_alias flush_icache_all
444 a0_alias flush_user_cache_all
445 a0_alias flush_kern_cache_all
446 a0_alias flush_kern_cache_louis
447 a0_alias flush_user_cache_range
448 a0_alias coherent_kern_range
449 a0_alias coherent_user_range
450 a0_alias flush_kern_dcache_area
451 a0_alias dma_flush_range
452 a0_alias dma_unmap_area
453
454 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
455 define_cache_functions xscale_80200_A0_A1
456
457ENTRY(cpu_xscale_dcache_clean_area)
4581: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
459 add r0, r0,
460 subs r1, r1,
461 bhi 1b
462 ret lr
463
464
465
466
467
468
469
470
471
472
473 .align 5
474ENTRY(cpu_xscale_switch_mm)
475 clean_d_cache r1, r2
476 mcr p15, 0, ip, c7, c5, 0 @ Invalidate I cache & BTB
477 mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
478 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
479 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
480 cpwait_ret lr, ip
481
482
483
484
485
486
487
488
489cpu_xscale_mt_table:
490 .long 0x00 @ L_PTE_MT_UNCACHED
491 .long PTE_BUFFERABLE @ L_PTE_MT_BUFFERABLE
492 .long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH
493 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEBACK
494 .long PTE_EXT_TEX(1) | PTE_BUFFERABLE @ L_PTE_MT_DEV_SHARED
495 .long 0x00 @ unused
496 .long PTE_EXT_TEX(1) | PTE_CACHEABLE @ L_PTE_MT_MINICACHE
497 .long PTE_EXT_TEX(1) | PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEALLOC
498 .long 0x00 @ unused
499 .long PTE_BUFFERABLE @ L_PTE_MT_DEV_WC
500 .long 0x00 @ unused
501 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_DEV_CACHED
502 .long 0x00 @ L_PTE_MT_DEV_NONSHARED
503 .long 0x00 @ unused
504 .long 0x00 @ unused
505 .long 0x00 @ unused
506
507 .align 5
508ENTRY(cpu_xscale_set_pte_ext)
509 xscale_set_pte_ext_prologue
510
511 @
512 @ Erratum 40: must set memory to write-through for user read-only pages
513 @
514 and ip, r1,
515 teq ip,
516
517 moveq r1,
518 and r1, r1,
519 adr ip, cpu_xscale_mt_table
520 ldr ip, [ip, r1]
521 bic r2, r2,
522 orr r2, r2, ip
523
524 xscale_set_pte_ext_epilogue
525 ret lr
526
527 .ltorg
528 .align
529
530.globl cpu_xscale_suspend_size
531.equ cpu_xscale_suspend_size, 4 * 6
532#ifdef CONFIG_ARM_CPU_SUSPEND
533ENTRY(cpu_xscale_do_suspend)
534 stmfd sp!, {r4 - r9, lr}
535 mrc p14, 0, r4, c6, c0, 0 @ clock configuration, for turbo mode
536 mrc p15, 0, r5, c15, c1, 0 @ CP access reg
537 mrc p15, 0, r6, c13, c0, 0 @ PID
538 mrc p15, 0, r7, c3, c0, 0 @ domain ID
539 mrc p15, 0, r8, c1, c0, 1 @ auxiliary control reg
540 mrc p15, 0, r9, c1, c0, 0 @ control reg
541 bic r4, r4,
542 stmia r0, {r4 - r9} @ store cp regs
543 ldmfd sp!, {r4 - r9, pc}
544ENDPROC(cpu_xscale_do_suspend)
545
546ENTRY(cpu_xscale_do_resume)
547 ldmia r0, {r4 - r9} @ load cp regs
548 mov ip,
549 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
550 mcr p15, 0, ip, c7, c7, 0 @ invalidate I & D caches, BTB
551 mcr p14, 0, r4, c6, c0, 0 @ clock configuration, turbo mode.
552 mcr p15, 0, r5, c15, c1, 0 @ CP access reg
553 mcr p15, 0, r6, c13, c0, 0 @ PID
554 mcr p15, 0, r7, c3, c0, 0 @ domain ID
555 mcr p15, 0, r1, c2, c0, 0 @ translation table base addr
556 mcr p15, 0, r8, c1, c0, 1 @ auxiliary control reg
557 mov r0, r9 @ control register
558 b cpu_resume_mmu
559ENDPROC(cpu_xscale_do_resume)
560#endif
561
562 .type __xscale_setup,
563__xscale_setup:
564 mcr p15, 0, ip, c7, c7, 0 @ invalidate I, D caches & BTB
565 mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
566 mcr p15, 0, ip, c8, c7, 0 @ invalidate I, D TLBs
567 mov r0,
568 orr r0, r0,
569 mcr p15, 0, r0, c15, c1, 0 @ affects USR or SVC modes
570
571 adr r5, xscale_crval
572 ldmia r5, {r5, r6}
573 mrc p15, 0, r0, c1, c0, 0 @ get control register
574 bic r0, r0, r5
575 orr r0, r0, r6
576 ret lr
577 .size __xscale_setup, . - __xscale_setup
578
579
580
581
582
583
584
585 .type xscale_crval,
586xscale_crval:
587 crval clear=0x00003b07, mmuset=0x00003905, ucset=0x00001900
588
589 __INITDATA
590
591 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
592 define_processor_functions xscale, dabort=v5t_early_abort, pabort=legacy_pabort, suspend=1
593
594 .section ".rodata"
595
596 string cpu_arch_name, "armv5te"
597 string cpu_elf_name, "v5"
598
599 string cpu_80200_A0_A1_name, "XScale-80200 A0/A1"
600 string cpu_80200_name, "XScale-80200"
601 string cpu_80219_name, "XScale-80219"
602 string cpu_8032x_name, "XScale-IOP8032x Family"
603 string cpu_8033x_name, "XScale-IOP8033x Family"
604 string cpu_pxa250_name, "XScale-PXA250"
605 string cpu_pxa210_name, "XScale-PXA210"
606 string cpu_ixp42x_name, "XScale-IXP42x Family"
607 string cpu_ixp43x_name, "XScale-IXP43x Family"
608 string cpu_ixp46x_name, "XScale-IXP46x Family"
609 string cpu_ixp2400_name, "XScale-IXP2400"
610 string cpu_ixp2800_name, "XScale-IXP2800"
611 string cpu_pxa255_name, "XScale-PXA255"
612 string cpu_pxa270_name, "XScale-PXA270"
613
614 .align
615
616 .section ".proc.info.init",
617
618.macro xscale_proc_info name:req, cpu_val:req, cpu_mask:req, cpu_name:req, cache
619 .type __\name\()_proc_info,
620__\name\()_proc_info:
621 .long \cpu_val
622 .long \cpu_mask
623 .long PMD_TYPE_SECT | \
624 PMD_SECT_BUFFERABLE | \
625 PMD_SECT_CACHEABLE | \
626 PMD_SECT_AP_WRITE | \
627 PMD_SECT_AP_READ
628 .long PMD_TYPE_SECT | \
629 PMD_SECT_AP_WRITE | \
630 PMD_SECT_AP_READ
631 initfn __xscale_setup, __\name\()_proc_info
632 .long cpu_arch_name
633 .long cpu_elf_name
634 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
635 .long \cpu_name
636 .long xscale_processor_functions
637 .long v4wbi_tlb_fns
638 .long xscale_mc_user_fns
639 .ifb \cache
640 .long xscale_cache_fns
641 .else
642 .long \cache
643 .endif
644 .size __\name\()_proc_info, . - __\name\()_proc_info
645.endm
646
647 xscale_proc_info 80200_A0_A1, 0x69052000, 0xfffffffe, cpu_80200_name, \
648 cache=xscale_80200_A0_A1_cache_fns
649 xscale_proc_info 80200, 0x69052000, 0xfffffff0, cpu_80200_name
650 xscale_proc_info 80219, 0x69052e20, 0xffffffe0, cpu_80219_name
651 xscale_proc_info 8032x, 0x69052420, 0xfffff7e0, cpu_8032x_name
652 xscale_proc_info 8033x, 0x69054010, 0xfffffd30, cpu_8033x_name
653 xscale_proc_info pxa250, 0x69052100, 0xfffff7f0, cpu_pxa250_name
654 xscale_proc_info pxa210, 0x69052120, 0xfffff3f0, cpu_pxa210_name
655 xscale_proc_info ixp2400, 0x69054190, 0xfffffff0, cpu_ixp2400_name
656 xscale_proc_info ixp2800, 0x690541a0, 0xfffffff0, cpu_ixp2800_name
657 xscale_proc_info ixp42x, 0x690541c0, 0xffffffc0, cpu_ixp42x_name
658 xscale_proc_info ixp43x, 0x69054040, 0xfffffff0, cpu_ixp43x_name
659 xscale_proc_info ixp46x, 0x69054200, 0xffffff00, cpu_ixp46x_name
660 xscale_proc_info pxa255, 0x69052d00, 0xfffffff0, cpu_pxa255_name
661 xscale_proc_info pxa270, 0x69054110, 0xfffffff0, cpu_pxa270_name
662