diff options
author | Jesper Nilsson <jesper.nilsson@axis.com> | 2007-11-14 20:01:27 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-14 21:45:47 -0500 |
commit | 57c230a873b9d82ae88d6b6736127b5485024699 (patch) | |
tree | c269b27965def19b45436f9e0a8946b6e53dba51 /arch | |
parent | d8e5219f9f5ca7518eb820db9f3d287a1d46fcf5 (diff) |
CRISv32: add cache flush operations
These are needed due to a cache bug, and can be used to make sure that the
DMA descriptors are flushed to memory and can be safely handled by DMA.
flush_dma_descr - Flush one DMA descriptor.
flush_dma_list - Flush a complete list of DMA descriptors.
cris_flush_cache - Flush the complete cache.
cris_flush_cache_range - Flush only the specified range
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/cris/arch-v32/kernel/cache.c | 33 | ||||
-rw-r--r-- | arch/cris/arch-v32/kernel/cacheflush.S | 94 |
2 files changed, 127 insertions, 0 deletions
diff --git a/arch/cris/arch-v32/kernel/cache.c b/arch/cris/arch-v32/kernel/cache.c new file mode 100644 index 000000000000..80da7b88a72b --- /dev/null +++ b/arch/cris/arch-v32/kernel/cache.c | |||
@@ -0,0 +1,33 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <asm/io.h> | ||
3 | #include <asm/arch/cache.h> | ||
4 | #include <asm/arch/hwregs/dma.h> | ||
5 | |||
6 | /* This file is used to workaround a cache bug, Guinness TR 106. */ | ||
7 | |||
8 | inline void flush_dma_descr(struct dma_descr_data *descr, int flush_buf) | ||
9 | { | ||
10 | /* Flush descriptor to make sure we get correct in_eop and after. */ | ||
11 | asm volatile ("ftagd [%0]" :: "r" (descr)); | ||
12 | /* Flush buffer pointed out by descriptor. */ | ||
13 | if (flush_buf) | ||
14 | cris_flush_cache_range(phys_to_virt((unsigned)descr->buf), | ||
15 | (unsigned)(descr->after - descr->buf)); | ||
16 | } | ||
17 | EXPORT_SYMBOL(flush_dma_descr); | ||
18 | |||
19 | void flush_dma_list(struct dma_descr_data *descr) | ||
20 | { | ||
21 | while (1) { | ||
22 | flush_dma_descr(descr, 1); | ||
23 | if (descr->eol) | ||
24 | break; | ||
25 | descr = phys_to_virt((unsigned)descr->next); | ||
26 | } | ||
27 | } | ||
28 | EXPORT_SYMBOL(flush_dma_list); | ||
29 | |||
30 | /* From cacheflush.S */ | ||
31 | EXPORT_SYMBOL(cris_flush_cache); | ||
32 | /* From cacheflush.S */ | ||
33 | EXPORT_SYMBOL(cris_flush_cache_range); | ||
diff --git a/arch/cris/arch-v32/kernel/cacheflush.S b/arch/cris/arch-v32/kernel/cacheflush.S new file mode 100644 index 000000000000..956e8fb82f01 --- /dev/null +++ b/arch/cris/arch-v32/kernel/cacheflush.S | |||
@@ -0,0 +1,94 @@ | |||
1 | .global cris_flush_cache_range | ||
2 | cris_flush_cache_range: | ||
3 | move.d 1024, $r12 | ||
4 | cmp.d $r11, $r12 | ||
5 | bhi cris_flush_1KB | ||
6 | nop | ||
7 | add.d $r10, $r11 | ||
8 | ftagd [$r10] | ||
9 | cris_flush_last: | ||
10 | addq 32, $r10 | ||
11 | cmp.d $r11, $r10 | ||
12 | blt cris_flush_last | ||
13 | ftagd [$r10] | ||
14 | ret | ||
15 | nop | ||
16 | cris_flush_1KB: | ||
17 | ftagd [$r10] | ||
18 | addq 32, $r10 | ||
19 | ftagd [$r10] | ||
20 | addq 32, $r10 | ||
21 | ftagd [$r10] | ||
22 | addq 32, $r10 | ||
23 | ftagd [$r10] | ||
24 | addq 32, $r10 | ||
25 | ftagd [$r10] | ||
26 | addq 32, $r10 | ||
27 | ftagd [$r10] | ||
28 | addq 32, $r10 | ||
29 | ftagd [$r10] | ||
30 | addq 32, $r10 | ||
31 | ftagd [$r10] | ||
32 | addq 32, $r10 | ||
33 | ftagd [$r10] | ||
34 | addq 32, $r10 | ||
35 | ftagd [$r10] | ||
36 | addq 32, $r10 | ||
37 | ftagd [$r10] | ||
38 | addq 32, $r10 | ||
39 | ftagd [$r10] | ||
40 | addq 32, $r10 | ||
41 | ftagd [$r10] | ||
42 | addq 32, $r10 | ||
43 | ftagd [$r10] | ||
44 | addq 32, $r10 | ||
45 | ftagd [$r10] | ||
46 | addq 32, $r10 | ||
47 | ftagd [$r10] | ||
48 | addq 32, $r10 | ||
49 | ftagd [$r10] | ||
50 | addq 32, $r10 | ||
51 | ftagd [$r10] | ||
52 | addq 32, $r10 | ||
53 | ftagd [$r10] | ||
54 | addq 32, $r10 | ||
55 | ftagd [$r10] | ||
56 | addq 32, $r10 | ||
57 | ftagd [$r10] | ||
58 | addq 32, $r10 | ||
59 | ftagd [$r10] | ||
60 | addq 32, $r10 | ||
61 | ftagd [$r10] | ||
62 | addq 32, $r10 | ||
63 | ftagd [$r10] | ||
64 | addq 32, $r10 | ||
65 | ftagd [$r10] | ||
66 | addq 32, $r10 | ||
67 | ftagd [$r10] | ||
68 | addq 32, $r10 | ||
69 | ftagd [$r10] | ||
70 | addq 32, $r10 | ||
71 | ftagd [$r10] | ||
72 | addq 32, $r10 | ||
73 | ftagd [$r10] | ||
74 | addq 32, $r10 | ||
75 | ftagd [$r10] | ||
76 | addq 32, $r10 | ||
77 | ftagd [$r10] | ||
78 | addq 32, $r10 | ||
79 | ftagd [$r10] | ||
80 | addq 32, $r10 | ||
81 | ba cris_flush_cache_range | ||
82 | sub.d $r12, $r11 | ||
83 | |||
84 | .global cris_flush_cache | ||
85 | cris_flush_cache: | ||
86 | moveq 0, $r10 | ||
87 | cris_flush_line: | ||
88 | move.d 16*1024, $r11 | ||
89 | addq 16, $r10 | ||
90 | cmp.d $r10, $r11 | ||
91 | blt cris_flush_line | ||
92 | fidxd [$r10] | ||
93 | ret | ||
94 | nop | ||