]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/blackfin/cpu/cache.S
Blackfin: use on-chip reset func with newer parts
[karo-tx-uboot.git] / arch / blackfin / cpu / cache.S
1 /*
2  * Blackfin cache control code
3  *
4  * Copyright 2003-2008 Analog Devices Inc.
5  *
6  * Enter bugs at http://blackfin.uclinux.org/
7  *
8  * Licensed under the GPL-2 or later.
9  */
10
11 #include <asm/linkage.h>
12 #include <config.h>
13 #include <asm/blackfin.h>
14
15 .text
16 /* Since all L1 caches work the same way, we use the same method for flushing
17  * them.  Only the actual flush instruction differs.  We write this in asm as
18  * GCC can be hard to coax into writing nice hardware loops.
19  *
20  * Also, we assume the following register setup:
21  * R0 = start address
22  * R1 = end address
23  */
24 .macro do_flush flushins:req optflushins optnopins label
25
26         R2 = -L1_CACHE_BYTES;
27
28         /* start = (start & -L1_CACHE_BYTES) */
29         R0 = R0 & R2;
30
31         /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
32         R1 += -1;
33         R1 = R1 & R2;
34         R1 += L1_CACHE_BYTES;
35
36         /* count = (end - start) >> L1_CACHE_SHIFT */
37         R2 = R1 - R0;
38         R2 >>= L1_CACHE_SHIFT;
39         P1 = R2;
40
41 .ifnb \label
42 \label :
43 .endif
44         P0 = R0;
45         LSETUP (1f, 2f) LC1 = P1;
46 1:
47 .ifnb \optflushins
48         \optflushins [P0];
49 .endif
50 #if ANOMALY_05000443
51 .ifb \optnopins
52 2:
53 .endif
54         \flushins [P0++];
55 .ifnb \optnopins
56 2:      \optnopins;
57 .endif
58 #else
59 2:      \flushins [P0++];
60 #endif
61
62         RTS;
63 .endm
64
65 /* Invalidate all instruction cache lines assocoiated with this memory area */
66 ENTRY(_blackfin_icache_flush_range)
67         do_flush IFLUSH, , nop
68 ENDPROC(_blackfin_icache_flush_range)
69
70 /* Flush all cache lines assocoiated with this area of memory. */
71 ENTRY(_blackfin_icache_dcache_flush_range)
72         do_flush FLUSH, IFLUSH
73 ENDPROC(_blackfin_icache_dcache_flush_range)
74
75 /* Throw away all D-cached data in specified region without any obligation to
76  * write them back.  Since the Blackfin ISA does not have an "invalidate"
77  * instruction, we use flush/invalidate.  Perhaps as a speed optimization we
78  * could bang on the DTEST MMRs ...
79  */
80 ENTRY(_blackfin_dcache_flush_invalidate_range)
81         do_flush FLUSHINV
82 ENDPROC(_blackfin_dcache_flush_invalidate_range)
83
84 /* Flush all data cache lines assocoiated with this memory area */
85 ENTRY(_blackfin_dcache_flush_range)
86         do_flush FLUSH, , , .Ldfr
87 ENDPROC(_blackfin_dcache_flush_range)