blob: 7824cf6e14a381579282c258ee0e0a4d6a123722 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mm/cache-v4.S
3 *
4 * Copyright (C) 1997-2002 Russell king
5 *
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.
9 */
10#include <linux/linkage.h>
11#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/page.h>
13#include "proc-macros.S"
14
15/*
Mika Westerbergc8c90862010-10-28 11:27:40 +010016 * flush_icache_all()
17 *
18 * Unconditionally clean and invalidate the entire icache.
19 */
20ENTRY(v4_flush_icache_all)
21 mov pc, lr
22ENDPROC(v4_flush_icache_all)
23
24/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 * flush_user_cache_all()
26 *
27 * Invalidate all cache entries in a particular address
28 * space.
29 *
30 * - mm - mm_struct describing address space
31 */
32ENTRY(v4_flush_user_cache_all)
33 /* FALLTHROUGH */
34/*
35 * flush_kern_cache_all()
36 *
37 * Clean and invalidate the entire cache.
38 */
39ENTRY(v4_flush_kern_cache_all)
Anders Grafströme4d2a592008-10-16 17:37:24 +010040#ifdef CONFIG_CPU_CP15
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 mov r0, #0
42 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache
43 mov pc, lr
Hyok S. Choif12d0d72006-09-26 17:36:37 +090044#else
45 /* FALLTHROUGH */
46#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48/*
49 * flush_user_cache_range(start, end, flags)
50 *
51 * Invalidate a range of cache entries in the specified
52 * address space.
53 *
54 * - start - start address (may not be aligned)
55 * - end - end address (exclusive, may not be aligned)
56 * - flags - vma_area_struct flags describing address space
57 */
58ENTRY(v4_flush_user_cache_range)
Anders Grafströme4d2a592008-10-16 17:37:24 +010059#ifdef CONFIG_CPU_CP15
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 mov ip, #0
61 mcreq p15, 0, ip, c7, c7, 0 @ flush ID cache
62 mov pc, lr
Hyok S. Choif12d0d72006-09-26 17:36:37 +090063#else
64 /* FALLTHROUGH */
65#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67/*
68 * coherent_kern_range(start, end)
69 *
70 * Ensure coherency between the Icache and the Dcache in the
71 * region described by start. If you have non-snooping
72 * Harvard caches, you need to implement this function.
73 *
74 * - start - virtual start address
75 * - end - virtual end address
76 */
77ENTRY(v4_coherent_kern_range)
78 /* FALLTHROUGH */
79
80/*
81 * coherent_user_range(start, end)
82 *
83 * Ensure coherency between the Icache and the Dcache in the
84 * region described by start. If you have non-snooping
85 * Harvard caches, you need to implement this function.
86 *
87 * - start - virtual start address
88 * - end - virtual end address
89 */
90ENTRY(v4_coherent_user_range)
91 mov pc, lr
92
93/*
Russell King2c9b9c82009-11-26 12:56:21 +000094 * flush_kern_dcache_area(void *addr, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 *
96 * Ensure no D cache aliasing occurs, either with itself or
97 * the I cache
98 *
Russell King2c9b9c82009-11-26 12:56:21 +000099 * - addr - kernel address
100 * - size - region size
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 */
Russell King2c9b9c82009-11-26 12:56:21 +0000102ENTRY(v4_flush_kern_dcache_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 /* FALLTHROUGH */
104
105/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106 * dma_inv_range(start, end)
107 *
108 * Invalidate (discard) the specified virtual address range.
109 * May not write back any entries. If 'start' or 'end'
110 * are not cache line aligned, those lines must be written
111 * back.
112 *
113 * - start - virtual start address
114 * - end - virtual end address
115 */
116ENTRY(v4_dma_inv_range)
117 /* FALLTHROUGH */
118
119/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 * dma_flush_range(start, end)
121 *
122 * Clean and invalidate the specified virtual address range.
123 *
124 * - start - virtual start address
125 * - end - virtual end address
126 */
127ENTRY(v4_dma_flush_range)
Anders Grafströme4d2a592008-10-16 17:37:24 +0100128#ifdef CONFIG_CPU_CP15
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 mov r0, #0
130 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache
Hyok S. Choif12d0d72006-09-26 17:36:37 +0900131#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132 /* FALLTHROUGH */
133
134/*
135 * dma_clean_range(start, end)
136 *
137 * Clean (write back) the specified virtual address range.
138 *
139 * - start - virtual start address
140 * - end - virtual end address
141 */
142ENTRY(v4_dma_clean_range)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 mov pc, lr
144
Russell Kinga9c91472009-11-26 16:19:58 +0000145/*
146 * dma_unmap_area(start, size, dir)
147 * - start - kernel virtual start address
148 * - size - size of region
149 * - dir - DMA direction
150 */
151ENTRY(v4_dma_unmap_area)
152 teq r2, #DMA_TO_DEVICE
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153 bne v4_dma_inv_range
Russell Kinga9c91472009-11-26 16:19:58 +0000154 /* FALLTHROUGH */
155
156/*
157 * dma_map_area(start, size, dir)
158 * - start - kernel virtual start address
159 * - size - size of region
160 * - dir - DMA direction
161 */
162ENTRY(v4_dma_map_area)
163 mov pc, lr
164ENDPROC(v4_dma_unmap_area)
165ENDPROC(v4_dma_map_area)
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 __INITDATA
168
169 .type v4_cache_fns, #object
170ENTRY(v4_cache_fns)
Mika Westerbergc8c90862010-10-28 11:27:40 +0100171 .long v4_flush_icache_all
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 .long v4_flush_kern_cache_all
173 .long v4_flush_user_cache_all
174 .long v4_flush_user_cache_range
175 .long v4_coherent_kern_range
176 .long v4_coherent_user_range
Russell King2c9b9c82009-11-26 12:56:21 +0000177 .long v4_flush_kern_dcache_area
Russell Kinga9c91472009-11-26 16:19:58 +0000178 .long v4_dma_map_area
179 .long v4_dma_unmap_area
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700180 .long v4_dma_inv_range
181 .long v4_dma_clean_range
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 .long v4_dma_flush_range
183 .size v4_cache_fns, . - v4_cache_fns