2 * linux/arch/arm/mm/proc-sa1100.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-1100 and StrongARM-1110.
16 * Note that SA1100 and SA1110 share everything but their name and CPU ID.
18 * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
19 * Flush the read buffer at context switches
21 #include <linux/linkage.h>
22 #include <linux/init.h>
23 #include <asm/assembler.h>
24 #include <asm/asm-offsets.h>
25 #include <asm/procinfo.h>
26 #include <asm/hardware.h>
27 #include <asm/pgtable-hwdef.h>
28 #include <asm/pgtable.h>
31 * the cache line size of the I and D cache
33 #define DCACHELINESIZE 32
38 * cpu_sa1100_proc_init()
40 ENTRY(cpu_sa1100_proc_init)
42 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
43 mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
49 * cpu_sa1100_proc_fin()
51 * Prepare the CPU for reset:
52 * - Disable interrupts
53 * - Clean and turn off caches.
55 ENTRY(cpu_sa1100_proc_fin)
57 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
59 bl v4wb_flush_kern_cache_all
60 mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
61 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
62 bic r0, r0, #0x1000 @ ...i............
63 bic r0, r0, #0x000e @ ............wca.
64 mcr p15, 0, r0, c1, c0, 0 @ disable caches
68 * cpu_sa1100_reset(loc)
70 * Perform a soft reset of the system. Put the CPU into the
71 * same state as it would be if it had been reset, and branch
72 * to what would be the reset vector.
74 * loc: location to jump to for soft reset
77 ENTRY(cpu_sa1100_reset)
79 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
80 mcr p15, 0, ip, c7, c10, 4 @ drain WB
82 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
84 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
85 bic ip, ip, #0x000f @ ............wcam
86 bic ip, ip, #0x1100 @ ...i...s........
87 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
91 * cpu_sa1100_do_idle(type)
93 * Cause the processor to idle
98 * 2 = switch to slow processor clock
99 * 3 = switch to fast processor clock
102 ENTRY(cpu_sa1100_do_idle)
103 mov r0, r0 @ 4 nop padding
106 mov r0, r0 @ 4 nop padding
110 ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
111 @ --- aligned to a cache line
112 mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
113 ldr r1, [r1, #0] @ force switch to MCLK
114 mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
116 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
119 /* ================================= CACHE ================================ */
122 * cpu_sa1100_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_sa1100_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_sa1100_switch_mm(pgd)
142 * Set the translation base pointer to be as described by pgd.
144 * pgd: new page tables
147 ENTRY(cpu_sa1100_switch_mm)
150 bl v4wb_flush_kern_cache_all @ clears IP
151 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
152 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
153 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
160 * cpu_sa1100_set_pte(ptep, pte)
162 * Set a PTE and flush it out
165 ENTRY(cpu_sa1100_set_pte)
167 str r1, [r0], #-2048 @ linux version
169 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
171 bic r2, r1, #PTE_SMALL_AP_MASK
172 bic r2, r2, #PTE_TYPE_MASK
173 orr r2, r2, #PTE_TYPE_SMALL
175 tst r1, #L_PTE_USER @ User?
176 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
178 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
179 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
181 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
184 str r2, [r0] @ hardware version
186 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
187 mcr p15, 0, r0, c7, c10, 4 @ drain WB
193 .type __sa1100_setup, #function
196 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
197 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
199 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
203 mrc p15, 0, r0, c1, c0 @ get control register v4
207 .size __sa1100_setup, . - __sa1100_setup
211 * .RVI ZFRS BLDP WCAM
212 * ..11 0001 ..11 1101
215 .type sa1100_crval, #object
217 crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130
222 * Purpose : Function pointers used to access above functions - all calls
227 * SA1100 and SA1110 share the same function calls
229 .type sa1100_processor_functions, #object
230 ENTRY(sa1100_processor_functions)
232 .word cpu_sa1100_proc_init
233 .word cpu_sa1100_proc_fin
234 .word cpu_sa1100_reset
235 .word cpu_sa1100_do_idle
236 .word cpu_sa1100_dcache_clean_area
237 .word cpu_sa1100_switch_mm
238 .word cpu_sa1100_set_pte
239 .size sa1100_processor_functions, . - sa1100_processor_functions
243 .type cpu_arch_name, #object
246 .size cpu_arch_name, . - cpu_arch_name
248 .type cpu_elf_name, #object
251 .size cpu_elf_name, . - cpu_elf_name
253 .type cpu_sa1100_name, #object
255 .asciz "StrongARM-1100"
256 .size cpu_sa1100_name, . - cpu_sa1100_name
258 .type cpu_sa1110_name, #object
260 .asciz "StrongARM-1110"
261 .size cpu_sa1110_name, . - cpu_sa1110_name
265 .section ".proc.info.init", #alloc, #execinstr
267 .type __sa1100_proc_info,#object
271 .long PMD_TYPE_SECT | \
272 PMD_SECT_BUFFERABLE | \
273 PMD_SECT_CACHEABLE | \
274 PMD_SECT_AP_WRITE | \
276 .long PMD_TYPE_SECT | \
277 PMD_SECT_AP_WRITE | \
282 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
283 .long cpu_sa1100_name
284 .long sa1100_processor_functions
288 .size __sa1100_proc_info, . - __sa1100_proc_info
290 .type __sa1110_proc_info,#object
294 .long PMD_TYPE_SECT | \
295 PMD_SECT_BUFFERABLE | \
296 PMD_SECT_CACHEABLE | \
297 PMD_SECT_AP_WRITE | \
299 .long PMD_TYPE_SECT | \
300 PMD_SECT_AP_WRITE | \
305 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
306 .long cpu_sa1110_name
307 .long sa1100_processor_functions
311 .size __sa1110_proc_info, . - __sa1110_proc_info