Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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> |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 12 | #include <asm/assembler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/page.h> |
| 14 | #include "proc-macros.S" |
| 15 | |
| 16 | /* |
Mika Westerberg | c8c9086 | 2010-10-28 11:27:40 +0100 | [diff] [blame] | 17 | * flush_icache_all() |
| 18 | * |
| 19 | * Unconditionally clean and invalidate the entire icache. |
| 20 | */ |
| 21 | ENTRY(v4_flush_icache_all) |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 22 | ret lr |
Mika Westerberg | c8c9086 | 2010-10-28 11:27:40 +0100 | [diff] [blame] | 23 | ENDPROC(v4_flush_icache_all) |
| 24 | |
| 25 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | * flush_user_cache_all() |
| 27 | * |
| 28 | * Invalidate all cache entries in a particular address |
| 29 | * space. |
| 30 | * |
| 31 | * - mm - mm_struct describing address space |
| 32 | */ |
| 33 | ENTRY(v4_flush_user_cache_all) |
| 34 | /* FALLTHROUGH */ |
| 35 | /* |
| 36 | * flush_kern_cache_all() |
| 37 | * |
| 38 | * Clean and invalidate the entire cache. |
| 39 | */ |
| 40 | ENTRY(v4_flush_kern_cache_all) |
Anders Grafström | e4d2a59 | 2008-10-16 17:37:24 +0100 | [diff] [blame] | 41 | #ifdef CONFIG_CPU_CP15 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | mov r0, #0 |
| 43 | mcr p15, 0, r0, c7, c7, 0 @ flush ID cache |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 44 | ret lr |
Hyok S. Choi | f12d0d7 | 2006-09-26 17:36:37 +0900 | [diff] [blame] | 45 | #else |
| 46 | /* FALLTHROUGH */ |
| 47 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * flush_user_cache_range(start, end, flags) |
| 51 | * |
| 52 | * Invalidate a range of cache entries in the specified |
| 53 | * address space. |
| 54 | * |
| 55 | * - start - start address (may not be aligned) |
| 56 | * - end - end address (exclusive, may not be aligned) |
| 57 | * - flags - vma_area_struct flags describing address space |
| 58 | */ |
| 59 | ENTRY(v4_flush_user_cache_range) |
Anders Grafström | e4d2a59 | 2008-10-16 17:37:24 +0100 | [diff] [blame] | 60 | #ifdef CONFIG_CPU_CP15 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | mov ip, #0 |
Will Deacon | 794fe85 | 2013-01-22 19:11:38 +0000 | [diff] [blame] | 62 | mcr p15, 0, ip, c7, c7, 0 @ flush ID cache |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 63 | ret lr |
Hyok S. Choi | f12d0d7 | 2006-09-26 17:36:37 +0900 | [diff] [blame] | 64 | #else |
| 65 | /* FALLTHROUGH */ |
| 66 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | /* |
| 69 | * coherent_kern_range(start, end) |
| 70 | * |
| 71 | * Ensure coherency between the Icache and the Dcache in the |
| 72 | * region described by start. If you have non-snooping |
| 73 | * Harvard caches, you need to implement this function. |
| 74 | * |
| 75 | * - start - virtual start address |
| 76 | * - end - virtual end address |
| 77 | */ |
| 78 | ENTRY(v4_coherent_kern_range) |
| 79 | /* FALLTHROUGH */ |
| 80 | |
| 81 | /* |
| 82 | * coherent_user_range(start, end) |
| 83 | * |
| 84 | * Ensure coherency between the Icache and the Dcache in the |
| 85 | * region described by start. If you have non-snooping |
| 86 | * Harvard caches, you need to implement this function. |
| 87 | * |
| 88 | * - start - virtual start address |
| 89 | * - end - virtual end address |
| 90 | */ |
| 91 | ENTRY(v4_coherent_user_range) |
Will Deacon | c5102f5 | 2012-04-27 13:08:53 +0100 | [diff] [blame] | 92 | mov r0, #0 |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 93 | ret lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | /* |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 96 | * flush_kern_dcache_area(void *addr, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | * |
| 98 | * Ensure no D cache aliasing occurs, either with itself or |
| 99 | * the I cache |
| 100 | * |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 101 | * - addr - kernel address |
| 102 | * - size - region size |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | */ |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 104 | ENTRY(v4_flush_kern_dcache_area) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | /* FALLTHROUGH */ |
| 106 | |
| 107 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | * dma_flush_range(start, end) |
| 109 | * |
| 110 | * Clean and invalidate the specified virtual address range. |
| 111 | * |
| 112 | * - start - virtual start address |
| 113 | * - end - virtual end address |
| 114 | */ |
| 115 | ENTRY(v4_dma_flush_range) |
Anders Grafström | e4d2a59 | 2008-10-16 17:37:24 +0100 | [diff] [blame] | 116 | #ifdef CONFIG_CPU_CP15 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | mov r0, #0 |
| 118 | mcr p15, 0, r0, c7, c7, 0 @ flush ID cache |
Hyok S. Choi | f12d0d7 | 2006-09-26 17:36:37 +0900 | [diff] [blame] | 119 | #endif |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 120 | ret lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 122 | /* |
| 123 | * dma_unmap_area(start, size, dir) |
| 124 | * - start - kernel virtual start address |
| 125 | * - size - size of region |
| 126 | * - dir - DMA direction |
| 127 | */ |
| 128 | ENTRY(v4_dma_unmap_area) |
| 129 | teq r2, #DMA_TO_DEVICE |
Russell King | 702b94b | 2009-11-26 16:24:19 +0000 | [diff] [blame] | 130 | bne v4_dma_flush_range |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 131 | /* FALLTHROUGH */ |
| 132 | |
| 133 | /* |
| 134 | * dma_map_area(start, size, dir) |
| 135 | * - start - kernel virtual start address |
| 136 | * - size - size of region |
| 137 | * - dir - DMA direction |
| 138 | */ |
| 139 | ENTRY(v4_dma_map_area) |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 140 | ret lr |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 141 | ENDPROC(v4_dma_unmap_area) |
| 142 | ENDPROC(v4_dma_map_area) |
| 143 | |
Lorenzo Pieralisi | 031bd87 | 2012-09-06 18:35:13 +0530 | [diff] [blame] | 144 | .globl v4_flush_kern_cache_louis |
| 145 | .equ v4_flush_kern_cache_louis, v4_flush_kern_cache_all |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | __INITDATA |
| 148 | |
Dave Martin | 54d4e9e | 2011-06-23 17:14:52 +0100 | [diff] [blame] | 149 | @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S) |
| 150 | define_cache_functions v4 |