Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mm/proc-feroceon.S: MMU functions for Feroceon |
| 3 | * |
| 4 | * Heavily based on proc-arm926.S |
| 5 | * Maintainer: Assaf Hoffman <hoffman@marvell.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #include <linux/linkage.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <asm/assembler.h> |
Russell King | 5ec9407 | 2008-09-07 19:15:31 +0100 | [diff] [blame] | 25 | #include <asm/hwcap.h> |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 26 | #include <asm/pgtable-hwdef.h> |
| 27 | #include <asm/pgtable.h> |
| 28 | #include <asm/page.h> |
| 29 | #include <asm/ptrace.h> |
| 30 | #include "proc-macros.S" |
| 31 | |
| 32 | /* |
| 33 | * This is the maximum size of an area which will be invalidated |
| 34 | * using the single invalidate entry instructions. Anything larger |
| 35 | * than this, and we go for the whole cache. |
| 36 | * |
| 37 | * This value should be chosen such that we choose the cheapest |
| 38 | * alternative. |
| 39 | */ |
| 40 | #define CACHE_DLIMIT 16384 |
| 41 | |
| 42 | /* |
| 43 | * the cache line size of the I and D cache |
| 44 | */ |
| 45 | #define CACHE_DLINESIZE 32 |
| 46 | |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 47 | .bss |
| 48 | .align 3 |
| 49 | __cache_params_loc: |
| 50 | .space 8 |
| 51 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 52 | .text |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 53 | __cache_params: |
| 54 | .word __cache_params_loc |
| 55 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 56 | /* |
| 57 | * cpu_feroceon_proc_init() |
| 58 | */ |
| 59 | ENTRY(cpu_feroceon_proc_init) |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 60 | mrc p15, 0, r0, c0, c0, 1 @ read cache type register |
| 61 | ldr r1, __cache_params |
| 62 | mov r2, #(16 << 5) |
| 63 | tst r0, #(1 << 16) @ get way |
| 64 | mov r0, r0, lsr #18 @ get cache size order |
| 65 | movne r3, #((4 - 1) << 30) @ 4-way |
| 66 | and r0, r0, #0xf |
| 67 | moveq r3, #0 @ 1-way |
| 68 | mov r2, r2, lsl r0 @ actual cache size |
| 69 | movne r2, r2, lsr #2 @ turned into # of sets |
| 70 | sub r2, r2, #(1 << 5) |
| 71 | stmia r1, {r2, r3} |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 72 | mov pc, lr |
| 73 | |
| 74 | /* |
| 75 | * cpu_feroceon_proc_fin() |
| 76 | */ |
| 77 | ENTRY(cpu_feroceon_proc_fin) |
| 78 | stmfd sp!, {lr} |
| 79 | mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE |
| 80 | msr cpsr_c, ip |
| 81 | bl feroceon_flush_kern_cache_all |
Lennert Buytenhek | 99c6dc1 | 2008-06-22 22:45:04 +0200 | [diff] [blame] | 82 | |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 83 | #if defined(CONFIG_CACHE_FEROCEON_L2) && \ |
| 84 | !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH) |
Lennert Buytenhek | 99c6dc1 | 2008-06-22 22:45:04 +0200 | [diff] [blame] | 85 | mov r0, #0 |
| 86 | mcr p15, 1, r0, c15, c9, 0 @ clean L2 |
| 87 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 88 | #endif |
| 89 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 90 | mrc p15, 0, r0, c1, c0, 0 @ ctrl register |
| 91 | bic r0, r0, #0x1000 @ ...i............ |
| 92 | bic r0, r0, #0x000e @ ............wca. |
| 93 | mcr p15, 0, r0, c1, c0, 0 @ disable caches |
| 94 | ldmfd sp!, {pc} |
| 95 | |
| 96 | /* |
| 97 | * cpu_feroceon_reset(loc) |
| 98 | * |
| 99 | * Perform a soft reset of the system. Put the CPU into the |
| 100 | * same state as it would be if it had been reset, and branch |
| 101 | * to what would be the reset vector. |
| 102 | * |
| 103 | * loc: location to jump to for soft reset |
| 104 | */ |
| 105 | .align 5 |
| 106 | ENTRY(cpu_feroceon_reset) |
| 107 | mov ip, #0 |
| 108 | mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches |
| 109 | mcr p15, 0, ip, c7, c10, 4 @ drain WB |
| 110 | #ifdef CONFIG_MMU |
| 111 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
| 112 | #endif |
| 113 | mrc p15, 0, ip, c1, c0, 0 @ ctrl register |
| 114 | bic ip, ip, #0x000f @ ............wcam |
| 115 | bic ip, ip, #0x1100 @ ...i...s........ |
| 116 | mcr p15, 0, ip, c1, c0, 0 @ ctrl register |
| 117 | mov pc, r0 |
| 118 | |
| 119 | /* |
| 120 | * cpu_feroceon_do_idle() |
| 121 | * |
| 122 | * Called with IRQs disabled |
| 123 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 124 | .align 5 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 125 | ENTRY(cpu_feroceon_do_idle) |
| 126 | mov r0, #0 |
| 127 | mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer |
| 128 | mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt |
| 129 | mov pc, lr |
| 130 | |
| 131 | /* |
| 132 | * flush_user_cache_all() |
| 133 | * |
| 134 | * Clean and invalidate all cache entries in a particular |
| 135 | * address space. |
| 136 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 137 | .align 5 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 138 | ENTRY(feroceon_flush_user_cache_all) |
| 139 | /* FALLTHROUGH */ |
| 140 | |
| 141 | /* |
| 142 | * flush_kern_cache_all() |
| 143 | * |
| 144 | * Clean and invalidate the entire cache. |
| 145 | */ |
| 146 | ENTRY(feroceon_flush_kern_cache_all) |
| 147 | mov r2, #VM_EXEC |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 148 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 149 | __flush_whole_cache: |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 150 | ldr r1, __cache_params |
| 151 | ldmia r1, {r1, r3} |
| 152 | 1: orr ip, r1, r3 |
| 153 | 2: mcr p15, 0, ip, c7, c14, 2 @ clean + invalidate D set/way |
| 154 | subs ip, ip, #(1 << 30) @ next way |
| 155 | bcs 2b |
| 156 | subs r1, r1, #(1 << 5) @ next set |
| 157 | bcs 1b |
| 158 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 159 | tst r2, #VM_EXEC |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 160 | mov ip, #0 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 161 | mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache |
| 162 | mcrne p15, 0, ip, c7, c10, 4 @ drain WB |
| 163 | mov pc, lr |
| 164 | |
| 165 | /* |
| 166 | * flush_user_cache_range(start, end, flags) |
| 167 | * |
| 168 | * Clean and invalidate a range of cache entries in the |
| 169 | * specified address range. |
| 170 | * |
| 171 | * - start - start address (inclusive) |
| 172 | * - end - end address (exclusive) |
| 173 | * - flags - vm_flags describing address space |
| 174 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 175 | .align 5 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 176 | ENTRY(feroceon_flush_user_cache_range) |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 177 | sub r3, r1, r0 @ calculate total size |
| 178 | cmp r3, #CACHE_DLIMIT |
| 179 | bgt __flush_whole_cache |
| 180 | 1: tst r2, #VM_EXEC |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 181 | mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry |
| 182 | mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry |
| 183 | add r0, r0, #CACHE_DLINESIZE |
| 184 | mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry |
| 185 | mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry |
| 186 | add r0, r0, #CACHE_DLINESIZE |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 187 | cmp r0, r1 |
| 188 | blo 1b |
| 189 | tst r2, #VM_EXEC |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 190 | mov ip, #0 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 191 | mcrne p15, 0, ip, c7, c10, 4 @ drain WB |
| 192 | mov pc, lr |
| 193 | |
| 194 | /* |
| 195 | * coherent_kern_range(start, end) |
| 196 | * |
| 197 | * Ensure coherency between the Icache and the Dcache in the |
| 198 | * region described by start, end. If you have non-snooping |
| 199 | * Harvard caches, you need to implement this function. |
| 200 | * |
| 201 | * - start - virtual start address |
| 202 | * - end - virtual end address |
| 203 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 204 | .align 5 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 205 | ENTRY(feroceon_coherent_kern_range) |
| 206 | /* FALLTHROUGH */ |
| 207 | |
| 208 | /* |
| 209 | * coherent_user_range(start, end) |
| 210 | * |
| 211 | * Ensure coherency between the Icache and the Dcache in the |
| 212 | * region described by start, end. If you have non-snooping |
| 213 | * Harvard caches, you need to implement this function. |
| 214 | * |
| 215 | * - start - virtual start address |
| 216 | * - end - virtual end address |
| 217 | */ |
| 218 | ENTRY(feroceon_coherent_user_range) |
| 219 | bic r0, r0, #CACHE_DLINESIZE - 1 |
| 220 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 221 | mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry |
| 222 | add r0, r0, #CACHE_DLINESIZE |
| 223 | cmp r0, r1 |
| 224 | blo 1b |
| 225 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 226 | mov pc, lr |
| 227 | |
| 228 | /* |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 229 | * flush_kern_dcache_area(void *addr, size_t size) |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 230 | * |
| 231 | * Ensure no D cache aliasing occurs, either with itself or |
| 232 | * the I cache |
| 233 | * |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 234 | * - addr - kernel address |
| 235 | * - size - region size |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 236 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 237 | .align 5 |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 238 | ENTRY(feroceon_flush_kern_dcache_area) |
| 239 | add r1, r0, r1 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 240 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
| 241 | add r0, r0, #CACHE_DLINESIZE |
| 242 | cmp r0, r1 |
| 243 | blo 1b |
| 244 | mov r0, #0 |
| 245 | mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache |
| 246 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 247 | mov pc, lr |
| 248 | |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 249 | .align 5 |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 250 | ENTRY(feroceon_range_flush_kern_dcache_area) |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 251 | mrs r2, cpsr |
| 252 | add r1, r0, #PAGE_SZ - CACHE_DLINESIZE @ top addr is inclusive |
| 253 | orr r3, r2, #PSR_I_BIT |
| 254 | msr cpsr_c, r3 @ disable interrupts |
| 255 | mcr p15, 5, r0, c15, c15, 0 @ D clean/inv range start |
| 256 | mcr p15, 5, r1, c15, c15, 1 @ D clean/inv range top |
| 257 | msr cpsr_c, r2 @ restore interrupts |
| 258 | mov r0, #0 |
| 259 | mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache |
| 260 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 261 | mov pc, lr |
| 262 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 263 | /* |
| 264 | * dma_inv_range(start, end) |
| 265 | * |
| 266 | * Invalidate (discard) the specified virtual address range. |
| 267 | * May not write back any entries. If 'start' or 'end' |
| 268 | * are not cache line aligned, those lines must be written |
| 269 | * back. |
| 270 | * |
| 271 | * - start - virtual start address |
| 272 | * - end - virtual end address |
| 273 | * |
| 274 | * (same as v4wb) |
| 275 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 276 | .align 5 |
Russell King | 702b94b | 2009-11-26 16:24:19 +0000 | [diff] [blame^] | 277 | feroceon_dma_inv_range: |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 278 | tst r0, #CACHE_DLINESIZE - 1 |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 279 | bic r0, r0, #CACHE_DLINESIZE - 1 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 280 | mcrne p15, 0, r0, c7, c10, 1 @ clean D entry |
| 281 | tst r1, #CACHE_DLINESIZE - 1 |
| 282 | mcrne p15, 0, r1, c7, c10, 1 @ clean D entry |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 283 | 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry |
| 284 | add r0, r0, #CACHE_DLINESIZE |
| 285 | cmp r0, r1 |
| 286 | blo 1b |
| 287 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 288 | mov pc, lr |
| 289 | |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 290 | .align 5 |
Russell King | 702b94b | 2009-11-26 16:24:19 +0000 | [diff] [blame^] | 291 | feroceon_range_dma_inv_range: |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 292 | mrs r2, cpsr |
| 293 | tst r0, #CACHE_DLINESIZE - 1 |
| 294 | mcrne p15, 0, r0, c7, c10, 1 @ clean D entry |
| 295 | tst r1, #CACHE_DLINESIZE - 1 |
| 296 | mcrne p15, 0, r1, c7, c10, 1 @ clean D entry |
| 297 | cmp r1, r0 |
| 298 | subne r1, r1, #1 @ top address is inclusive |
| 299 | orr r3, r2, #PSR_I_BIT |
| 300 | msr cpsr_c, r3 @ disable interrupts |
| 301 | mcr p15, 5, r0, c15, c14, 0 @ D inv range start |
| 302 | mcr p15, 5, r1, c15, c14, 1 @ D inv range top |
| 303 | msr cpsr_c, r2 @ restore interrupts |
| 304 | mov pc, lr |
| 305 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 306 | /* |
| 307 | * dma_clean_range(start, end) |
| 308 | * |
| 309 | * Clean the specified virtual address range. |
| 310 | * |
| 311 | * - start - virtual start address |
| 312 | * - end - virtual end address |
| 313 | * |
| 314 | * (same as v4wb) |
| 315 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 316 | .align 5 |
Russell King | 702b94b | 2009-11-26 16:24:19 +0000 | [diff] [blame^] | 317 | feroceon_dma_clean_range: |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 318 | bic r0, r0, #CACHE_DLINESIZE - 1 |
| 319 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 320 | add r0, r0, #CACHE_DLINESIZE |
| 321 | cmp r0, r1 |
| 322 | blo 1b |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 323 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 324 | mov pc, lr |
| 325 | |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 326 | .align 5 |
Russell King | 702b94b | 2009-11-26 16:24:19 +0000 | [diff] [blame^] | 327 | feroceon_range_dma_clean_range: |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 328 | mrs r2, cpsr |
| 329 | cmp r1, r0 |
| 330 | subne r1, r1, #1 @ top address is inclusive |
| 331 | orr r3, r2, #PSR_I_BIT |
| 332 | msr cpsr_c, r3 @ disable interrupts |
| 333 | mcr p15, 5, r0, c15, c13, 0 @ D clean range start |
| 334 | mcr p15, 5, r1, c15, c13, 1 @ D clean range top |
| 335 | msr cpsr_c, r2 @ restore interrupts |
| 336 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 337 | mov pc, lr |
| 338 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 339 | /* |
| 340 | * dma_flush_range(start, end) |
| 341 | * |
| 342 | * Clean and invalidate the specified virtual address range. |
| 343 | * |
| 344 | * - start - virtual start address |
| 345 | * - end - virtual end address |
| 346 | */ |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 347 | .align 5 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 348 | ENTRY(feroceon_dma_flush_range) |
| 349 | bic r0, r0, #CACHE_DLINESIZE - 1 |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 350 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 351 | add r0, r0, #CACHE_DLINESIZE |
| 352 | cmp r0, r1 |
| 353 | blo 1b |
| 354 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 355 | mov pc, lr |
| 356 | |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 357 | .align 5 |
| 358 | ENTRY(feroceon_range_dma_flush_range) |
| 359 | mrs r2, cpsr |
| 360 | cmp r1, r0 |
| 361 | subne r1, r1, #1 @ top address is inclusive |
| 362 | orr r3, r2, #PSR_I_BIT |
| 363 | msr cpsr_c, r3 @ disable interrupts |
| 364 | mcr p15, 5, r0, c15, c15, 0 @ D clean/inv range start |
| 365 | mcr p15, 5, r1, c15, c15, 1 @ D clean/inv range top |
| 366 | msr cpsr_c, r2 @ restore interrupts |
| 367 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 368 | mov pc, lr |
| 369 | |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 370 | /* |
| 371 | * dma_map_area(start, size, dir) |
| 372 | * - start - kernel virtual start address |
| 373 | * - size - size of region |
| 374 | * - dir - DMA direction |
| 375 | */ |
| 376 | ENTRY(feroceon_dma_map_area) |
| 377 | add r1, r1, r0 |
| 378 | cmp r2, #DMA_TO_DEVICE |
| 379 | beq feroceon_dma_clean_range |
| 380 | bcs feroceon_dma_inv_range |
| 381 | b feroceon_dma_flush_range |
| 382 | ENDPROC(feroceon_dma_map_area) |
| 383 | |
| 384 | /* |
| 385 | * dma_map_area(start, size, dir) |
| 386 | * - start - kernel virtual start address |
| 387 | * - size - size of region |
| 388 | * - dir - DMA direction |
| 389 | */ |
| 390 | ENTRY(feroceon_range_dma_map_area) |
| 391 | add r1, r1, r0 |
| 392 | cmp r2, #DMA_TO_DEVICE |
| 393 | beq feroceon_range_dma_clean_range |
| 394 | bcs feroceon_range_dma_inv_range |
| 395 | b feroceon_range_dma_flush_range |
| 396 | ENDPROC(feroceon_range_dma_map_area) |
| 397 | |
| 398 | /* |
| 399 | * dma_unmap_area(start, size, dir) |
| 400 | * - start - kernel virtual start address |
| 401 | * - size - size of region |
| 402 | * - dir - DMA direction |
| 403 | */ |
| 404 | ENTRY(feroceon_dma_unmap_area) |
| 405 | mov pc, lr |
| 406 | ENDPROC(feroceon_dma_unmap_area) |
| 407 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 408 | ENTRY(feroceon_cache_fns) |
| 409 | .long feroceon_flush_kern_cache_all |
| 410 | .long feroceon_flush_user_cache_all |
| 411 | .long feroceon_flush_user_cache_range |
| 412 | .long feroceon_coherent_kern_range |
| 413 | .long feroceon_coherent_user_range |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 414 | .long feroceon_flush_kern_dcache_area |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 415 | .long feroceon_dma_map_area |
| 416 | .long feroceon_dma_unmap_area |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 417 | .long feroceon_dma_flush_range |
| 418 | |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 419 | ENTRY(feroceon_range_cache_fns) |
| 420 | .long feroceon_flush_kern_cache_all |
| 421 | .long feroceon_flush_user_cache_all |
| 422 | .long feroceon_flush_user_cache_range |
| 423 | .long feroceon_coherent_kern_range |
| 424 | .long feroceon_coherent_user_range |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 425 | .long feroceon_range_flush_kern_dcache_area |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 426 | .long feroceon_range_dma_map_area |
| 427 | .long feroceon_dma_unmap_area |
Stanislav Samsonov | 836a805 | 2008-06-03 11:24:40 +0300 | [diff] [blame] | 428 | .long feroceon_range_dma_flush_range |
| 429 | |
Nicolas Pitre | 6b29e68 | 2008-04-25 13:56:32 -0400 | [diff] [blame] | 430 | .align 5 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 431 | ENTRY(cpu_feroceon_dcache_clean_area) |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 432 | #if defined(CONFIG_CACHE_FEROCEON_L2) && \ |
| 433 | !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH) |
Lennert Buytenhek | 99c6dc1 | 2008-06-22 22:45:04 +0200 | [diff] [blame] | 434 | mov r2, r0 |
| 435 | mov r3, r1 |
| 436 | #endif |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 437 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 438 | add r0, r0, #CACHE_DLINESIZE |
| 439 | subs r1, r1, #CACHE_DLINESIZE |
| 440 | bhi 1b |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 441 | #if defined(CONFIG_CACHE_FEROCEON_L2) && \ |
| 442 | !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH) |
Lennert Buytenhek | 99c6dc1 | 2008-06-22 22:45:04 +0200 | [diff] [blame] | 443 | 1: mcr p15, 1, r2, c15, c9, 1 @ clean L2 entry |
| 444 | add r2, r2, #CACHE_DLINESIZE |
| 445 | subs r3, r3, #CACHE_DLINESIZE |
| 446 | bhi 1b |
| 447 | #endif |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 448 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 449 | mov pc, lr |
| 450 | |
| 451 | /* =============================== PageTable ============================== */ |
| 452 | |
| 453 | /* |
| 454 | * cpu_feroceon_switch_mm(pgd) |
| 455 | * |
| 456 | * Set the translation base pointer to be as described by pgd. |
| 457 | * |
| 458 | * pgd: new page tables |
| 459 | */ |
| 460 | .align 5 |
| 461 | ENTRY(cpu_feroceon_switch_mm) |
| 462 | #ifdef CONFIG_MMU |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 463 | /* |
| 464 | * Note: we wish to call __flush_whole_cache but we need to preserve |
| 465 | * lr to do so. The only way without touching main memory is to |
| 466 | * use r2 which is normally used to test the VM_EXEC flag, and |
| 467 | * compensate locally for the skipped ops if it is not set. |
| 468 | */ |
| 469 | mov r2, lr @ abuse r2 to preserve lr |
| 470 | bl __flush_whole_cache |
| 471 | @ if r2 contains the VM_EXEC bit then the next 2 ops are done already |
| 472 | tst r2, #VM_EXEC |
| 473 | mcreq p15, 0, ip, c7, c5, 0 @ invalidate I cache |
| 474 | mcreq p15, 0, ip, c7, c10, 4 @ drain WB |
| 475 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 476 | mcr p15, 0, r0, c2, c0, 0 @ load page table pointer |
| 477 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 478 | mov pc, r2 |
| 479 | #else |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 480 | mov pc, lr |
Nicolas Pitre | 6c386e5 | 2008-04-24 02:04:54 +0200 | [diff] [blame] | 481 | #endif |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 482 | |
| 483 | /* |
| 484 | * cpu_feroceon_set_pte_ext(ptep, pte, ext) |
| 485 | * |
| 486 | * Set a PTE and flush it out |
| 487 | */ |
| 488 | .align 5 |
| 489 | ENTRY(cpu_feroceon_set_pte_ext) |
| 490 | #ifdef CONFIG_MMU |
Russell King | da09165 | 2008-09-06 17:19:08 +0100 | [diff] [blame] | 491 | armv3_set_pte_ext wc_disable=0 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 492 | mov r0, r0 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 493 | mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
Ronen Shitrit | 4360bb4 | 2008-09-23 15:28:10 +0300 | [diff] [blame] | 494 | #if defined(CONFIG_CACHE_FEROCEON_L2) && \ |
| 495 | !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH) |
Lennert Buytenhek | 99c6dc1 | 2008-06-22 22:45:04 +0200 | [diff] [blame] | 496 | mcr p15, 1, r0, c15, c9, 1 @ clean L2 entry |
| 497 | #endif |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 498 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
| 499 | #endif |
| 500 | mov pc, lr |
| 501 | |
| 502 | __INIT |
| 503 | |
| 504 | .type __feroceon_setup, #function |
| 505 | __feroceon_setup: |
| 506 | mov r0, #0 |
| 507 | mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 |
| 508 | mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 |
| 509 | #ifdef CONFIG_MMU |
| 510 | mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 |
| 511 | #endif |
| 512 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 513 | adr r5, feroceon_crval |
| 514 | ldmia r5, {r5, r6} |
| 515 | mrc p15, 0, r0, c1, c0 @ get control register v4 |
| 516 | bic r0, r0, r5 |
| 517 | orr r0, r0, r6 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 518 | mov pc, lr |
| 519 | .size __feroceon_setup, . - __feroceon_setup |
| 520 | |
| 521 | /* |
Saeed Bishara | 188237e | 2008-07-02 06:06:32 -1100 | [diff] [blame] | 522 | * B |
| 523 | * R P |
| 524 | * .RVI UFRS BLDP WCAM |
| 525 | * .011 .001 ..11 0101 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 526 | * |
| 527 | */ |
| 528 | .type feroceon_crval, #object |
| 529 | feroceon_crval: |
Saeed Bishara | 188237e | 2008-07-02 06:06:32 -1100 | [diff] [blame] | 530 | crval clear=0x0000773f, mmuset=0x00003135, ucset=0x00001134 |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 531 | |
| 532 | __INITDATA |
| 533 | |
| 534 | /* |
| 535 | * Purpose : Function pointers used to access above functions - all calls |
| 536 | * come through these |
| 537 | */ |
| 538 | .type feroceon_processor_functions, #object |
| 539 | feroceon_processor_functions: |
| 540 | .word v5t_early_abort |
Kirill A. Shutemov | 4fb2847 | 2009-09-25 13:39:47 +0100 | [diff] [blame] | 541 | .word legacy_pabort |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 542 | .word cpu_feroceon_proc_init |
| 543 | .word cpu_feroceon_proc_fin |
| 544 | .word cpu_feroceon_reset |
| 545 | .word cpu_feroceon_do_idle |
| 546 | .word cpu_feroceon_dcache_clean_area |
| 547 | .word cpu_feroceon_switch_mm |
| 548 | .word cpu_feroceon_set_pte_ext |
| 549 | .size feroceon_processor_functions, . - feroceon_processor_functions |
| 550 | |
| 551 | .section ".rodata" |
| 552 | |
| 553 | .type cpu_arch_name, #object |
| 554 | cpu_arch_name: |
| 555 | .asciz "armv5te" |
| 556 | .size cpu_arch_name, . - cpu_arch_name |
| 557 | |
| 558 | .type cpu_elf_name, #object |
| 559 | cpu_elf_name: |
| 560 | .asciz "v5" |
| 561 | .size cpu_elf_name, . - cpu_elf_name |
| 562 | |
| 563 | .type cpu_feroceon_name, #object |
| 564 | cpu_feroceon_name: |
| 565 | .asciz "Feroceon" |
| 566 | .size cpu_feroceon_name, . - cpu_feroceon_name |
| 567 | |
Lennert Buytenhek | ee0dd84 | 2008-04-11 23:08:26 +0200 | [diff] [blame] | 568 | .type cpu_88fr531_name, #object |
| 569 | cpu_88fr531_name: |
| 570 | .asciz "Feroceon 88FR531-vd" |
| 571 | .size cpu_88fr531_name, . - cpu_88fr531_name |
| 572 | |
Lennert Buytenhek | 0a17c7b | 2008-06-22 22:45:08 +0200 | [diff] [blame] | 573 | .type cpu_88fr571_name, #object |
| 574 | cpu_88fr571_name: |
| 575 | .asciz "Feroceon 88FR571-vd" |
| 576 | .size cpu_88fr571_name, . - cpu_88fr571_name |
| 577 | |
Lennert Buytenhek | 9c2af6c | 2008-06-22 22:45:05 +0200 | [diff] [blame] | 578 | .type cpu_88fr131_name, #object |
| 579 | cpu_88fr131_name: |
| 580 | .asciz "Feroceon 88FR131" |
| 581 | .size cpu_88fr131_name, . - cpu_88fr131_name |
| 582 | |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 583 | .align |
| 584 | |
| 585 | .section ".proc.info.init", #alloc, #execinstr |
| 586 | |
Tzachi Perelstein | d910a0a | 2007-11-06 10:35:40 +0200 | [diff] [blame] | 587 | #ifdef CONFIG_CPU_FEROCEON_OLD_ID |
| 588 | .type __feroceon_old_id_proc_info,#object |
| 589 | __feroceon_old_id_proc_info: |
Ke Wei | ab6d15d | 2008-06-22 22:45:00 +0200 | [diff] [blame] | 590 | .long 0x41009260 |
| 591 | .long 0xff00fff0 |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 592 | .long PMD_TYPE_SECT | \ |
Tzachi Perelstein | d910a0a | 2007-11-06 10:35:40 +0200 | [diff] [blame] | 593 | PMD_SECT_BUFFERABLE | \ |
| 594 | PMD_SECT_CACHEABLE | \ |
| 595 | PMD_BIT4 | \ |
| 596 | PMD_SECT_AP_WRITE | \ |
| 597 | PMD_SECT_AP_READ |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 598 | .long PMD_TYPE_SECT | \ |
Tzachi Perelstein | d910a0a | 2007-11-06 10:35:40 +0200 | [diff] [blame] | 599 | PMD_BIT4 | \ |
| 600 | PMD_SECT_AP_WRITE | \ |
| 601 | PMD_SECT_AP_READ |
| 602 | b __feroceon_setup |
| 603 | .long cpu_arch_name |
| 604 | .long cpu_elf_name |
| 605 | .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP |
| 606 | .long cpu_feroceon_name |
| 607 | .long feroceon_processor_functions |
| 608 | .long v4wbi_tlb_fns |
Lennert Buytenhek | 0ed1507 | 2008-04-24 01:31:45 -0400 | [diff] [blame] | 609 | .long feroceon_user_fns |
Tzachi Perelstein | d910a0a | 2007-11-06 10:35:40 +0200 | [diff] [blame] | 610 | .long feroceon_cache_fns |
| 611 | .size __feroceon_old_id_proc_info, . - __feroceon_old_id_proc_info |
| 612 | #endif |
| 613 | |
Lennert Buytenhek | ee0dd84 | 2008-04-11 23:08:26 +0200 | [diff] [blame] | 614 | .type __88fr531_proc_info,#object |
| 615 | __88fr531_proc_info: |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 616 | .long 0x56055310 |
| 617 | .long 0xfffffff0 |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 618 | .long PMD_TYPE_SECT | \ |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 619 | PMD_SECT_BUFFERABLE | \ |
| 620 | PMD_SECT_CACHEABLE | \ |
| 621 | PMD_BIT4 | \ |
| 622 | PMD_SECT_AP_WRITE | \ |
| 623 | PMD_SECT_AP_READ |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 624 | .long PMD_TYPE_SECT | \ |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 625 | PMD_BIT4 | \ |
| 626 | PMD_SECT_AP_WRITE | \ |
| 627 | PMD_SECT_AP_READ |
| 628 | b __feroceon_setup |
| 629 | .long cpu_arch_name |
| 630 | .long cpu_elf_name |
| 631 | .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP |
Lennert Buytenhek | ee0dd84 | 2008-04-11 23:08:26 +0200 | [diff] [blame] | 632 | .long cpu_88fr531_name |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 633 | .long feroceon_processor_functions |
| 634 | .long v4wbi_tlb_fns |
Lennert Buytenhek | 0ed1507 | 2008-04-24 01:31:45 -0400 | [diff] [blame] | 635 | .long feroceon_user_fns |
Assaf Hoffman | e50d640 | 2007-10-23 15:14:41 -0400 | [diff] [blame] | 636 | .long feroceon_cache_fns |
Lennert Buytenhek | ee0dd84 | 2008-04-11 23:08:26 +0200 | [diff] [blame] | 637 | .size __88fr531_proc_info, . - __88fr531_proc_info |
Lennert Buytenhek | 9c2af6c | 2008-06-22 22:45:05 +0200 | [diff] [blame] | 638 | |
Lennert Buytenhek | 0a17c7b | 2008-06-22 22:45:08 +0200 | [diff] [blame] | 639 | .type __88fr571_proc_info,#object |
| 640 | __88fr571_proc_info: |
| 641 | .long 0x56155710 |
| 642 | .long 0xfffffff0 |
| 643 | .long PMD_TYPE_SECT | \ |
| 644 | PMD_SECT_BUFFERABLE | \ |
| 645 | PMD_SECT_CACHEABLE | \ |
| 646 | PMD_BIT4 | \ |
| 647 | PMD_SECT_AP_WRITE | \ |
| 648 | PMD_SECT_AP_READ |
| 649 | .long PMD_TYPE_SECT | \ |
| 650 | PMD_BIT4 | \ |
| 651 | PMD_SECT_AP_WRITE | \ |
| 652 | PMD_SECT_AP_READ |
| 653 | b __feroceon_setup |
| 654 | .long cpu_arch_name |
| 655 | .long cpu_elf_name |
| 656 | .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP |
| 657 | .long cpu_88fr571_name |
| 658 | .long feroceon_processor_functions |
| 659 | .long v4wbi_tlb_fns |
| 660 | .long feroceon_user_fns |
| 661 | .long feroceon_range_cache_fns |
| 662 | .size __88fr571_proc_info, . - __88fr571_proc_info |
| 663 | |
Lennert Buytenhek | 9c2af6c | 2008-06-22 22:45:05 +0200 | [diff] [blame] | 664 | .type __88fr131_proc_info,#object |
| 665 | __88fr131_proc_info: |
| 666 | .long 0x56251310 |
| 667 | .long 0xfffffff0 |
| 668 | .long PMD_TYPE_SECT | \ |
| 669 | PMD_SECT_BUFFERABLE | \ |
| 670 | PMD_SECT_CACHEABLE | \ |
| 671 | PMD_BIT4 | \ |
| 672 | PMD_SECT_AP_WRITE | \ |
| 673 | PMD_SECT_AP_READ |
| 674 | .long PMD_TYPE_SECT | \ |
| 675 | PMD_BIT4 | \ |
| 676 | PMD_SECT_AP_WRITE | \ |
| 677 | PMD_SECT_AP_READ |
| 678 | b __feroceon_setup |
| 679 | .long cpu_arch_name |
| 680 | .long cpu_elf_name |
| 681 | .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP |
| 682 | .long cpu_88fr131_name |
| 683 | .long feroceon_processor_functions |
| 684 | .long v4wbi_tlb_fns |
| 685 | .long feroceon_user_fns |
| 686 | .long feroceon_range_cache_fns |
| 687 | .size __88fr131_proc_info, . - __88fr131_proc_info |