Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mm/proc-xscale.S |
| 3 | * |
| 4 | * Author: Nicolas Pitre |
| 5 | * Created: November 2000 |
| 6 | * Copyright: (C) 2000, 2001 MontaVista Software Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * MMU functions for the Intel XScale CPUs |
| 13 | * |
| 14 | * 2001 Aug 21: |
| 15 | * some contributions by Brett Gaines <brett.w.gaines@intel.com> |
| 16 | * Copyright 2001 by Intel Corp. |
| 17 | * |
| 18 | * 2001 Sep 08: |
| 19 | * Completely revisited, many important fixes |
Nicolas Pitre | 2f82af0 | 2009-09-14 03:25:28 -0400 | [diff] [blame] | 20 | * Nicolas Pitre <nico@fluxnic.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #include <linux/linkage.h> |
| 24 | #include <linux/init.h> |
| 25 | #include <asm/assembler.h> |
Russell King | 5ec9407 | 2008-09-07 19:15:31 +0100 | [diff] [blame] | 26 | #include <asm/hwcap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <asm/pgtable.h> |
Russell King | 0003ced | 2006-03-25 22:08:55 +0000 | [diff] [blame] | 28 | #include <asm/pgtable-hwdef.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <asm/page.h> |
| 30 | #include <asm/ptrace.h> |
| 31 | #include "proc-macros.S" |
| 32 | |
| 33 | /* |
| 34 | * This is the maximum size of an area which will be flushed. If the area |
| 35 | * is larger than this, then we flush the whole cache |
| 36 | */ |
| 37 | #define MAX_AREA_SIZE 32768 |
| 38 | |
| 39 | /* |
| 40 | * the cache line size of the I and D cache |
| 41 | */ |
| 42 | #define CACHELINESIZE 32 |
| 43 | |
| 44 | /* |
| 45 | * the size of the data cache |
| 46 | */ |
| 47 | #define CACHESIZE 32768 |
| 48 | |
| 49 | /* |
| 50 | * Virtual address used to allocate the cache when flushed |
| 51 | * |
| 52 | * This must be an address range which is _never_ used. It should |
| 53 | * apparently have a mapping in the corresponding page table for |
| 54 | * compatibility with future CPUs that _could_ require it. For instance we |
| 55 | * don't care. |
| 56 | * |
| 57 | * This must be aligned on a 2*CACHESIZE boundary. The code selects one of |
| 58 | * the 2 areas in alternance each time the clean_d_cache macro is used. |
| 59 | * Without this the XScale core exhibits cache eviction problems and no one |
| 60 | * knows why. |
| 61 | * |
| 62 | * Reminder: the vector table is located at 0xffff0000-0xffff0fff. |
| 63 | */ |
| 64 | #define CLEAN_ADDR 0xfffe0000 |
| 65 | |
| 66 | /* |
| 67 | * This macro is used to wait for a CP15 write and is needed |
| 68 | * when we have to ensure that the last operation to the co-pro |
| 69 | * was completed before continuing with operation. |
| 70 | */ |
| 71 | .macro cpwait, rd |
| 72 | mrc p15, 0, \rd, c2, c0, 0 @ arbitrary read of cp15 |
| 73 | mov \rd, \rd @ wait for completion |
| 74 | sub pc, pc, #4 @ flush instruction pipeline |
| 75 | .endm |
| 76 | |
| 77 | .macro cpwait_ret, lr, rd |
| 78 | mrc p15, 0, \rd, c2, c0, 0 @ arbitrary read of cp15 |
| 79 | sub pc, \lr, \rd, LSR #32 @ wait for completion and |
| 80 | @ flush instruction pipeline |
| 81 | .endm |
| 82 | |
| 83 | /* |
| 84 | * This macro cleans the entire dcache using line allocate. |
| 85 | * The main loop has been unrolled to reduce loop overhead. |
| 86 | * rd and rs are two scratch registers. |
| 87 | */ |
| 88 | .macro clean_d_cache, rd, rs |
| 89 | ldr \rs, =clean_addr |
| 90 | ldr \rd, [\rs] |
| 91 | eor \rd, \rd, #CACHESIZE |
| 92 | str \rd, [\rs] |
| 93 | add \rs, \rd, #CACHESIZE |
| 94 | 1: mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line |
| 95 | add \rd, \rd, #CACHELINESIZE |
| 96 | mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line |
| 97 | add \rd, \rd, #CACHELINESIZE |
| 98 | mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line |
| 99 | add \rd, \rd, #CACHELINESIZE |
| 100 | mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line |
| 101 | add \rd, \rd, #CACHELINESIZE |
| 102 | teq \rd, \rs |
| 103 | bne 1b |
| 104 | .endm |
| 105 | |
| 106 | .data |
| 107 | clean_addr: .word CLEAN_ADDR |
| 108 | |
| 109 | .text |
| 110 | |
| 111 | /* |
| 112 | * cpu_xscale_proc_init() |
| 113 | * |
| 114 | * Nothing too exciting at the moment |
| 115 | */ |
| 116 | ENTRY(cpu_xscale_proc_init) |
Arnaud Patard | 391c569 | 2008-03-13 09:53:21 +0100 | [diff] [blame] | 117 | @ enable write buffer coalescing. Some bootloader disable it |
| 118 | mrc p15, 0, r1, c1, c0, 1 |
| 119 | bic r1, r1, #1 |
| 120 | mcr p15, 0, r1, c1, c0, 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | mov pc, lr |
| 122 | |
| 123 | /* |
| 124 | * cpu_xscale_proc_fin() |
| 125 | */ |
| 126 | ENTRY(cpu_xscale_proc_fin) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | mrc p15, 0, r0, c1, c0, 0 @ ctrl register |
| 128 | bic r0, r0, #0x1800 @ ...IZ........... |
| 129 | bic r0, r0, #0x0006 @ .............CA. |
| 130 | mcr p15, 0, r0, c1, c0, 0 @ disable caches |
Russell King | 9ca03a2 | 2010-07-26 12:22:12 +0100 | [diff] [blame] | 131 | mov pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | /* |
| 134 | * cpu_xscale_reset(loc) |
| 135 | * |
| 136 | * Perform a soft reset of the system. Put the CPU into the |
| 137 | * same state as it would be if it had been reset, and branch |
| 138 | * to what would be the reset vector. |
| 139 | * |
| 140 | * loc: location to jump to for soft reset |
Nicolas Pitre | 2dc7667 | 2006-07-01 21:29:32 +0100 | [diff] [blame] | 141 | * |
| 142 | * Beware PXA270 erratum E7. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | */ |
| 144 | .align 5 |
Will Deacon | 1a4baaf | 2011-11-15 13:25:04 +0000 | [diff] [blame] | 145 | .pushsection .idmap.text, "ax" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | ENTRY(cpu_xscale_reset) |
| 147 | mov r1, #PSR_F_BIT|PSR_I_BIT|SVC_MODE |
| 148 | msr cpsr_c, r1 @ reset CPSR |
Nicolas Pitre | 2dc7667 | 2006-07-01 21:29:32 +0100 | [diff] [blame] | 149 | mcr p15, 0, r1, c10, c4, 1 @ unlock I-TLB |
| 150 | mcr p15, 0, r1, c8, c5, 0 @ invalidate I-TLB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | mrc p15, 0, r1, c1, c0, 0 @ ctrl register |
| 152 | bic r1, r1, #0x0086 @ ........B....CA. |
| 153 | bic r1, r1, #0x3900 @ ..VIZ..S........ |
Nicolas Pitre | 2dc7667 | 2006-07-01 21:29:32 +0100 | [diff] [blame] | 154 | sub pc, pc, #4 @ flush pipeline |
| 155 | @ *** cache line aligned *** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | mcr p15, 0, r1, c1, c0, 0 @ ctrl register |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | bic r1, r1, #0x0001 @ ...............M |
Nicolas Pitre | 2dc7667 | 2006-07-01 21:29:32 +0100 | [diff] [blame] | 158 | mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches & BTB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | mcr p15, 0, r1, c1, c0, 0 @ ctrl register |
| 160 | @ CAUTION: MMU turned off from this point. We count on the pipeline |
| 161 | @ already containing those two last instructions to survive. |
| 162 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
| 163 | mov pc, r0 |
Will Deacon | 1a4baaf | 2011-11-15 13:25:04 +0000 | [diff] [blame] | 164 | ENDPROC(cpu_xscale_reset) |
| 165 | .popsection |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
| 167 | /* |
| 168 | * cpu_xscale_do_idle() |
| 169 | * |
| 170 | * Cause the processor to idle |
| 171 | * |
| 172 | * For now we do nothing but go to idle mode for every case |
| 173 | * |
| 174 | * XScale supports clock switching, but using idle mode support |
| 175 | * allows external hardware to react to system state changes. |
| 176 | */ |
| 177 | .align 5 |
| 178 | |
| 179 | ENTRY(cpu_xscale_do_idle) |
| 180 | mov r0, #1 |
| 181 | mcr p14, 0, r0, c7, c0, 0 @ Go to IDLE |
| 182 | mov pc, lr |
| 183 | |
| 184 | /* ================================= CACHE ================================ */ |
| 185 | |
| 186 | /* |
Mika Westerberg | c8c9086 | 2010-10-28 11:27:40 +0100 | [diff] [blame] | 187 | * flush_icache_all() |
| 188 | * |
| 189 | * Unconditionally clean and invalidate the entire icache. |
| 190 | */ |
| 191 | ENTRY(xscale_flush_icache_all) |
| 192 | mov r0, #0 |
| 193 | mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache |
| 194 | mov pc, lr |
| 195 | ENDPROC(xscale_flush_icache_all) |
| 196 | |
| 197 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | * flush_user_cache_all() |
| 199 | * |
| 200 | * Invalidate all cache entries in a particular address |
| 201 | * space. |
| 202 | */ |
| 203 | ENTRY(xscale_flush_user_cache_all) |
| 204 | /* FALLTHROUGH */ |
| 205 | |
| 206 | /* |
| 207 | * flush_kern_cache_all() |
| 208 | * |
| 209 | * Clean and invalidate the entire cache. |
| 210 | */ |
| 211 | ENTRY(xscale_flush_kern_cache_all) |
| 212 | mov r2, #VM_EXEC |
| 213 | mov ip, #0 |
| 214 | __flush_whole_cache: |
| 215 | clean_d_cache r0, r1 |
| 216 | tst r2, #VM_EXEC |
| 217 | mcrne p15, 0, ip, c7, c5, 0 @ Invalidate I cache & BTB |
| 218 | mcrne p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 219 | mov pc, lr |
| 220 | |
| 221 | /* |
| 222 | * flush_user_cache_range(start, end, vm_flags) |
| 223 | * |
| 224 | * Invalidate a range of cache entries in the specified |
| 225 | * address space. |
| 226 | * |
| 227 | * - start - start address (may not be aligned) |
| 228 | * - end - end address (exclusive, may not be aligned) |
| 229 | * - vma - vma_area_struct describing address space |
| 230 | */ |
| 231 | .align 5 |
| 232 | ENTRY(xscale_flush_user_cache_range) |
| 233 | mov ip, #0 |
| 234 | sub r3, r1, r0 @ calculate total size |
| 235 | cmp r3, #MAX_AREA_SIZE |
| 236 | bhs __flush_whole_cache |
| 237 | |
| 238 | 1: tst r2, #VM_EXEC |
| 239 | mcrne p15, 0, r0, c7, c5, 1 @ Invalidate I cache line |
| 240 | mcr p15, 0, r0, c7, c10, 1 @ Clean D cache line |
| 241 | mcr p15, 0, r0, c7, c6, 1 @ Invalidate D cache line |
| 242 | add r0, r0, #CACHELINESIZE |
| 243 | cmp r0, r1 |
| 244 | blo 1b |
| 245 | tst r2, #VM_EXEC |
| 246 | mcrne p15, 0, ip, c7, c5, 6 @ Invalidate BTB |
| 247 | mcrne p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 248 | mov pc, lr |
| 249 | |
| 250 | /* |
| 251 | * coherent_kern_range(start, end) |
| 252 | * |
| 253 | * Ensure coherency between the Icache and the Dcache in the |
| 254 | * region described by start. If you have non-snooping |
| 255 | * Harvard caches, you need to implement this function. |
| 256 | * |
| 257 | * - start - virtual start address |
| 258 | * - end - virtual end address |
| 259 | * |
| 260 | * Note: single I-cache line invalidation isn't used here since |
| 261 | * it also trashes the mini I-cache used by JTAG debuggers. |
| 262 | */ |
| 263 | ENTRY(xscale_coherent_kern_range) |
Nicolas Pitre | 8a052e0 | 2006-02-01 19:26:01 +0000 | [diff] [blame] | 264 | bic r0, r0, #CACHELINESIZE - 1 |
| 265 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 266 | add r0, r0, #CACHELINESIZE |
| 267 | cmp r0, r1 |
| 268 | blo 1b |
| 269 | mov r0, #0 |
| 270 | mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB |
| 271 | mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 272 | mov pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
| 274 | /* |
| 275 | * coherent_user_range(start, end) |
| 276 | * |
| 277 | * Ensure coherency between the Icache and the Dcache in the |
| 278 | * region described by start. If you have non-snooping |
| 279 | * Harvard caches, you need to implement this function. |
| 280 | * |
| 281 | * - start - virtual start address |
| 282 | * - end - virtual end address |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | */ |
| 284 | ENTRY(xscale_coherent_user_range) |
| 285 | bic r0, r0, #CACHELINESIZE - 1 |
| 286 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
Nicolas Pitre | 8a052e0 | 2006-02-01 19:26:01 +0000 | [diff] [blame] | 287 | mcr p15, 0, r0, c7, c5, 1 @ Invalidate I cache entry |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | add r0, r0, #CACHELINESIZE |
| 289 | cmp r0, r1 |
| 290 | blo 1b |
| 291 | mov r0, #0 |
Nicolas Pitre | 8a052e0 | 2006-02-01 19:26:01 +0000 | [diff] [blame] | 292 | mcr p15, 0, r0, c7, c5, 6 @ Invalidate BTB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 294 | mov pc, lr |
| 295 | |
| 296 | /* |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 297 | * flush_kern_dcache_area(void *addr, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | * |
| 299 | * Ensure no D cache aliasing occurs, either with itself or |
| 300 | * the I cache |
| 301 | * |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 302 | * - addr - kernel address |
| 303 | * - size - region size |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | */ |
Russell King | 2c9b9c8 | 2009-11-26 12:56:21 +0000 | [diff] [blame] | 305 | ENTRY(xscale_flush_kern_dcache_area) |
| 306 | add r1, r0, r1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 308 | mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry |
| 309 | add r0, r0, #CACHELINESIZE |
| 310 | cmp r0, r1 |
| 311 | blo 1b |
| 312 | mov r0, #0 |
| 313 | mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB |
| 314 | mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 315 | mov pc, lr |
| 316 | |
| 317 | /* |
| 318 | * dma_inv_range(start, end) |
| 319 | * |
| 320 | * Invalidate (discard) the specified virtual address range. |
| 321 | * May not write back any entries. If 'start' or 'end' |
| 322 | * are not cache line aligned, those lines must be written |
| 323 | * back. |
| 324 | * |
| 325 | * - start - virtual start address |
| 326 | * - end - virtual end address |
| 327 | */ |
Russell King | 702b94b | 2009-11-26 16:24:19 +0000 | [diff] [blame] | 328 | xscale_dma_inv_range: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | tst r0, #CACHELINESIZE - 1 |
| 330 | bic r0, r0, #CACHELINESIZE - 1 |
| 331 | mcrne p15, 0, r0, c7, c10, 1 @ clean D entry |
| 332 | tst r1, #CACHELINESIZE - 1 |
| 333 | mcrne p15, 0, r1, c7, c10, 1 @ clean D entry |
| 334 | 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry |
| 335 | add r0, r0, #CACHELINESIZE |
| 336 | cmp r0, r1 |
| 337 | blo 1b |
| 338 | mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 339 | mov pc, lr |
| 340 | |
| 341 | /* |
| 342 | * dma_clean_range(start, end) |
| 343 | * |
| 344 | * Clean the specified virtual address range. |
| 345 | * |
| 346 | * - start - virtual start address |
| 347 | * - end - virtual end address |
| 348 | */ |
Russell King | 702b94b | 2009-11-26 16:24:19 +0000 | [diff] [blame] | 349 | xscale_dma_clean_range: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | bic r0, r0, #CACHELINESIZE - 1 |
| 351 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 352 | add r0, r0, #CACHELINESIZE |
| 353 | cmp r0, r1 |
| 354 | blo 1b |
| 355 | mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 356 | mov pc, lr |
| 357 | |
| 358 | /* |
| 359 | * dma_flush_range(start, end) |
| 360 | * |
| 361 | * Clean and invalidate the specified virtual address range. |
| 362 | * |
| 363 | * - start - virtual start address |
| 364 | * - end - virtual end address |
| 365 | */ |
| 366 | ENTRY(xscale_dma_flush_range) |
| 367 | bic r0, r0, #CACHELINESIZE - 1 |
| 368 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 369 | mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry |
| 370 | add r0, r0, #CACHELINESIZE |
| 371 | cmp r0, r1 |
| 372 | blo 1b |
| 373 | mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 374 | mov pc, lr |
| 375 | |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 376 | /* |
| 377 | * dma_map_area(start, size, dir) |
| 378 | * - start - kernel virtual start address |
| 379 | * - size - size of region |
| 380 | * - dir - DMA direction |
| 381 | */ |
| 382 | ENTRY(xscale_dma_map_area) |
| 383 | add r1, r1, r0 |
| 384 | cmp r2, #DMA_TO_DEVICE |
| 385 | beq xscale_dma_clean_range |
| 386 | bcs xscale_dma_inv_range |
| 387 | b xscale_dma_flush_range |
| 388 | ENDPROC(xscale_dma_map_area) |
| 389 | |
| 390 | /* |
| 391 | * dma_map_area(start, size, dir) |
| 392 | * - start - kernel virtual start address |
| 393 | * - size - size of region |
| 394 | * - dir - DMA direction |
| 395 | */ |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 396 | ENTRY(xscale_80200_A0_A1_dma_map_area) |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 397 | add r1, r1, r0 |
| 398 | teq r2, #DMA_TO_DEVICE |
| 399 | beq xscale_dma_clean_range |
| 400 | b xscale_dma_flush_range |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 401 | ENDPROC(xscale_80200_A0_A1_dma_map_area) |
Russell King | a9c9147 | 2009-11-26 16:19:58 +0000 | [diff] [blame] | 402 | |
| 403 | /* |
| 404 | * dma_unmap_area(start, size, dir) |
| 405 | * - start - kernel virtual start address |
| 406 | * - size - size of region |
| 407 | * - dir - DMA direction |
| 408 | */ |
| 409 | ENTRY(xscale_dma_unmap_area) |
| 410 | mov pc, lr |
| 411 | ENDPROC(xscale_dma_unmap_area) |
| 412 | |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 413 | @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S) |
| 414 | define_cache_functions xscale |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
Lennert Buytenhek | 197c944 | 2006-09-16 10:52:02 +0100 | [diff] [blame] | 416 | /* |
| 417 | * On stepping A0/A1 of the 80200, invalidating D-cache by line doesn't |
| 418 | * clear the dirty bits, which means that if we invalidate a dirty line, |
| 419 | * the dirty data can still be written back to external memory later on. |
| 420 | * |
| 421 | * The recommended workaround is to always do a clean D-cache line before |
| 422 | * doing an invalidate D-cache line, so on the affected processors, |
| 423 | * dma_inv_range() is implemented as dma_flush_range(). |
| 424 | * |
| 425 | * See erratum #25 of "Intel 80200 Processor Specification Update", |
| 426 | * revision January 22, 2003, available at: |
| 427 | * http://www.intel.com/design/iio/specupdt/273415.htm |
| 428 | */ |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 429 | .macro a0_alias basename |
| 430 | .globl xscale_80200_A0_A1_\basename |
| 431 | .type xscale_80200_A0_A1_\basename , %function |
| 432 | .equ xscale_80200_A0_A1_\basename , xscale_\basename |
| 433 | .endm |
| 434 | |
| 435 | /* |
| 436 | * Most of the cache functions are unchanged for these processor revisions. |
| 437 | * Export suitable alias symbols for the unchanged functions: |
| 438 | */ |
| 439 | a0_alias flush_icache_all |
| 440 | a0_alias flush_user_cache_all |
| 441 | a0_alias flush_kern_cache_all |
| 442 | a0_alias flush_user_cache_range |
| 443 | a0_alias coherent_kern_range |
| 444 | a0_alias coherent_user_range |
| 445 | a0_alias flush_kern_dcache_area |
| 446 | a0_alias dma_flush_range |
| 447 | a0_alias dma_unmap_area |
| 448 | |
| 449 | @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S) |
| 450 | define_cache_functions xscale_80200_A0_A1 |
Lennert Buytenhek | 197c944 | 2006-09-16 10:52:02 +0100 | [diff] [blame] | 451 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | ENTRY(cpu_xscale_dcache_clean_area) |
| 453 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 454 | add r0, r0, #CACHELINESIZE |
| 455 | subs r1, r1, #CACHELINESIZE |
| 456 | bhi 1b |
| 457 | mov pc, lr |
| 458 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | /* =============================== PageTable ============================== */ |
| 460 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | /* |
| 462 | * cpu_xscale_switch_mm(pgd) |
| 463 | * |
| 464 | * Set the translation base pointer to be as described by pgd. |
| 465 | * |
| 466 | * pgd: new page tables |
| 467 | */ |
| 468 | .align 5 |
| 469 | ENTRY(cpu_xscale_switch_mm) |
| 470 | clean_d_cache r1, r2 |
| 471 | mcr p15, 0, ip, c7, c5, 0 @ Invalidate I cache & BTB |
| 472 | mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 473 | mcr p15, 0, r0, c2, c0, 0 @ load page table pointer |
| 474 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
| 475 | cpwait_ret lr, ip |
| 476 | |
| 477 | /* |
Russell King | ad1ae2f | 2006-12-13 14:34:43 +0000 | [diff] [blame] | 478 | * cpu_xscale_set_pte_ext(ptep, pte, ext) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | * |
| 480 | * Set a PTE and flush it out |
| 481 | * |
| 482 | * Errata 40: must set memory to write-through for user read-only pages. |
| 483 | */ |
Russell King | 9e8b519 | 2008-09-06 20:47:54 +0100 | [diff] [blame] | 484 | cpu_xscale_mt_table: |
| 485 | .long 0x00 @ L_PTE_MT_UNCACHED |
| 486 | .long PTE_BUFFERABLE @ L_PTE_MT_BUFFERABLE |
| 487 | .long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH |
| 488 | .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEBACK |
Russell King | 40df2d1 | 2008-09-07 12:36:46 +0100 | [diff] [blame] | 489 | .long PTE_EXT_TEX(1) | PTE_BUFFERABLE @ L_PTE_MT_DEV_SHARED |
Russell King | 639b0ae | 2008-09-06 21:07:45 +0100 | [diff] [blame] | 490 | .long 0x00 @ unused |
Russell King | 9e8b519 | 2008-09-06 20:47:54 +0100 | [diff] [blame] | 491 | .long PTE_EXT_TEX(1) | PTE_CACHEABLE @ L_PTE_MT_MINICACHE |
| 492 | .long PTE_EXT_TEX(1) | PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEALLOC |
Russell King | 639b0ae | 2008-09-06 21:07:45 +0100 | [diff] [blame] | 493 | .long 0x00 @ unused |
Russell King | 9e8b519 | 2008-09-06 20:47:54 +0100 | [diff] [blame] | 494 | .long PTE_BUFFERABLE @ L_PTE_MT_DEV_WC |
| 495 | .long 0x00 @ unused |
| 496 | .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_DEV_CACHED |
| 497 | .long 0x00 @ L_PTE_MT_DEV_NONSHARED |
Russell King | db5b716 | 2008-09-07 12:42:51 +0100 | [diff] [blame] | 498 | .long 0x00 @ unused |
Russell King | 9e8b519 | 2008-09-06 20:47:54 +0100 | [diff] [blame] | 499 | .long 0x00 @ unused |
| 500 | .long 0x00 @ unused |
| 501 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | .align 5 |
Russell King | ad1ae2f | 2006-12-13 14:34:43 +0000 | [diff] [blame] | 503 | ENTRY(cpu_xscale_set_pte_ext) |
Russell King | da09165 | 2008-09-06 17:19:08 +0100 | [diff] [blame] | 504 | xscale_set_pte_ext_prologue |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | @ |
Russell King | 9e8b519 | 2008-09-06 20:47:54 +0100 | [diff] [blame] | 507 | @ Erratum 40: must set memory to write-through for user read-only pages |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | @ |
Russell King | 36bb94b | 2010-11-16 08:40:36 +0000 | [diff] [blame] | 509 | and ip, r1, #(L_PTE_MT_MASK | L_PTE_USER | L_PTE_RDONLY) & ~(4 << 2) |
| 510 | teq ip, #L_PTE_MT_WRITEBACK | L_PTE_USER | L_PTE_RDONLY |
Russell King | 9e8b519 | 2008-09-06 20:47:54 +0100 | [diff] [blame] | 511 | |
| 512 | moveq r1, #L_PTE_MT_WRITETHROUGH |
| 513 | and r1, r1, #L_PTE_MT_MASK |
| 514 | adr ip, cpu_xscale_mt_table |
| 515 | ldr ip, [ip, r1] |
| 516 | bic r2, r2, #0x0c |
| 517 | orr r2, r2, ip |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | |
Russell King | da09165 | 2008-09-06 17:19:08 +0100 | [diff] [blame] | 519 | xscale_set_pte_ext_epilogue |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | mov pc, lr |
| 521 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | .ltorg |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | .align |
| 524 | |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 525 | .globl cpu_xscale_suspend_size |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 526 | .equ cpu_xscale_suspend_size, 4 * 6 |
Russell King | 29ea23f | 2011-04-02 10:08:55 +0100 | [diff] [blame] | 527 | #ifdef CONFIG_PM_SLEEP |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 528 | ENTRY(cpu_xscale_do_suspend) |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 529 | stmfd sp!, {r4 - r9, lr} |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 530 | mrc p14, 0, r4, c6, c0, 0 @ clock configuration, for turbo mode |
| 531 | mrc p15, 0, r5, c15, c1, 0 @ CP access reg |
| 532 | mrc p15, 0, r6, c13, c0, 0 @ PID |
| 533 | mrc p15, 0, r7, c3, c0, 0 @ domain ID |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 534 | mrc p15, 0, r8, c1, c1, 0 @ auxiliary control reg |
| 535 | mrc p15, 0, r9, c1, c0, 0 @ control reg |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 536 | bic r4, r4, #2 @ clear frequency change bit |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 537 | stmia r0, {r4 - r9} @ store cp regs |
| 538 | ldmfd sp!, {r4 - r9, pc} |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 539 | ENDPROC(cpu_xscale_do_suspend) |
| 540 | |
| 541 | ENTRY(cpu_xscale_do_resume) |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 542 | ldmia r0, {r4 - r9} @ load cp regs |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 543 | mov ip, #0 |
| 544 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
| 545 | mcr p15, 0, ip, c7, c7, 0 @ invalidate I & D caches, BTB |
| 546 | mcr p14, 0, r4, c6, c0, 0 @ clock configuration, turbo mode. |
| 547 | mcr p15, 0, r5, c15, c1, 0 @ CP access reg |
| 548 | mcr p15, 0, r6, c13, c0, 0 @ PID |
| 549 | mcr p15, 0, r7, c3, c0, 0 @ domain ID |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 550 | mcr p15, 0, r1, c2, c0, 0 @ translation table base addr |
| 551 | mcr p15, 0, r8, c1, c1, 0 @ auxiliary control reg |
| 552 | mov r0, r9 @ control register |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 553 | b cpu_resume_mmu |
| 554 | ENDPROC(cpu_xscale_do_resume) |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 555 | #endif |
| 556 | |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 557 | __CPUINIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | |
| 559 | .type __xscale_setup, #function |
| 560 | __xscale_setup: |
| 561 | mcr p15, 0, ip, c7, c7, 0 @ invalidate I, D caches & BTB |
| 562 | mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer |
| 563 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I, D TLBs |
Lennert Buytenhek | afe4b25 | 2006-12-03 18:51:14 +0100 | [diff] [blame] | 564 | mov r0, #1 << 6 @ cp6 for IOP3xx and Bulverde |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | orr r0, r0, #1 << 13 @ Its undefined whether this |
| 566 | mcr p15, 0, r0, c15, c1, 0 @ affects USR or SVC modes |
Russell King | 22b1908 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 567 | |
| 568 | adr r5, xscale_crval |
| 569 | ldmia r5, {r5, r6} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | mrc p15, 0, r0, c1, c0, 0 @ get control register |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | bic r0, r0, r5 |
Russell King | 22b1908 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 572 | orr r0, r0, r6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | mov pc, lr |
| 574 | .size __xscale_setup, . - __xscale_setup |
| 575 | |
| 576 | /* |
| 577 | * R |
| 578 | * .RVI ZFRS BLDP WCAM |
| 579 | * ..11 1.01 .... .101 |
| 580 | * |
| 581 | */ |
Russell King | 22b1908 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 582 | .type xscale_crval, #object |
| 583 | xscale_crval: |
| 584 | crval clear=0x00003b07, mmuset=0x00003905, ucset=0x00001900 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
| 586 | __INITDATA |
| 587 | |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 588 | @ define struct processor (see <asm/proc-fns.h> and proc-macros.S) |
| 589 | define_processor_functions xscale, dabort=v5t_early_abort, pabort=legacy_pabort, suspend=1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
| 591 | .section ".rodata" |
| 592 | |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 593 | string cpu_arch_name, "armv5te" |
| 594 | string cpu_elf_name, "v5" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 596 | string cpu_80200_A0_A1_name, "XScale-80200 A0/A1" |
| 597 | string cpu_80200_name, "XScale-80200" |
| 598 | string cpu_80219_name, "XScale-80219" |
| 599 | string cpu_8032x_name, "XScale-IOP8032x Family" |
| 600 | string cpu_8033x_name, "XScale-IOP8033x Family" |
| 601 | string cpu_pxa250_name, "XScale-PXA250" |
| 602 | string cpu_pxa210_name, "XScale-PXA210" |
| 603 | string cpu_ixp42x_name, "XScale-IXP42x Family" |
| 604 | string cpu_ixp43x_name, "XScale-IXP43x Family" |
| 605 | string cpu_ixp46x_name, "XScale-IXP46x Family" |
| 606 | string cpu_ixp2400_name, "XScale-IXP2400" |
| 607 | string cpu_ixp2800_name, "XScale-IXP2800" |
| 608 | string cpu_pxa255_name, "XScale-PXA255" |
| 609 | string cpu_pxa270_name, "XScale-PXA270" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
| 611 | .align |
| 612 | |
Ben Dooks | 02b7dd1 | 2005-09-20 16:35:03 +0100 | [diff] [blame] | 613 | .section ".proc.info.init", #alloc, #execinstr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 615 | .macro xscale_proc_info name:req, cpu_val:req, cpu_mask:req, cpu_name:req, cache |
| 616 | .type __\name\()_proc_info,#object |
| 617 | __\name\()_proc_info: |
| 618 | .long \cpu_val |
| 619 | .long \cpu_mask |
| 620 | .long PMD_TYPE_SECT | \ |
Lennert Buytenhek | 197c944 | 2006-09-16 10:52:02 +0100 | [diff] [blame] | 621 | PMD_SECT_BUFFERABLE | \ |
| 622 | PMD_SECT_CACHEABLE | \ |
| 623 | PMD_SECT_AP_WRITE | \ |
| 624 | PMD_SECT_AP_READ |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 625 | .long PMD_TYPE_SECT | \ |
Lennert Buytenhek | 197c944 | 2006-09-16 10:52:02 +0100 | [diff] [blame] | 626 | PMD_SECT_AP_WRITE | \ |
| 627 | PMD_SECT_AP_READ |
| 628 | b __xscale_setup |
| 629 | .long cpu_arch_name |
| 630 | .long cpu_elf_name |
| 631 | .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 632 | .long \cpu_name |
Lennert Buytenhek | 197c944 | 2006-09-16 10:52:02 +0100 | [diff] [blame] | 633 | .long xscale_processor_functions |
| 634 | .long v4wbi_tlb_fns |
| 635 | .long xscale_mc_user_fns |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 636 | .ifb \cache |
| 637 | .long xscale_cache_fns |
| 638 | .else |
| 639 | .long \cache |
| 640 | .endif |
| 641 | .size __\name\()_proc_info, . - __\name\()_proc_info |
| 642 | .endm |
Lennert Buytenhek | 197c944 | 2006-09-16 10:52:02 +0100 | [diff] [blame] | 643 | |
Dave Martin | ab1a746 | 2011-06-23 17:26:56 +0100 | [diff] [blame] | 644 | xscale_proc_info 80200_A0_A1, 0x69052000, 0xfffffffe, cpu_80200_name, \ |
| 645 | cache=xscale_80200_A0_A1_cache_fns |
| 646 | xscale_proc_info 80200, 0x69052000, 0xfffffff0, cpu_80200_name |
| 647 | xscale_proc_info 80219, 0x69052e20, 0xffffffe0, cpu_80219_name |
| 648 | xscale_proc_info 8032x, 0x69052420, 0xfffff7e0, cpu_8032x_name |
| 649 | xscale_proc_info 8033x, 0x69054010, 0xfffffd30, cpu_8033x_name |
| 650 | xscale_proc_info pxa250, 0x69052100, 0xfffff7f0, cpu_pxa250_name |
| 651 | xscale_proc_info pxa210, 0x69052120, 0xfffff3f0, cpu_pxa210_name |
| 652 | xscale_proc_info ixp2400, 0x69054190, 0xfffffff0, cpu_ixp2400_name |
| 653 | xscale_proc_info ixp2800, 0x690541a0, 0xfffffff0, cpu_ixp2800_name |
| 654 | xscale_proc_info ixp42x, 0x690541c0, 0xffffffc0, cpu_ixp42x_name |
| 655 | xscale_proc_info ixp43x, 0x69054040, 0xfffffff0, cpu_ixp43x_name |
| 656 | xscale_proc_info ixp46x, 0x69054200, 0xffffff00, cpu_ixp46x_name |
| 657 | xscale_proc_info pxa255, 0x69052d00, 0xfffffff0, cpu_pxa255_name |
| 658 | xscale_proc_info pxa270, 0x69054110, 0xfffffff0, cpu_pxa270_name |