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/constants.h>
19 #include <asm/procinfo.h>
20 #include <asm/hardware.h>
21 #include <asm/pgtable.h>
22 #include <asm/ptrace.h>
25 * the cache line size of the I and D cache
27 #define DCACHELINESIZE 32
28 #define FLUSH_OFFSET 32768
30 .macro flush_110_dcache rd, ra, re
33 eor \ra, \ra, #FLUSH_OFFSET
35 add \re, \ra, #16384 @ only necessary for 16k
36 1001: ldr \rd, [\ra], #DCACHELINESIZE
47 * cpu_sa110_proc_init()
49 ENTRY(cpu_sa110_proc_init)
51 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
55 * cpu_sa110_proc_fin()
57 ENTRY(cpu_sa110_proc_fin)
59 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
61 bl v4wb_flush_kern_cache_all @ clean caches
63 mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
64 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
65 bic r0, r0, #0x1000 @ ...i............
66 bic r0, r0, #0x000e @ ............wca.
67 mcr p15, 0, r0, c1, c0, 0 @ disable caches
71 * cpu_sa110_reset(loc)
73 * Perform a soft reset of the system. Put the CPU into the
74 * same state as it would be if it had been reset, and branch
75 * to what would be the reset vector.
77 * loc: location to jump to for soft reset
80 ENTRY(cpu_sa110_reset)
82 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
83 mcr p15, 0, ip, c7, c10, 4 @ drain WB
84 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
85 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
86 bic ip, ip, #0x000f @ ............wcam
87 bic ip, ip, #0x1100 @ ...i...s........
88 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
92 * cpu_sa110_do_idle(type)
94 * Cause the processor to idle
99 * 2 = switch to slow processor clock
100 * 3 = switch to fast processor clock
104 ENTRY(cpu_sa110_do_idle)
105 mcr p15, 0, ip, c15, c2, 2 @ disable clock switching
106 ldr r1, =UNCACHEABLE_ADDR @ load from uncacheable loc
107 ldr r1, [r1, #0] @ force switch to MCLK
111 mcr p15, 0, r0, c15, c8, 2 @ Wait for interrupt, cache aligned
115 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
118 /* ================================= CACHE ================================ */
121 * cpu_sa110_dcache_clean_area(addr,sz)
123 * Clean the specified entry of any caches such that the MMU
124 * translation fetches will obtain correct data.
126 * addr: cache-unaligned virtual address
129 ENTRY(cpu_sa110_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
136 /* =============================== PageTable ============================== */
139 * cpu_sa110_switch_mm(pgd)
141 * Set the translation base pointer to be as described by pgd.
143 * pgd: new page tables
146 ENTRY(cpu_sa110_switch_mm)
147 flush_110_dcache r3, ip, r1
149 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
150 mcr p15, 0, r1, c7, c10, 4 @ drain WB
151 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
152 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
156 * cpu_sa110_set_pte(ptep, pte)
158 * Set a PTE and flush it out
161 ENTRY(cpu_sa110_set_pte)
162 str r1, [r0], #-2048 @ linux version
164 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
166 bic r2, r1, #PTE_SMALL_AP_MASK
167 bic r2, r2, #PTE_TYPE_MASK
168 orr r2, r2, #PTE_TYPE_SMALL
170 tst r1, #L_PTE_USER @ User?
171 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
173 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
174 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
176 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
179 str r2, [r0] @ hardware version
181 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
182 mcr p15, 0, r0, c7, c10, 4 @ drain WB
187 .type __sa110_setup, #function
190 mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4
191 mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4
192 mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4
193 mrc p15, 0, r0, c1, c0 @ get control register v4
194 ldr r5, sa110_cr1_clear
196 ldr r5, sa110_cr1_set
199 .size __sa110_setup, . - __sa110_setup
203 * .RVI ZFRS BLDP WCAM
204 * ..01 0001 ..11 1101
207 .type sa110_cr1_clear, #object
208 .type sa110_cr1_set, #object
217 * Purpose : Function pointers used to access above functions - all calls
221 .type sa110_processor_functions, #object
222 ENTRY(sa110_processor_functions)
224 .word cpu_sa110_proc_init
225 .word cpu_sa110_proc_fin
226 .word cpu_sa110_reset
227 .word cpu_sa110_do_idle
228 .word cpu_sa110_dcache_clean_area
229 .word cpu_sa110_switch_mm
230 .word cpu_sa110_set_pte
231 .size sa110_processor_functions, . - sa110_processor_functions
235 .type cpu_arch_name, #object
238 .size cpu_arch_name, . - cpu_arch_name
240 .type cpu_elf_name, #object
243 .size cpu_elf_name, . - cpu_elf_name
245 .type cpu_sa110_name, #object
247 .asciz "StrongARM-110"
248 .size cpu_sa110_name, . - cpu_sa110_name
252 .section ".proc.info", #alloc, #execinstr
254 .type __sa110_proc_info,#object
258 .long PMD_TYPE_SECT | \
259 PMD_SECT_BUFFERABLE | \
260 PMD_SECT_CACHEABLE | \
261 PMD_SECT_AP_WRITE | \
266 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
268 .long sa110_processor_functions
272 .size __sa110_proc_info, . - __sa110_proc_info