Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mm/proc-xsc3.S |
| 3 | * |
| 4 | * Original Author: Matthew Gilbert |
Lennert Buytenhek | 57fee39 | 2006-12-19 21:48:15 +0100 | [diff] [blame] | 5 | * Current Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 6 | * |
| 7 | * Copyright 2004 (C) Intel Corp. |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 8 | * Copyright 2005 (C) MontaVista Software, Inc. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 14 | * MMU functions for the Intel XScale3 Core (XSC3). The XSC3 core is |
| 15 | * an extension to Intel's original XScale core that adds the following |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 16 | * features: |
| 17 | * |
| 18 | * - ARMv6 Supersections |
| 19 | * - Low Locality Reference pages (replaces mini-cache) |
| 20 | * - 36-bit addressing |
| 21 | * - L2 cache |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 22 | * - Cache coherency if chipset supports it |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 23 | * |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 24 | * Based on original XScale code by Nicolas Pitre. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #include <linux/linkage.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <asm/assembler.h> |
Russell King | ee90dab | 2006-11-09 14:20:47 +0000 | [diff] [blame] | 30 | #include <asm/elf.h> |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 31 | #include <asm/hardware.h> |
| 32 | #include <asm/pgtable.h> |
Lennert Buytenhek | b48340a | 2006-03-30 10:24:07 +0100 | [diff] [blame] | 33 | #include <asm/pgtable-hwdef.h> |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 34 | #include <asm/page.h> |
| 35 | #include <asm/ptrace.h> |
| 36 | #include "proc-macros.S" |
| 37 | |
| 38 | /* |
| 39 | * This is the maximum size of an area which will be flushed. If the |
| 40 | * area is larger than this, then we flush the whole cache. |
| 41 | */ |
| 42 | #define MAX_AREA_SIZE 32768 |
| 43 | |
| 44 | /* |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 45 | * The cache line size of the L1 I, L1 D and unified L2 cache. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 46 | */ |
| 47 | #define CACHELINESIZE 32 |
| 48 | |
| 49 | /* |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 50 | * The size of the L1 D cache. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 51 | */ |
| 52 | #define CACHESIZE 32768 |
| 53 | |
| 54 | /* |
| 55 | * Run with L2 enabled. |
| 56 | */ |
| 57 | #define L2_CACHE_ENABLE 1 |
| 58 | |
| 59 | /* |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 60 | * This macro is used to wait for a CP15 write and is needed when we |
| 61 | * have to ensure that the last operation to the coprocessor was |
| 62 | * completed before continuing with operation. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 63 | */ |
| 64 | .macro cpwait_ret, lr, rd |
| 65 | mrc p15, 0, \rd, c2, c0, 0 @ arbitrary read of cp15 |
| 66 | sub pc, \lr, \rd, LSR #32 @ wait for completion and |
| 67 | @ flush instruction pipeline |
| 68 | .endm |
| 69 | |
| 70 | /* |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 71 | * This macro cleans and invalidates the entire L1 D cache. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 72 | */ |
| 73 | |
| 74 | .macro clean_d_cache rd, rs |
| 75 | mov \rd, #0x1f00 |
| 76 | orr \rd, \rd, #0x00e0 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 77 | 1: mcr p15, 0, \rd, c7, c14, 2 @ clean/invalidate L1 D line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 78 | adds \rd, \rd, #0x40000000 |
| 79 | bcc 1b |
| 80 | subs \rd, \rd, #0x20 |
| 81 | bpl 1b |
| 82 | .endm |
| 83 | |
| 84 | .text |
| 85 | |
| 86 | /* |
| 87 | * cpu_xsc3_proc_init() |
| 88 | * |
| 89 | * Nothing too exciting at the moment |
| 90 | */ |
| 91 | ENTRY(cpu_xsc3_proc_init) |
| 92 | mov pc, lr |
| 93 | |
| 94 | /* |
| 95 | * cpu_xsc3_proc_fin() |
| 96 | */ |
| 97 | ENTRY(cpu_xsc3_proc_fin) |
| 98 | str lr, [sp, #-4]! |
| 99 | mov r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE |
| 100 | msr cpsr_c, r0 |
| 101 | bl xsc3_flush_kern_cache_all @ clean caches |
| 102 | mrc p15, 0, r0, c1, c0, 0 @ ctrl register |
| 103 | bic r0, r0, #0x1800 @ ...IZ........... |
| 104 | bic r0, r0, #0x0006 @ .............CA. |
| 105 | mcr p15, 0, r0, c1, c0, 0 @ disable caches |
| 106 | ldr pc, [sp], #4 |
| 107 | |
| 108 | /* |
| 109 | * cpu_xsc3_reset(loc) |
| 110 | * |
| 111 | * Perform a soft reset of the system. Put the CPU into the |
| 112 | * same state as it would be if it had been reset, and branch |
| 113 | * to what would be the reset vector. |
| 114 | * |
| 115 | * loc: location to jump to for soft reset |
| 116 | */ |
| 117 | .align 5 |
| 118 | ENTRY(cpu_xsc3_reset) |
| 119 | mov r1, #PSR_F_BIT|PSR_I_BIT|SVC_MODE |
| 120 | msr cpsr_c, r1 @ reset CPSR |
| 121 | mrc p15, 0, r1, c1, c0, 0 @ ctrl register |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 122 | bic r1, r1, #0x3900 @ ..VIZ..S........ |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 123 | bic r1, r1, #0x0086 @ ........B....CA. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 124 | mcr p15, 0, r1, c1, c0, 0 @ ctrl register |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 125 | mcr p15, 0, ip, c7, c7, 0 @ invalidate L1 caches and BTB |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 126 | bic r1, r1, #0x0001 @ ...............M |
| 127 | mcr p15, 0, r1, c1, c0, 0 @ ctrl register |
| 128 | @ CAUTION: MMU turned off from this point. We count on the pipeline |
| 129 | @ already containing those two last instructions to survive. |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 130 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I and D TLBs |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 131 | mov pc, r0 |
| 132 | |
| 133 | /* |
| 134 | * cpu_xsc3_do_idle() |
| 135 | * |
| 136 | * Cause the processor to idle |
| 137 | * |
| 138 | * For now we do nothing but go to idle mode for every case |
| 139 | * |
| 140 | * XScale supports clock switching, but using idle mode support |
| 141 | * allows external hardware to react to system state changes. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 142 | */ |
| 143 | .align 5 |
| 144 | |
| 145 | ENTRY(cpu_xsc3_do_idle) |
| 146 | mov r0, #1 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 147 | mcr p14, 0, r0, c7, c0, 0 @ go to idle |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 148 | mov pc, lr |
| 149 | |
| 150 | /* ================================= CACHE ================================ */ |
| 151 | |
| 152 | /* |
| 153 | * flush_user_cache_all() |
| 154 | * |
| 155 | * Invalidate all cache entries in a particular address |
| 156 | * space. |
| 157 | */ |
| 158 | ENTRY(xsc3_flush_user_cache_all) |
| 159 | /* FALLTHROUGH */ |
| 160 | |
| 161 | /* |
| 162 | * flush_kern_cache_all() |
| 163 | * |
| 164 | * Clean and invalidate the entire cache. |
| 165 | */ |
| 166 | ENTRY(xsc3_flush_kern_cache_all) |
| 167 | mov r2, #VM_EXEC |
| 168 | mov ip, #0 |
| 169 | __flush_whole_cache: |
| 170 | clean_d_cache r0, r1 |
| 171 | tst r2, #VM_EXEC |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 172 | mcrne p15, 0, ip, c7, c5, 0 @ invalidate L1 I cache and BTB |
| 173 | mcrne p15, 0, ip, c7, c10, 4 @ data write barrier |
| 174 | mcrne p15, 0, ip, c7, c5, 4 @ prefetch flush |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 175 | mov pc, lr |
| 176 | |
| 177 | /* |
| 178 | * flush_user_cache_range(start, end, vm_flags) |
| 179 | * |
| 180 | * Invalidate a range of cache entries in the specified |
| 181 | * address space. |
| 182 | * |
| 183 | * - start - start address (may not be aligned) |
| 184 | * - end - end address (exclusive, may not be aligned) |
| 185 | * - vma - vma_area_struct describing address space |
| 186 | */ |
| 187 | .align 5 |
| 188 | ENTRY(xsc3_flush_user_cache_range) |
| 189 | mov ip, #0 |
| 190 | sub r3, r1, r0 @ calculate total size |
| 191 | cmp r3, #MAX_AREA_SIZE |
| 192 | bhs __flush_whole_cache |
| 193 | |
| 194 | 1: tst r2, #VM_EXEC |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 195 | mcrne p15, 0, r0, c7, c5, 1 @ invalidate L1 I line |
| 196 | mcr p15, 0, r0, c7, c14, 1 @ clean/invalidate L1 D line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 197 | add r0, r0, #CACHELINESIZE |
| 198 | cmp r0, r1 |
| 199 | blo 1b |
| 200 | tst r2, #VM_EXEC |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 201 | mcrne p15, 0, ip, c7, c5, 6 @ invalidate BTB |
| 202 | mcrne p15, 0, ip, c7, c10, 4 @ data write barrier |
| 203 | mcrne p15, 0, ip, c7, c5, 4 @ prefetch flush |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 204 | mov pc, lr |
| 205 | |
| 206 | /* |
| 207 | * coherent_kern_range(start, end) |
| 208 | * |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 209 | * Ensure coherency between the I cache and the D cache in the |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 210 | * region described by start. If you have non-snooping |
| 211 | * Harvard caches, you need to implement this function. |
| 212 | * |
| 213 | * - start - virtual start address |
| 214 | * - end - virtual end address |
| 215 | * |
| 216 | * Note: single I-cache line invalidation isn't used here since |
| 217 | * it also trashes the mini I-cache used by JTAG debuggers. |
| 218 | */ |
| 219 | ENTRY(xsc3_coherent_kern_range) |
| 220 | /* FALLTHROUGH */ |
| 221 | ENTRY(xsc3_coherent_user_range) |
| 222 | bic r0, r0, #CACHELINESIZE - 1 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 223 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean L1 D line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 224 | add r0, r0, #CACHELINESIZE |
| 225 | cmp r0, r1 |
| 226 | blo 1b |
| 227 | mov r0, #0 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 228 | mcr p15, 0, r0, c7, c5, 0 @ invalidate L1 I cache and BTB |
| 229 | mcr p15, 0, r0, c7, c10, 4 @ data write barrier |
| 230 | mcr p15, 0, r0, c7, c5, 4 @ prefetch flush |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 231 | mov pc, lr |
| 232 | |
| 233 | /* |
| 234 | * flush_kern_dcache_page(void *page) |
| 235 | * |
| 236 | * Ensure no D cache aliasing occurs, either with itself or |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 237 | * the I cache. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 238 | * |
| 239 | * - addr - page aligned address |
| 240 | */ |
| 241 | ENTRY(xsc3_flush_kern_dcache_page) |
| 242 | add r1, r0, #PAGE_SZ |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 243 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean/invalidate L1 D line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 244 | add r0, r0, #CACHELINESIZE |
| 245 | cmp r0, r1 |
| 246 | blo 1b |
| 247 | mov r0, #0 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 248 | mcr p15, 0, r0, c7, c5, 0 @ invalidate L1 I cache and BTB |
| 249 | mcr p15, 0, r0, c7, c10, 4 @ data write barrier |
| 250 | mcr p15, 0, r0, c7, c5, 4 @ prefetch flush |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 251 | mov pc, lr |
| 252 | |
| 253 | /* |
| 254 | * dma_inv_range(start, end) |
| 255 | * |
| 256 | * Invalidate (discard) the specified virtual address range. |
| 257 | * May not write back any entries. If 'start' or 'end' |
| 258 | * are not cache line aligned, those lines must be written |
| 259 | * back. |
| 260 | * |
| 261 | * - start - virtual start address |
| 262 | * - end - virtual end address |
| 263 | */ |
| 264 | ENTRY(xsc3_dma_inv_range) |
| 265 | tst r0, #CACHELINESIZE - 1 |
| 266 | bic r0, r0, #CACHELINESIZE - 1 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 267 | mcrne p15, 0, r0, c7, c10, 1 @ clean L1 D line |
| 268 | mcrne p15, 1, r0, c7, c11, 1 @ clean L2 line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 269 | tst r1, #CACHELINESIZE - 1 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 270 | mcrne p15, 0, r1, c7, c10, 1 @ clean L1 D line |
| 271 | mcrne p15, 1, r1, c7, c11, 1 @ clean L2 line |
| 272 | 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate L1 D line |
| 273 | mcr p15, 1, r0, c7, c7, 1 @ invalidate L2 line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 274 | add r0, r0, #CACHELINESIZE |
| 275 | cmp r0, r1 |
| 276 | blo 1b |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 277 | mcr p15, 0, r0, c7, c10, 4 @ data write barrier |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 278 | mov pc, lr |
| 279 | |
| 280 | /* |
| 281 | * dma_clean_range(start, end) |
| 282 | * |
| 283 | * Clean the specified virtual address range. |
| 284 | * |
| 285 | * - start - virtual start address |
| 286 | * - end - virtual end address |
| 287 | */ |
| 288 | ENTRY(xsc3_dma_clean_range) |
| 289 | bic r0, r0, #CACHELINESIZE - 1 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 290 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean L1 D line |
| 291 | mcr p15, 1, r0, c7, c11, 1 @ clean L2 line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 292 | add r0, r0, #CACHELINESIZE |
| 293 | cmp r0, r1 |
| 294 | blo 1b |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 295 | mcr p15, 0, r0, c7, c10, 4 @ data write barrier |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 296 | mov pc, lr |
| 297 | |
| 298 | /* |
| 299 | * dma_flush_range(start, end) |
| 300 | * |
| 301 | * Clean and invalidate the specified virtual address range. |
| 302 | * |
| 303 | * - start - virtual start address |
| 304 | * - end - virtual end address |
| 305 | */ |
| 306 | ENTRY(xsc3_dma_flush_range) |
| 307 | bic r0, r0, #CACHELINESIZE - 1 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 308 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean/invalidate L1 D line |
| 309 | mcr p15, 1, r0, c7, c11, 1 @ clean L2 line |
| 310 | mcr p15, 1, r0, c7, c7, 1 @ invalidate L2 line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 311 | add r0, r0, #CACHELINESIZE |
| 312 | cmp r0, r1 |
| 313 | blo 1b |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 314 | mcr p15, 0, r0, c7, c10, 4 @ data write barrier |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 315 | mov pc, lr |
| 316 | |
| 317 | ENTRY(xsc3_cache_fns) |
| 318 | .long xsc3_flush_kern_cache_all |
| 319 | .long xsc3_flush_user_cache_all |
| 320 | .long xsc3_flush_user_cache_range |
| 321 | .long xsc3_coherent_kern_range |
| 322 | .long xsc3_coherent_user_range |
| 323 | .long xsc3_flush_kern_dcache_page |
| 324 | .long xsc3_dma_inv_range |
| 325 | .long xsc3_dma_clean_range |
| 326 | .long xsc3_dma_flush_range |
| 327 | |
| 328 | ENTRY(cpu_xsc3_dcache_clean_area) |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 329 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean L1 D line |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 330 | add r0, r0, #CACHELINESIZE |
| 331 | subs r1, r1, #CACHELINESIZE |
| 332 | bhi 1b |
| 333 | mov pc, lr |
| 334 | |
| 335 | /* =============================== PageTable ============================== */ |
| 336 | |
| 337 | /* |
| 338 | * cpu_xsc3_switch_mm(pgd) |
| 339 | * |
| 340 | * Set the translation base pointer to be as described by pgd. |
| 341 | * |
| 342 | * pgd: new page tables |
| 343 | */ |
| 344 | .align 5 |
| 345 | ENTRY(cpu_xsc3_switch_mm) |
| 346 | clean_d_cache r1, r2 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 347 | mcr p15, 0, ip, c7, c5, 0 @ invalidate L1 I cache and BTB |
| 348 | mcr p15, 0, ip, c7, c10, 4 @ data write barrier |
| 349 | mcr p15, 0, ip, c7, c5, 4 @ prefetch flush |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 350 | #ifdef L2_CACHE_ENABLE |
| 351 | orr r0, r0, #0x18 @ cache the page table in L2 |
| 352 | #endif |
| 353 | mcr p15, 0, r0, c2, c0, 0 @ load page table pointer |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 354 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I and D TLBs |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 355 | cpwait_ret lr, ip |
| 356 | |
| 357 | /* |
Russell King | ad1ae2f | 2006-12-13 14:34:43 +0000 | [diff] [blame] | 358 | * cpu_xsc3_set_pte_ext(ptep, pte, ext) |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 359 | * |
| 360 | * Set a PTE and flush it out |
| 361 | * |
| 362 | */ |
| 363 | .align 5 |
Russell King | ad1ae2f | 2006-12-13 14:34:43 +0000 | [diff] [blame] | 364 | ENTRY(cpu_xsc3_set_pte_ext) |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 365 | str r1, [r0], #-2048 @ linux version |
| 366 | |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 367 | bic r2, r1, #0xff0 @ keep C, B bits |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 368 | orr r2, r2, #PTE_TYPE_EXT @ extended page |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 369 | tst r1, #L_PTE_SHARED @ shared? |
Lennert Buytenhek | 0e5fdca | 2006-12-02 00:03:47 +0100 | [diff] [blame] | 370 | orrne r2, r2, #0x200 |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 371 | |
| 372 | eor r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY |
| 373 | |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 374 | tst r3, #L_PTE_USER @ user? |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 375 | orrne r2, r2, #PTE_EXT_AP_URO_SRW @ yes -> user r/o, system r/w |
| 376 | |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 377 | tst r3, #L_PTE_WRITE | L_PTE_DIRTY @ write and dirty? |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 378 | orreq r2, r2, #PTE_EXT_AP_UNO_SRW @ yes -> user n/a, system r/w |
| 379 | @ combined with user -> user r/w |
| 380 | |
| 381 | #if L2_CACHE_ENABLE |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 382 | @ If it's cacheable, it needs to be in L2 also. |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 383 | eor ip, r1, #L_PTE_CACHEABLE |
| 384 | tst ip, #L_PTE_CACHEABLE |
| 385 | orreq r2, r2, #PTE_EXT_TEX(0x5) |
| 386 | #endif |
| 387 | |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 388 | tst r3, #L_PTE_PRESENT | L_PTE_YOUNG @ present and young? |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 389 | movne r2, #0 @ no -> fault |
| 390 | |
| 391 | str r2, [r0] @ hardware version |
| 392 | mov ip, #0 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 393 | mcr p15, 0, r0, c7, c10, 1 @ clean L1 D line |
| 394 | mcr p15, 0, ip, c7, c10, 4 @ data write barrier |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 395 | mov pc, lr |
| 396 | |
| 397 | .ltorg |
| 398 | |
| 399 | .align |
| 400 | |
| 401 | __INIT |
| 402 | |
| 403 | .type __xsc3_setup, #function |
| 404 | __xsc3_setup: |
| 405 | mov r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE |
| 406 | msr cpsr_c, r0 |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 407 | mcr p15, 0, ip, c7, c7, 0 @ invalidate L1 caches and BTB |
| 408 | mcr p15, 0, ip, c7, c10, 4 @ data write barrier |
| 409 | mcr p15, 0, ip, c7, c5, 4 @ prefetch flush |
| 410 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I and D TLBs |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 411 | #if L2_CACHE_ENABLE |
| 412 | orr r4, r4, #0x18 @ cache the page table in L2 |
| 413 | #endif |
| 414 | mcr p15, 0, r4, c2, c0, 0 @ load page table pointer |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 415 | |
| 416 | mov r0, #0 @ don't allow CP access |
| 417 | mcr p15, 0, r0, c15, c1, 0 @ write CP access register |
| 418 | |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 419 | mrc p15, 0, r0, c1, c0, 1 @ get auxiliary control reg |
| 420 | and r0, r0, #2 @ preserve bit P bit setting |
| 421 | #if L2_CACHE_ENABLE |
| 422 | orr r0, r0, #(1 << 10) @ enable L2 for LLR cache |
| 423 | #endif |
| 424 | mcr p15, 0, r0, c1, c0, 1 @ set auxiliary control reg |
Russell King | 22b19086 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 425 | |
| 426 | adr r5, xsc3_crval |
| 427 | ldmia r5, {r5, r6} |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 428 | mrc p15, 0, r0, c1, c0, 0 @ get control register |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 429 | bic r0, r0, r5 @ ..V. ..R. .... ..A. |
| 430 | orr r0, r0, r6 @ ..VI Z..S .... .C.M (mmu) |
| 431 | @ ...I Z..S .... .... (uc) |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 432 | #if L2_CACHE_ENABLE |
Russell King | 22b19086 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 433 | orr r0, r0, #0x04000000 @ L2 enable |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 434 | #endif |
| 435 | mov pc, lr |
| 436 | |
| 437 | .size __xsc3_setup, . - __xsc3_setup |
| 438 | |
Russell King | 22b19086 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 439 | .type xsc3_crval, #object |
| 440 | xsc3_crval: |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 441 | crval clear=0x04002202, mmuset=0x00003905, ucset=0x00001900 |
Russell King | 22b19086 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 442 | |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 443 | __INITDATA |
| 444 | |
| 445 | /* |
| 446 | * Purpose : Function pointers used to access above functions - all calls |
| 447 | * come through these |
| 448 | */ |
| 449 | |
| 450 | .type xsc3_processor_functions, #object |
| 451 | ENTRY(xsc3_processor_functions) |
| 452 | .word v5t_early_abort |
| 453 | .word cpu_xsc3_proc_init |
| 454 | .word cpu_xsc3_proc_fin |
| 455 | .word cpu_xsc3_reset |
| 456 | .word cpu_xsc3_do_idle |
| 457 | .word cpu_xsc3_dcache_clean_area |
| 458 | .word cpu_xsc3_switch_mm |
Russell King | ad1ae2f | 2006-12-13 14:34:43 +0000 | [diff] [blame] | 459 | .word cpu_xsc3_set_pte_ext |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 460 | .size xsc3_processor_functions, . - xsc3_processor_functions |
| 461 | |
| 462 | .section ".rodata" |
| 463 | |
| 464 | .type cpu_arch_name, #object |
| 465 | cpu_arch_name: |
| 466 | .asciz "armv5te" |
| 467 | .size cpu_arch_name, . - cpu_arch_name |
| 468 | |
| 469 | .type cpu_elf_name, #object |
| 470 | cpu_elf_name: |
| 471 | .asciz "v5" |
| 472 | .size cpu_elf_name, . - cpu_elf_name |
| 473 | |
| 474 | .type cpu_xsc3_name, #object |
| 475 | cpu_xsc3_name: |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 476 | .asciz "XScale-V3 based processor" |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 477 | .size cpu_xsc3_name, . - cpu_xsc3_name |
| 478 | |
| 479 | .align |
| 480 | |
| 481 | .section ".proc.info.init", #alloc, #execinstr |
| 482 | |
| 483 | .type __xsc3_proc_info,#object |
| 484 | __xsc3_proc_info: |
| 485 | .long 0x69056000 |
| 486 | .long 0xffffe000 |
Russell King | 8799ee9 | 2006-06-29 18:24:21 +0100 | [diff] [blame] | 487 | .long PMD_TYPE_SECT | \ |
| 488 | PMD_SECT_BUFFERABLE | \ |
| 489 | PMD_SECT_CACHEABLE | \ |
| 490 | PMD_SECT_AP_WRITE | \ |
| 491 | PMD_SECT_AP_READ |
Lennert Buytenhek | 850b429 | 2007-02-05 00:55:27 +0100 | [diff] [blame] | 492 | .long PMD_TYPE_SECT | \ |
Russell King | 8799ee9 | 2006-06-29 18:24:21 +0100 | [diff] [blame] | 493 | PMD_SECT_AP_WRITE | \ |
| 494 | PMD_SECT_AP_READ |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 495 | b __xsc3_setup |
| 496 | .long cpu_arch_name |
| 497 | .long cpu_elf_name |
| 498 | .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP |
| 499 | .long cpu_xsc3_name |
| 500 | .long xsc3_processor_functions |
| 501 | .long v4wbi_tlb_fns |
| 502 | .long xsc3_mc_user_fns |
| 503 | .long xsc3_cache_fns |
| 504 | .size __xsc3_proc_info, . - __xsc3_proc_info |