]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/blackfin/mach-common/cache.S
[ARM] pxa: fix the bad assumption that PCMCIA sockets always start with 0
[linux-2.6-omap-h63xx.git] / arch / blackfin / mach-common / cache.S
1 /*
2  * Blackfin cache control code
3  *
4  * Copyright 2004-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 <linux/linkage.h>
12 #include <asm/blackfin.h>
13 #include <asm/cache.h>
14 #include <asm/page.h>
15
16 .text
17
18 /* Since all L1 caches work the same way, we use the same method for flushing
19  * them.  Only the actual flush instruction differs.  We write this in asm as
20  * GCC can be hard to coax into writing nice hardware loops.
21  *
22  * Also, we assume the following register setup:
23  * R0 = start address
24  * R1 = end address
25  */
26 .macro do_flush flushins:req optflushins optnopins label
27
28         R2 = -L1_CACHE_BYTES;
29
30         /* start = (start & -L1_CACHE_BYTES) */
31         R0 = R0 & R2;
32
33         /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
34         R1 += -1;
35         R1 = R1 & R2;
36         R1 += L1_CACHE_BYTES;
37
38         /* count = (end - start) >> L1_CACHE_SHIFT */
39         R2 = R1 - R0;
40         R2 >>= L1_CACHE_SHIFT;
41         P1 = R2;
42
43 .ifnb \label
44 \label :
45 .endif
46         P0 = R0;
47         LSETUP (1f, 2f) LC1 = P1;
48 1:
49 .ifnb \optflushins
50         \optflushins [P0];
51 .endif
52 #if ANOMALY_05000443
53 .ifb \optnopins
54 2:
55 .endif
56         \flushins [P0++];
57 .ifnb \optnopins
58 2:      \optnopins;
59 .endif
60 #else
61 2:      \flushins [P0++];
62 #endif
63
64         RTS;
65 .endm
66
67 /* Invalidate all instruction cache lines assocoiated with this memory area */
68 ENTRY(_blackfin_icache_flush_range)
69         do_flush IFLUSH, , nop
70 ENDPROC(_blackfin_icache_flush_range)
71
72 /* Flush all cache lines assocoiated with this area of memory. */
73 ENTRY(_blackfin_icache_dcache_flush_range)
74         do_flush FLUSH, IFLUSH
75 ENDPROC(_blackfin_icache_dcache_flush_range)
76
77 /* Throw away all D-cached data in specified region without any obligation to
78  * write them back.  Since the Blackfin ISA does not have an "invalidate"
79  * instruction, we use flush/invalidate.  Perhaps as a speed optimization we
80  * could bang on the DTEST MMRs ...
81  */
82 ENTRY(_blackfin_dcache_invalidate_range)
83         do_flush FLUSHINV
84 ENDPROC(_blackfin_dcache_invalidate_range)
85
86 /* Flush all data cache lines assocoiated with this memory area */
87 ENTRY(_blackfin_dcache_flush_range)
88         do_flush FLUSH, , , .Ldfr
89 ENDPROC(_blackfin_dcache_flush_range)
90
91 /* Our headers convert the page structure to an address, so just need to flush
92  * its contents like normal.  We know the start address is page aligned (which
93  * greater than our cache alignment), as is the end address.  So just jump into
94  * the middle of the dcache flush function.
95  */
96 ENTRY(_blackfin_dflush_page)
97         P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
98         jump .Ldfr;
99 ENDPROC(_blackfin_dflush_page)