Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mm/proc-sa1100.S |
| 3 | * |
| 4 | * Copyright (C) 1997-2002 Russell King |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 5 | * hacked for non-paged-MM by Hyok S. Choi, 2003. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * MMU functions for SA110 |
| 12 | * |
| 13 | * These are the low level assembler for performing cache and TLB |
| 14 | * functions on the StrongARM-1100 and StrongARM-1110. |
| 15 | * |
| 16 | * Note that SA1100 and SA1110 share everything but their name and CPU ID. |
| 17 | * |
| 18 | * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl): |
| 19 | * Flush the read buffer at context switches |
| 20 | */ |
| 21 | #include <linux/linkage.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <asm/assembler.h> |
Sam Ravnborg | e6ae744 | 2005-09-09 21:08:59 +0200 | [diff] [blame] | 24 | #include <asm/asm-offsets.h> |
Russell King | 5ec9407 | 2008-09-07 19:15:31 +0100 | [diff] [blame] | 25 | #include <asm/hwcap.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/hardware.h> |
Russell King | 74945c8 | 2006-03-16 14:44:36 +0000 | [diff] [blame] | 27 | #include <asm/pgtable-hwdef.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <asm/pgtable.h> |
| 29 | |
Thomas Gleixner | bb8d5a5 | 2006-07-03 02:21:18 +0200 | [diff] [blame] | 30 | #include "proc-macros.S" |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | /* |
| 33 | * the cache line size of the I and D cache |
| 34 | */ |
| 35 | #define DCACHELINESIZE 32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Russell King | b69874e | 2011-06-21 18:57:31 +0100 | [diff] [blame] | 37 | .section .text |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * cpu_sa1100_proc_init() |
| 41 | */ |
| 42 | ENTRY(cpu_sa1100_proc_init) |
| 43 | mov r0, #0 |
| 44 | mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching |
| 45 | mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland |
| 46 | mov pc, lr |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | /* |
| 49 | * cpu_sa1100_proc_fin() |
| 50 | * |
| 51 | * Prepare the CPU for reset: |
| 52 | * - Disable interrupts |
| 53 | * - Clean and turn off caches. |
| 54 | */ |
| 55 | ENTRY(cpu_sa1100_proc_fin) |
Russell King | 95f3df6 | 2006-04-07 13:17:15 +0100 | [diff] [blame] | 56 | mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | mrc p15, 0, r0, c1, c0, 0 @ ctrl register |
| 58 | bic r0, r0, #0x1000 @ ...i............ |
| 59 | bic r0, r0, #0x000e @ ............wca. |
| 60 | mcr p15, 0, r0, c1, c0, 0 @ disable caches |
Russell King | 9ca03a2 | 2010-07-26 12:22:12 +0100 | [diff] [blame] | 61 | mov pc, lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * cpu_sa1100_reset(loc) |
| 65 | * |
| 66 | * Perform a soft reset of the system. Put the CPU into the |
| 67 | * same state as it would be if it had been reset, and branch |
| 68 | * to what would be the reset vector. |
| 69 | * |
| 70 | * loc: location to jump to for soft reset |
| 71 | */ |
| 72 | .align 5 |
Will Deacon | 1a4baaf | 2011-11-15 13:25:04 +0000 | [diff] [blame] | 73 | .pushsection .idmap.text, "ax" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | ENTRY(cpu_sa1100_reset) |
| 75 | mov ip, #0 |
| 76 | mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches |
| 77 | mcr p15, 0, ip, c7, c10, 4 @ drain WB |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 78 | #ifdef CONFIG_MMU |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 80 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | mrc p15, 0, ip, c1, c0, 0 @ ctrl register |
| 82 | bic ip, ip, #0x000f @ ............wcam |
| 83 | bic ip, ip, #0x1100 @ ...i...s........ |
| 84 | mcr p15, 0, ip, c1, c0, 0 @ ctrl register |
| 85 | mov pc, r0 |
Will Deacon | 1a4baaf | 2011-11-15 13:25:04 +0000 | [diff] [blame] | 86 | ENDPROC(cpu_sa1100_reset) |
| 87 | .popsection |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | /* |
| 90 | * cpu_sa1100_do_idle(type) |
| 91 | * |
| 92 | * Cause the processor to idle |
| 93 | * |
| 94 | * type: call type: |
| 95 | * 0 = slow idle |
| 96 | * 1 = fast idle |
| 97 | * 2 = switch to slow processor clock |
| 98 | * 3 = switch to fast processor clock |
| 99 | */ |
| 100 | .align 5 |
| 101 | ENTRY(cpu_sa1100_do_idle) |
| 102 | mov r0, r0 @ 4 nop padding |
| 103 | mov r0, r0 |
| 104 | mov r0, r0 |
| 105 | mov r0, r0 @ 4 nop padding |
| 106 | mov r0, r0 |
| 107 | mov r0, r0 |
| 108 | mov r0, #0 |
| 109 | ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address |
| 110 | @ --- aligned to a cache line |
| 111 | mcr p15, 0, r0, c15, c2, 2 @ disable clock switching |
| 112 | ldr r1, [r1, #0] @ force switch to MCLK |
| 113 | mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt |
| 114 | mov r0, r0 @ safety |
| 115 | mcr p15, 0, r0, c15, c1, 2 @ enable clock switching |
| 116 | mov pc, lr |
| 117 | |
| 118 | /* ================================= CACHE ================================ */ |
| 119 | |
| 120 | /* |
| 121 | * cpu_sa1100_dcache_clean_area(addr,sz) |
| 122 | * |
| 123 | * Clean the specified entry of any caches such that the MMU |
| 124 | * translation fetches will obtain correct data. |
| 125 | * |
| 126 | * addr: cache-unaligned virtual address |
| 127 | */ |
| 128 | .align 5 |
| 129 | ENTRY(cpu_sa1100_dcache_clean_area) |
| 130 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 131 | add r0, r0, #DCACHELINESIZE |
| 132 | subs r1, r1, #DCACHELINESIZE |
| 133 | bhi 1b |
| 134 | mov pc, lr |
| 135 | |
| 136 | /* =============================== PageTable ============================== */ |
| 137 | |
| 138 | /* |
| 139 | * cpu_sa1100_switch_mm(pgd) |
| 140 | * |
| 141 | * Set the translation base pointer to be as described by pgd. |
| 142 | * |
| 143 | * pgd: new page tables |
| 144 | */ |
| 145 | .align 5 |
| 146 | ENTRY(cpu_sa1100_switch_mm) |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 147 | #ifdef CONFIG_MMU |
Russell King | 95f3df6 | 2006-04-07 13:17:15 +0100 | [diff] [blame] | 148 | str lr, [sp, #-4]! |
| 149 | bl v4wb_flush_kern_cache_all @ clears IP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | mcr p15, 0, ip, c9, c0, 0 @ invalidate RB |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | mcr p15, 0, r0, c2, c0, 0 @ load page table pointer |
| 152 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
Russell King | 95f3df6 | 2006-04-07 13:17:15 +0100 | [diff] [blame] | 153 | ldr pc, [sp], #4 |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 154 | #else |
| 155 | mov pc, lr |
| 156 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
| 158 | /* |
Russell King | ad1ae2f | 2006-12-13 14:34:43 +0000 | [diff] [blame] | 159 | * cpu_sa1100_set_pte_ext(ptep, pte, ext) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | * |
| 161 | * Set a PTE and flush it out |
| 162 | */ |
| 163 | .align 5 |
Russell King | ad1ae2f | 2006-12-13 14:34:43 +0000 | [diff] [blame] | 164 | ENTRY(cpu_sa1100_set_pte_ext) |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 165 | #ifdef CONFIG_MMU |
Russell King | da09165 | 2008-09-06 17:19:08 +0100 | [diff] [blame] | 166 | armv3_set_pte_ext wc_disable=0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | mov r0, r0 |
| 168 | mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
| 169 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 170 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | mov pc, lr |
| 172 | |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 173 | .globl cpu_sa1100_suspend_size |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 174 | .equ cpu_sa1100_suspend_size, 4 * 3 |
Russell King | b6c7aab | 2013-04-08 11:44:57 +0100 | [diff] [blame] | 175 | #ifdef CONFIG_ARM_CPU_SUSPEND |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 176 | ENTRY(cpu_sa1100_do_suspend) |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 177 | stmfd sp!, {r4 - r6, lr} |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 178 | mrc p15, 0, r4, c3, c0, 0 @ domain ID |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 179 | mrc p15, 0, r5, c13, c0, 0 @ PID |
| 180 | mrc p15, 0, r6, c1, c0, 0 @ control reg |
| 181 | stmia r0, {r4 - r6} @ store cp regs |
| 182 | ldmfd sp!, {r4 - r6, pc} |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 183 | ENDPROC(cpu_sa1100_do_suspend) |
| 184 | |
| 185 | ENTRY(cpu_sa1100_do_resume) |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 186 | ldmia r0, {r4 - r6} @ load cp regs |
Russell King | 6f354e5 | 2011-08-27 11:37:58 +0100 | [diff] [blame] | 187 | mov ip, #0 |
| 188 | mcr p15, 0, ip, c8, c7, 0 @ flush I+D TLBs |
| 189 | mcr p15, 0, ip, c7, c7, 0 @ flush I&D cache |
| 190 | mcr p15, 0, ip, c9, c0, 0 @ invalidate RB |
| 191 | mcr p15, 0, ip, c9, c0, 5 @ allow user space to use RB |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 192 | |
| 193 | mcr p15, 0, r4, c3, c0, 0 @ domain ID |
Russell King | de8e71c | 2011-08-27 22:39:09 +0100 | [diff] [blame] | 194 | mcr p15, 0, r1, c2, c0, 0 @ translation table base addr |
| 195 | mcr p15, 0, r5, c13, c0, 0 @ PID |
| 196 | mov r0, r6 @ control register |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 197 | b cpu_resume_mmu |
| 198 | ENDPROC(cpu_sa1100_do_resume) |
Russell King | f6b0fa0 | 2011-02-06 15:48:39 +0000 | [diff] [blame] | 199 | #endif |
| 200 | |
Russell King | 5085f3f | 2010-10-01 15:37:05 +0100 | [diff] [blame] | 201 | __CPUINIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
| 203 | .type __sa1100_setup, #function |
| 204 | __sa1100_setup: |
| 205 | mov r0, #0 |
| 206 | mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4 |
| 207 | mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4 |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 208 | #ifdef CONFIG_MMU |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 |
Hyok S. Choi | d090ddd | 2006-06-28 14:10:01 +0100 | [diff] [blame] | 210 | #endif |
Russell King | 22b19086 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 211 | adr r5, sa1100_crval |
| 212 | ldmia r5, {r5, r6} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | mrc p15, 0, r0, c1, c0 @ get control register v4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | bic r0, r0, r5 |
Russell King | 22b19086 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 215 | orr r0, r0, r6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | mov pc, lr |
| 217 | .size __sa1100_setup, . - __sa1100_setup |
| 218 | |
| 219 | /* |
| 220 | * R |
| 221 | * .RVI ZFRS BLDP WCAM |
| 222 | * ..11 0001 ..11 1101 |
| 223 | * |
| 224 | */ |
Russell King | 22b19086 | 2006-06-29 15:09:57 +0100 | [diff] [blame] | 225 | .type sa1100_crval, #object |
| 226 | sa1100_crval: |
| 227 | crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | __INITDATA |
| 230 | |
| 231 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | * SA1100 and SA1110 share the same function calls |
| 233 | */ |
Dave Martin | f58d59f | 2011-06-23 17:25:30 +0100 | [diff] [blame] | 234 | |
| 235 | @ define struct processor (see <asm/proc-fns.h> and proc-macros.S) |
| 236 | define_processor_functions sa1100, dabort=v4_early_abort, pabort=legacy_pabort, suspend=1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
| 238 | .section ".rodata" |
| 239 | |
Dave Martin | f58d59f | 2011-06-23 17:25:30 +0100 | [diff] [blame] | 240 | string cpu_arch_name, "armv4" |
| 241 | string cpu_elf_name, "v4" |
| 242 | string cpu_sa1100_name, "StrongARM-1100" |
| 243 | string cpu_sa1110_name, "StrongARM-1110" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | |
| 245 | .align |
| 246 | |
Ben Dooks | 02b7dd1 | 2005-09-20 16:35:03 +0100 | [diff] [blame] | 247 | .section ".proc.info.init", #alloc, #execinstr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Dave Martin | f58d59f | 2011-06-23 17:25:30 +0100 | [diff] [blame] | 249 | .macro sa1100_proc_info name:req, cpu_val:req, cpu_mask:req, cpu_name:req |
| 250 | .type __\name\()_proc_info,#object |
| 251 | __\name\()_proc_info: |
| 252 | .long \cpu_val |
| 253 | .long \cpu_mask |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | .long PMD_TYPE_SECT | \ |
| 255 | PMD_SECT_BUFFERABLE | \ |
| 256 | PMD_SECT_CACHEABLE | \ |
| 257 | PMD_SECT_AP_WRITE | \ |
| 258 | PMD_SECT_AP_READ |
Russell King | 8799ee9 | 2006-06-29 18:24:21 +0100 | [diff] [blame] | 259 | .long PMD_TYPE_SECT | \ |
| 260 | PMD_SECT_AP_WRITE | \ |
| 261 | PMD_SECT_AP_READ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | b __sa1100_setup |
| 263 | .long cpu_arch_name |
| 264 | .long cpu_elf_name |
| 265 | .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT |
Dave Martin | f58d59f | 2011-06-23 17:25:30 +0100 | [diff] [blame] | 266 | .long \cpu_name |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | .long sa1100_processor_functions |
| 268 | .long v4wb_tlb_fns |
| 269 | .long v4_mc_user_fns |
| 270 | .long v4wb_cache_fns |
Dave Martin | f58d59f | 2011-06-23 17:25:30 +0100 | [diff] [blame] | 271 | .size __\name\()_proc_info, . - __\name\()_proc_info |
| 272 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
Dave Martin | f58d59f | 2011-06-23 17:25:30 +0100 | [diff] [blame] | 274 | sa1100_proc_info sa1100, 0x4401a110, 0xfffffff0, cpu_sa1100_name |
| 275 | sa1100_proc_info sa1110, 0x6901b110, 0xfffffff0, cpu_sa1110_name |