2 * linux/arch/arm/mm/cache-v4wb.S
4 * Copyright (C) 1997-2002 Russell king
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/config.h>
11 #include <linux/linkage.h>
12 #include <linux/init.h>
13 #include <asm/hardware.h>
15 #include "proc-macros.S"
18 * The size of one data cache line.
20 // following mask by Victor Yu. 06-08-2005
22 #define CACHE_DLINESIZE 32
23 // following add by Victor Yu. 06-08-2005
25 #define CACHE_DLINESIZE 16
29 * The total size of the data cache.
31 #if defined(CONFIG_CPU_SA110)
32 # define CACHE_DSIZE 16384
33 #elif defined(CONFIG_CPU_SA1100)
34 # define CACHE_DSIZE 8192
35 // following add by Victor Yu. 06-08-2005
36 #elif defined(CONFIG_CPU_ARM922T)
37 # define CACHE_DSIZE 16384
38 // above add by Victor Yu. 06-08-2005
40 # error Unknown cache size
44 * This is the size at which it becomes more efficient to
45 * clean the whole cache, rather than using the individual
46 * cache line maintainence instructions.
48 * Size Clean (ticks) Dirty (ticks)
49 * 4096 21 20 21 53 55 54
50 * 8192 40 41 40 106 100 102
51 * 16384 77 77 76 140 140 138
52 * 32768 150 149 150 214 216 212 <---
53 * 65536 296 297 296 351 358 361
54 * 131072 591 591 591 656 657 651
55 * Whole 132 136 132 221 217 207 <---
57 #define CACHE_DLIMIT (CACHE_DSIZE * 4)
60 * flush_user_cache_all()
62 * Clean and invalidate all cache entries in a particular address
65 ENTRY(v4wb_flush_user_cache_all)
68 * flush_kern_cache_all()
70 * Clean and invalidate the entire cache.
72 ENTRY(v4wb_flush_kern_cache_all)
74 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
77 add r1, r0, #CACHE_DSIZE
81 mcr p15, 0, ip, c7, c10, 4 @ drain write buffer
85 * flush_user_cache_range(start, end, flags)
87 * Invalidate a range of cache entries in the specified
90 * - start - start address (inclusive, page aligned)
91 * - end - end address (exclusive, page aligned)
92 * - flags - vma_area_struct flags describing address space
94 ENTRY(v4wb_flush_user_cache_range)
95 sub r3, r1, r0 @ calculate total size
96 tst r2, #VM_EXEC @ executable region?
97 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
99 cmp r3, #CACHE_DLIMIT @ total size >= limit?
100 bhs __flush_whole_cache @ flush whole D cache
102 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
103 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
104 add r0, r0, #CACHE_DLINESIZE
108 mcrne p15, 0, ip, c7, c10, 4 @ drain write buffer
112 * flush_kern_dcache_page(void *page)
114 * Ensure no D cache aliasing occurs, either with itself or
117 * - addr - page aligned address
119 ENTRY(v4wb_flush_kern_dcache_page)
124 * coherent_kern_range(start, end)
126 * Ensure coherency between the Icache and the Dcache in the
127 * region described by start. If you have non-snooping
128 * Harvard caches, you need to implement this function.
130 * - start - virtual start address
131 * - end - virtual end address
133 ENTRY(v4wb_coherent_kern_range)
137 * coherent_user_range(start, end)
139 * Ensure coherency between the Icache and the Dcache in the
140 * region described by start. If you have non-snooping
141 * Harvard caches, you need to implement this function.
143 * - start - virtual start address
144 * - end - virtual end address
146 ENTRY(v4wb_coherent_user_range)
147 bic r0, r0, #CACHE_DLINESIZE - 1
148 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
149 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
150 add r0, r0, #CACHE_DLINESIZE
154 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
155 mcr p15, 0, ip, c7, c10, 4 @ drain WB
160 * dma_inv_range(start, end)
162 * Invalidate (discard) the specified virtual address range.
163 * May not write back any entries. If 'start' or 'end'
164 * are not cache line aligned, those lines must be written
167 * - start - virtual start address
168 * - end - virtual end address
170 ENTRY(v4wb_dma_inv_range)
171 tst r0, #CACHE_DLINESIZE - 1
172 bic r0, r0, #CACHE_DLINESIZE - 1
173 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
174 tst r1, #CACHE_DLINESIZE - 1
175 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
176 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
177 add r0, r0, #CACHE_DLINESIZE
180 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
184 * dma_clean_range(start, end)
186 * Clean (write back) the specified virtual address range.
188 * - start - virtual start address
189 * - end - virtual end address
191 ENTRY(v4wb_dma_clean_range)
192 bic r0, r0, #CACHE_DLINESIZE - 1
193 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
194 add r0, r0, #CACHE_DLINESIZE
197 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
201 * dma_flush_range(start, end)
203 * Clean and invalidate the specified virtual address range.
205 * - start - virtual start address
206 * - end - virtual end address
208 * This is actually the same as v4wb_coherent_kern_range()
210 .globl v4wb_dma_flush_range
211 .set v4wb_dma_flush_range, v4wb_coherent_kern_range
215 .type v4wb_cache_fns, #object
216 ENTRY(v4wb_cache_fns)
217 .long v4wb_flush_kern_cache_all
218 .long v4wb_flush_user_cache_all
219 .long v4wb_flush_user_cache_range
220 .long v4wb_coherent_kern_range
221 .long v4wb_coherent_user_range
222 .long v4wb_flush_kern_dcache_page
223 .long v4wb_dma_inv_range
224 .long v4wb_dma_clean_range
225 .long v4wb_dma_flush_range
226 .size v4wb_cache_fns, . - v4wb_cache_fns