2 * linux/arch/arm/mm/proc-sa110.S
4 * Copyright (C) 1997-2002 Russell King
5 * hacked for non-paged-MM by Hyok S. Choi, 2003.
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.
11 * MMU functions for SA110
13 * These are the low level assembler for performing cache and TLB
14 * functions on the StrongARM-110.
16 #include <linux/linkage.h>
17 #include <linux/init.h>
18 #include <asm/assembler.h>
19 #include <asm/asm-offsets.h>
20 #include <asm/procinfo.h>
21 #include <asm/hardware.h>
22 #include <asm/pgtable-hwdef.h>
23 #include <asm/pgtable.h>
24 #include <asm/ptrace.h>
27 * the cache line size of the I and D cache
29 #define DCACHELINESIZE 32
34 * cpu_sa110_proc_init()
36 ENTRY(cpu_sa110_proc_init)
38 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
42 * cpu_sa110_proc_fin()
44 ENTRY(cpu_sa110_proc_fin)
46 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
48 bl v4wb_flush_kern_cache_all @ clean caches
50 mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
51 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
52 bic r0, r0, #0x1000 @ ...i............
53 bic r0, r0, #0x000e @ ............wca.
54 mcr p15, 0, r0, c1, c0, 0 @ disable caches
58 * cpu_sa110_reset(loc)
60 * Perform a soft reset of the system. Put the CPU into the
61 * same state as it would be if it had been reset, and branch
62 * to what would be the reset vector.
64 * loc: location to jump to for soft reset
67 ENTRY(cpu_sa110_reset)
69 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
70 mcr p15, 0, ip, c7, c10, 4 @ drain WB
72 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
74 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
75 bic ip, ip, #0x000f @ ............wcam
76 bic ip, ip, #0x1100 @ ...i...s........
77 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
81 * cpu_sa110_do_idle(type)
83 * Cause the processor to idle
88 * 2 = switch to slow processor clock
89 * 3 = switch to fast processor clock
93 ENTRY(cpu_sa110_do_idle)
94 mcr p15, 0, ip, c15, c2, 2 @ disable clock switching
95 ldr r1, =UNCACHEABLE_ADDR @ load from uncacheable loc
96 ldr r1, [r1, #0] @ force switch to MCLK
100 mcr p15, 0, r0, c15, c8, 2 @ Wait for interrupt, cache aligned
104 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
107 /* ================================= CACHE ================================ */
110 * cpu_sa110_dcache_clean_area(addr,sz)
112 * Clean the specified entry of any caches such that the MMU
113 * translation fetches will obtain correct data.
115 * addr: cache-unaligned virtual address
118 ENTRY(cpu_sa110_dcache_clean_area)
119 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
120 add r0, r0, #DCACHELINESIZE
121 subs r1, r1, #DCACHELINESIZE
125 /* =============================== PageTable ============================== */
128 * cpu_sa110_switch_mm(pgd)
130 * Set the translation base pointer to be as described by pgd.
132 * pgd: new page tables
135 ENTRY(cpu_sa110_switch_mm)
138 bl v4wb_flush_kern_cache_all @ clears IP
139 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
140 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
147 * cpu_sa110_set_pte(ptep, pte)
149 * Set a PTE and flush it out
152 ENTRY(cpu_sa110_set_pte)
154 str r1, [r0], #-2048 @ linux version
156 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
158 bic r2, r1, #PTE_SMALL_AP_MASK
159 bic r2, r2, #PTE_TYPE_MASK
160 orr r2, r2, #PTE_TYPE_SMALL
162 tst r1, #L_PTE_USER @ User?
163 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
165 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
166 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
168 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
171 str r2, [r0] @ hardware version
173 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
174 mcr p15, 0, r0, c7, c10, 4 @ drain WB
180 .type __sa110_setup, #function
183 mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4
184 mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4
186 mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4
191 mrc p15, 0, r0, c1, c0 @ get control register v4
195 .size __sa110_setup, . - __sa110_setup
199 * .RVI ZFRS BLDP WCAM
200 * ..01 0001 ..11 1101
203 .type sa110_crval, #object
205 crval clear=0x00003f3f, mmuset=0x0000113d, ucset=0x00001130
210 * Purpose : Function pointers used to access above functions - all calls
214 .type sa110_processor_functions, #object
215 ENTRY(sa110_processor_functions)
217 .word cpu_sa110_proc_init
218 .word cpu_sa110_proc_fin
219 .word cpu_sa110_reset
220 .word cpu_sa110_do_idle
221 .word cpu_sa110_dcache_clean_area
222 .word cpu_sa110_switch_mm
223 .word cpu_sa110_set_pte
224 .size sa110_processor_functions, . - sa110_processor_functions
228 .type cpu_arch_name, #object
231 .size cpu_arch_name, . - cpu_arch_name
233 .type cpu_elf_name, #object
236 .size cpu_elf_name, . - cpu_elf_name
238 .type cpu_sa110_name, #object
240 .asciz "StrongARM-110"
241 .size cpu_sa110_name, . - cpu_sa110_name
245 .section ".proc.info.init", #alloc, #execinstr
247 .type __sa110_proc_info,#object
251 .long PMD_TYPE_SECT | \
252 PMD_SECT_BUFFERABLE | \
253 PMD_SECT_CACHEABLE | \
254 PMD_SECT_AP_WRITE | \
256 .long PMD_TYPE_SECT | \
257 PMD_SECT_AP_WRITE | \
262 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
264 .long sa110_processor_functions
268 .size __sa110_proc_info, . - __sa110_proc_info