2 * linux/arch/arm/mm/proc-sa1100.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-1100 and StrongARM-1110.
15 * Note that SA1100 and SA1110 share everything but their name and CPU ID.
17 * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
18 * Flush the read buffer at context switches
20 #include <linux/linkage.h>
21 #include <linux/init.h>
22 #include <asm/assembler.h>
23 #include <asm/asm-offsets.h>
24 #include <asm/procinfo.h>
25 #include <asm/hardware.h>
26 #include <asm/pgtable.h>
29 * the cache line size of the I and D cache
31 #define DCACHELINESIZE 32
32 #define FLUSH_OFFSET 32768
34 .macro flush_1100_dcache rd, ra, re
37 eor \ra, \ra, #FLUSH_OFFSET
39 add \re, \ra, #8192 @ only necessary for 8k
40 1001: ldr \rd, [\ra], #DCACHELINESIZE
43 #ifdef FLUSH_BASE_MINICACHE
44 add \ra, \ra, #FLUSH_BASE_MINICACHE - FLUSH_BASE
45 add \re, \ra, #512 @ only 512 bytes
46 1002: ldr \rd, [\ra], #DCACHELINESIZE
60 * cpu_sa1100_proc_init()
62 ENTRY(cpu_sa1100_proc_init)
64 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
65 mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
71 * cpu_sa1100_proc_fin()
73 * Prepare the CPU for reset:
74 * - Disable interrupts
75 * - Clean and turn off caches.
77 ENTRY(cpu_sa1100_proc_fin)
79 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
81 flush_1100_dcache r0, r1, r2 @ clean caches
83 mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
84 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
85 bic r0, r0, #0x1000 @ ...i............
86 bic r0, r0, #0x000e @ ............wca.
87 mcr p15, 0, r0, c1, c0, 0 @ disable caches
91 * cpu_sa1100_reset(loc)
93 * Perform a soft reset of the system. Put the CPU into the
94 * same state as it would be if it had been reset, and branch
95 * to what would be the reset vector.
97 * loc: location to jump to for soft reset
100 ENTRY(cpu_sa1100_reset)
102 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
103 mcr p15, 0, ip, c7, c10, 4 @ drain WB
104 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
105 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
106 bic ip, ip, #0x000f @ ............wcam
107 bic ip, ip, #0x1100 @ ...i...s........
108 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
112 * cpu_sa1100_do_idle(type)
114 * Cause the processor to idle
119 * 2 = switch to slow processor clock
120 * 3 = switch to fast processor clock
123 ENTRY(cpu_sa1100_do_idle)
124 mov r0, r0 @ 4 nop padding
127 mov r0, r0 @ 4 nop padding
131 ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
132 @ --- aligned to a cache line
133 mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
134 ldr r1, [r1, #0] @ force switch to MCLK
135 mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
137 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
140 /* ================================= CACHE ================================ */
143 * cpu_sa1100_dcache_clean_area(addr,sz)
145 * Clean the specified entry of any caches such that the MMU
146 * translation fetches will obtain correct data.
148 * addr: cache-unaligned virtual address
151 ENTRY(cpu_sa1100_dcache_clean_area)
152 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
153 add r0, r0, #DCACHELINESIZE
154 subs r1, r1, #DCACHELINESIZE
158 /* =============================== PageTable ============================== */
161 * cpu_sa1100_switch_mm(pgd)
163 * Set the translation base pointer to be as described by pgd.
165 * pgd: new page tables
168 ENTRY(cpu_sa1100_switch_mm)
169 flush_1100_dcache r3, ip, r1
171 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
172 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
173 mcr p15, 0, ip, c7, c10, 4 @ drain WB
174 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
175 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
179 * cpu_sa1100_set_pte(ptep, pte)
181 * Set a PTE and flush it out
184 ENTRY(cpu_sa1100_set_pte)
185 str r1, [r0], #-2048 @ linux version
187 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
189 bic r2, r1, #PTE_SMALL_AP_MASK
190 bic r2, r2, #PTE_TYPE_MASK
191 orr r2, r2, #PTE_TYPE_SMALL
193 tst r1, #L_PTE_USER @ User?
194 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
196 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
197 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
199 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
202 str r2, [r0] @ hardware version
204 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
205 mcr p15, 0, r0, c7, c10, 4 @ drain WB
210 .type __sa1100_setup, #function
213 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
214 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
215 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
216 mrc p15, 0, r0, c1, c0 @ get control register v4
217 ldr r5, sa1100_cr1_clear
219 ldr r5, sa1100_cr1_set
222 .size __sa1100_setup, . - __sa1100_setup
226 * .RVI ZFRS BLDP WCAM
227 * ..11 0001 ..11 1101
230 .type sa1100_cr1_clear, #object
231 .type sa1100_cr1_set, #object
240 * Purpose : Function pointers used to access above functions - all calls
245 * SA1100 and SA1110 share the same function calls
247 .type sa1100_processor_functions, #object
248 ENTRY(sa1100_processor_functions)
250 .word cpu_sa1100_proc_init
251 .word cpu_sa1100_proc_fin
252 .word cpu_sa1100_reset
253 .word cpu_sa1100_do_idle
254 .word cpu_sa1100_dcache_clean_area
255 .word cpu_sa1100_switch_mm
256 .word cpu_sa1100_set_pte
257 .size sa1100_processor_functions, . - sa1100_processor_functions
261 .type cpu_arch_name, #object
264 .size cpu_arch_name, . - cpu_arch_name
266 .type cpu_elf_name, #object
269 .size cpu_elf_name, . - cpu_elf_name
271 .type cpu_sa1100_name, #object
273 .asciz "StrongARM-1100"
274 .size cpu_sa1100_name, . - cpu_sa1100_name
276 .type cpu_sa1110_name, #object
278 .asciz "StrongARM-1110"
279 .size cpu_sa1110_name, . - cpu_sa1110_name
283 .section ".proc.info.init", #alloc, #execinstr
285 .type __sa1100_proc_info,#object
289 .long PMD_TYPE_SECT | \
290 PMD_SECT_BUFFERABLE | \
291 PMD_SECT_CACHEABLE | \
292 PMD_SECT_AP_WRITE | \
297 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
298 .long cpu_sa1100_name
299 .long sa1100_processor_functions
303 .size __sa1100_proc_info, . - __sa1100_proc_info
305 .type __sa1110_proc_info,#object
309 .long PMD_TYPE_SECT | \
310 PMD_SECT_BUFFERABLE | \
311 PMD_SECT_CACHEABLE | \
312 PMD_SECT_AP_WRITE | \
317 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
318 .long cpu_sa1110_name
319 .long sa1100_processor_functions
323 .size __sa1110_proc_info, . - __sa1110_proc_info