2 * linux/arch/arm/mm/proc-sa110.S
4 * Copyright (C) 1997-2002 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * MMU functions for SA110
12 * These are the low level assembler for performing cache and TLB
13 * functions on the StrongARM-110.
15 #include <linux/linkage.h>
16 #include <linux/init.h>
17 #include <asm/assembler.h>
18 #include <asm/asm-offsets.h>
19 #include <asm/procinfo.h>
20 #include <asm/hardware.h>
21 #include <asm/pgtable-hwdef.h>
22 #include <asm/pgtable.h>
23 #include <asm/ptrace.h>
26 * the cache line size of the I and D cache
28 #define DCACHELINESIZE 32
29 #define FLUSH_OFFSET 32768
31 .macro flush_110_dcache rd, ra, re
34 eor \ra, \ra, #FLUSH_OFFSET
36 add \re, \ra, #16384 @ only necessary for 16k
37 1001: ldr \rd, [\ra], #DCACHELINESIZE
48 * cpu_sa110_proc_init()
50 ENTRY(cpu_sa110_proc_init)
52 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
56 * cpu_sa110_proc_fin()
58 ENTRY(cpu_sa110_proc_fin)
60 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
62 bl v4wb_flush_kern_cache_all @ clean caches
64 mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
65 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
66 bic r0, r0, #0x1000 @ ...i............
67 bic r0, r0, #0x000e @ ............wca.
68 mcr p15, 0, r0, c1, c0, 0 @ disable caches
72 * cpu_sa110_reset(loc)
74 * Perform a soft reset of the system. Put the CPU into the
75 * same state as it would be if it had been reset, and branch
76 * to what would be the reset vector.
78 * loc: location to jump to for soft reset
81 ENTRY(cpu_sa110_reset)
83 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
84 mcr p15, 0, ip, c7, c10, 4 @ drain WB
85 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
86 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
87 bic ip, ip, #0x000f @ ............wcam
88 bic ip, ip, #0x1100 @ ...i...s........
89 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
93 * cpu_sa110_do_idle(type)
95 * Cause the processor to idle
100 * 2 = switch to slow processor clock
101 * 3 = switch to fast processor clock
105 ENTRY(cpu_sa110_do_idle)
106 mcr p15, 0, ip, c15, c2, 2 @ disable clock switching
107 ldr r1, =UNCACHEABLE_ADDR @ load from uncacheable loc
108 ldr r1, [r1, #0] @ force switch to MCLK
112 mcr p15, 0, r0, c15, c8, 2 @ Wait for interrupt, cache aligned
116 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
119 /* ================================= CACHE ================================ */
122 * cpu_sa110_dcache_clean_area(addr,sz)
124 * Clean the specified entry of any caches such that the MMU
125 * translation fetches will obtain correct data.
127 * addr: cache-unaligned virtual address
130 ENTRY(cpu_sa110_dcache_clean_area)
131 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
132 add r0, r0, #DCACHELINESIZE
133 subs r1, r1, #DCACHELINESIZE
137 /* =============================== PageTable ============================== */
140 * cpu_sa110_switch_mm(pgd)
142 * Set the translation base pointer to be as described by pgd.
144 * pgd: new page tables
147 ENTRY(cpu_sa110_switch_mm)
148 flush_110_dcache r3, ip, r1
150 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
151 mcr p15, 0, r1, c7, c10, 4 @ drain WB
152 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
153 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
157 * cpu_sa110_set_pte(ptep, pte)
159 * Set a PTE and flush it out
162 ENTRY(cpu_sa110_set_pte)
163 str r1, [r0], #-2048 @ linux version
165 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
167 bic r2, r1, #PTE_SMALL_AP_MASK
168 bic r2, r2, #PTE_TYPE_MASK
169 orr r2, r2, #PTE_TYPE_SMALL
171 tst r1, #L_PTE_USER @ User?
172 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
174 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
175 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
177 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
180 str r2, [r0] @ hardware version
182 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
183 mcr p15, 0, r0, c7, c10, 4 @ drain WB
188 .type __sa110_setup, #function
191 mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4
192 mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4
193 mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4
194 mrc p15, 0, r0, c1, c0 @ get control register v4
195 ldr r5, sa110_cr1_clear
197 ldr r5, sa110_cr1_set
200 .size __sa110_setup, . - __sa110_setup
204 * .RVI ZFRS BLDP WCAM
205 * ..01 0001 ..11 1101
208 .type sa110_cr1_clear, #object
209 .type sa110_cr1_set, #object
218 * Purpose : Function pointers used to access above functions - all calls
222 .type sa110_processor_functions, #object
223 ENTRY(sa110_processor_functions)
225 .word cpu_sa110_proc_init
226 .word cpu_sa110_proc_fin
227 .word cpu_sa110_reset
228 .word cpu_sa110_do_idle
229 .word cpu_sa110_dcache_clean_area
230 .word cpu_sa110_switch_mm
231 .word cpu_sa110_set_pte
232 .size sa110_processor_functions, . - sa110_processor_functions
236 .type cpu_arch_name, #object
239 .size cpu_arch_name, . - cpu_arch_name
241 .type cpu_elf_name, #object
244 .size cpu_elf_name, . - cpu_elf_name
246 .type cpu_sa110_name, #object
248 .asciz "StrongARM-110"
249 .size cpu_sa110_name, . - cpu_sa110_name
253 .section ".proc.info.init", #alloc, #execinstr
255 .type __sa110_proc_info,#object
259 .long PMD_TYPE_SECT | \
260 PMD_SECT_BUFFERABLE | \
261 PMD_SECT_CACHEABLE | \
262 PMD_SECT_AP_WRITE | \
267 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
269 .long sa110_processor_functions
273 .size __sa110_proc_info, . - __sa110_proc_info