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-hwdef.h>
27 #include <asm/pgtable.h>
30 * the cache line size of the I and D cache
32 #define DCACHELINESIZE 32
37 * cpu_sa1100_proc_init()
39 ENTRY(cpu_sa1100_proc_init)
41 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
42 mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
48 * cpu_sa1100_proc_fin()
50 * Prepare the CPU for reset:
51 * - Disable interrupts
52 * - Clean and turn off caches.
54 ENTRY(cpu_sa1100_proc_fin)
56 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
58 bl v4wb_flush_kern_cache_all
59 mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
60 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
61 bic r0, r0, #0x1000 @ ...i............
62 bic r0, r0, #0x000e @ ............wca.
63 mcr p15, 0, r0, c1, c0, 0 @ disable caches
67 * cpu_sa1100_reset(loc)
69 * Perform a soft reset of the system. Put the CPU into the
70 * same state as it would be if it had been reset, and branch
71 * to what would be the reset vector.
73 * loc: location to jump to for soft reset
76 ENTRY(cpu_sa1100_reset)
78 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
79 mcr p15, 0, ip, c7, c10, 4 @ drain WB
80 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
81 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
82 bic ip, ip, #0x000f @ ............wcam
83 bic ip, ip, #0x1100 @ ...i...s........
84 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
88 * cpu_sa1100_do_idle(type)
90 * Cause the processor to idle
95 * 2 = switch to slow processor clock
96 * 3 = switch to fast processor clock
99 ENTRY(cpu_sa1100_do_idle)
100 mov r0, r0 @ 4 nop padding
103 mov r0, r0 @ 4 nop padding
107 ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
108 @ --- aligned to a cache line
109 mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
110 ldr r1, [r1, #0] @ force switch to MCLK
111 mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
113 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
116 /* ================================= CACHE ================================ */
119 * cpu_sa1100_dcache_clean_area(addr,sz)
121 * Clean the specified entry of any caches such that the MMU
122 * translation fetches will obtain correct data.
124 * addr: cache-unaligned virtual address
127 ENTRY(cpu_sa1100_dcache_clean_area)
128 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
129 add r0, r0, #DCACHELINESIZE
130 subs r1, r1, #DCACHELINESIZE
134 /* =============================== PageTable ============================== */
137 * cpu_sa1100_switch_mm(pgd)
139 * Set the translation base pointer to be as described by pgd.
141 * pgd: new page tables
144 ENTRY(cpu_sa1100_switch_mm)
146 bl v4wb_flush_kern_cache_all @ clears IP
147 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
148 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
149 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
153 * cpu_sa1100_set_pte(ptep, pte)
155 * Set a PTE and flush it out
158 ENTRY(cpu_sa1100_set_pte)
159 str r1, [r0], #-2048 @ linux version
161 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
163 bic r2, r1, #PTE_SMALL_AP_MASK
164 bic r2, r2, #PTE_TYPE_MASK
165 orr r2, r2, #PTE_TYPE_SMALL
167 tst r1, #L_PTE_USER @ User?
168 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
170 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
171 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
173 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
176 str r2, [r0] @ hardware version
178 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
179 mcr p15, 0, r0, c7, c10, 4 @ drain WB
184 .type __sa1100_setup, #function
187 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
188 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
189 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
190 mrc p15, 0, r0, c1, c0 @ get control register v4
191 ldr r5, sa1100_cr1_clear
193 ldr r5, sa1100_cr1_set
196 .size __sa1100_setup, . - __sa1100_setup
200 * .RVI ZFRS BLDP WCAM
201 * ..11 0001 ..11 1101
204 .type sa1100_cr1_clear, #object
205 .type sa1100_cr1_set, #object
214 * Purpose : Function pointers used to access above functions - all calls
219 * SA1100 and SA1110 share the same function calls
221 .type sa1100_processor_functions, #object
222 ENTRY(sa1100_processor_functions)
224 .word cpu_sa1100_proc_init
225 .word cpu_sa1100_proc_fin
226 .word cpu_sa1100_reset
227 .word cpu_sa1100_do_idle
228 .word cpu_sa1100_dcache_clean_area
229 .word cpu_sa1100_switch_mm
230 .word cpu_sa1100_set_pte
231 .size sa1100_processor_functions, . - sa1100_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_sa1100_name, #object
247 .asciz "StrongARM-1100"
248 .size cpu_sa1100_name, . - cpu_sa1100_name
250 .type cpu_sa1110_name, #object
252 .asciz "StrongARM-1110"
253 .size cpu_sa1110_name, . - cpu_sa1110_name
257 .section ".proc.info.init", #alloc, #execinstr
259 .type __sa1100_proc_info,#object
263 .long PMD_TYPE_SECT | \
264 PMD_SECT_BUFFERABLE | \
265 PMD_SECT_CACHEABLE | \
266 PMD_SECT_AP_WRITE | \
271 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
272 .long cpu_sa1100_name
273 .long sa1100_processor_functions
277 .size __sa1100_proc_info, . - __sa1100_proc_info
279 .type __sa1110_proc_info,#object
283 .long PMD_TYPE_SECT | \
284 PMD_SECT_BUFFERABLE | \
285 PMD_SECT_CACHEABLE | \
286 PMD_SECT_AP_WRITE | \
291 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
292 .long cpu_sa1110_name
293 .long sa1100_processor_functions
297 .size __sa1110_proc_info, . - __sa1110_proc_info