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
33 * cpu_sa110_proc_init()
35 ENTRY(cpu_sa110_proc_init)
37 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
41 * cpu_sa110_proc_fin()
43 ENTRY(cpu_sa110_proc_fin)
45 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
47 bl v4wb_flush_kern_cache_all @ clean caches
49 mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
50 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
51 bic r0, r0, #0x1000 @ ...i............
52 bic r0, r0, #0x000e @ ............wca.
53 mcr p15, 0, r0, c1, c0, 0 @ disable caches
57 * cpu_sa110_reset(loc)
59 * Perform a soft reset of the system. Put the CPU into the
60 * same state as it would be if it had been reset, and branch
61 * to what would be the reset vector.
63 * loc: location to jump to for soft reset
66 ENTRY(cpu_sa110_reset)
68 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
69 mcr p15, 0, ip, c7, c10, 4 @ drain WB
70 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
71 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
72 bic ip, ip, #0x000f @ ............wcam
73 bic ip, ip, #0x1100 @ ...i...s........
74 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
78 * cpu_sa110_do_idle(type)
80 * Cause the processor to idle
85 * 2 = switch to slow processor clock
86 * 3 = switch to fast processor clock
90 ENTRY(cpu_sa110_do_idle)
91 mcr p15, 0, ip, c15, c2, 2 @ disable clock switching
92 ldr r1, =UNCACHEABLE_ADDR @ load from uncacheable loc
93 ldr r1, [r1, #0] @ force switch to MCLK
97 mcr p15, 0, r0, c15, c8, 2 @ Wait for interrupt, cache aligned
101 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
104 /* ================================= CACHE ================================ */
107 * cpu_sa110_dcache_clean_area(addr,sz)
109 * Clean the specified entry of any caches such that the MMU
110 * translation fetches will obtain correct data.
112 * addr: cache-unaligned virtual address
115 ENTRY(cpu_sa110_dcache_clean_area)
116 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
117 add r0, r0, #DCACHELINESIZE
118 subs r1, r1, #DCACHELINESIZE
122 /* =============================== PageTable ============================== */
125 * cpu_sa110_switch_mm(pgd)
127 * Set the translation base pointer to be as described by pgd.
129 * pgd: new page tables
132 ENTRY(cpu_sa110_switch_mm)
134 bl v4wb_flush_kern_cache_all @ clears IP
135 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
136 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
140 * cpu_sa110_set_pte(ptep, pte)
142 * Set a PTE and flush it out
145 ENTRY(cpu_sa110_set_pte)
146 str r1, [r0], #-2048 @ linux version
148 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
150 bic r2, r1, #PTE_SMALL_AP_MASK
151 bic r2, r2, #PTE_TYPE_MASK
152 orr r2, r2, #PTE_TYPE_SMALL
154 tst r1, #L_PTE_USER @ User?
155 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
157 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
158 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
160 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
163 str r2, [r0] @ hardware version
165 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
166 mcr p15, 0, r0, c7, c10, 4 @ drain WB
171 .type __sa110_setup, #function
174 mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4
175 mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4
176 mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4
177 mrc p15, 0, r0, c1, c0 @ get control register v4
178 ldr r5, sa110_cr1_clear
180 ldr r5, sa110_cr1_set
183 .size __sa110_setup, . - __sa110_setup
187 * .RVI ZFRS BLDP WCAM
188 * ..01 0001 ..11 1101
191 .type sa110_cr1_clear, #object
192 .type sa110_cr1_set, #object
201 * Purpose : Function pointers used to access above functions - all calls
205 .type sa110_processor_functions, #object
206 ENTRY(sa110_processor_functions)
208 .word cpu_sa110_proc_init
209 .word cpu_sa110_proc_fin
210 .word cpu_sa110_reset
211 .word cpu_sa110_do_idle
212 .word cpu_sa110_dcache_clean_area
213 .word cpu_sa110_switch_mm
214 .word cpu_sa110_set_pte
215 .size sa110_processor_functions, . - sa110_processor_functions
219 .type cpu_arch_name, #object
222 .size cpu_arch_name, . - cpu_arch_name
224 .type cpu_elf_name, #object
227 .size cpu_elf_name, . - cpu_elf_name
229 .type cpu_sa110_name, #object
231 .asciz "StrongARM-110"
232 .size cpu_sa110_name, . - cpu_sa110_name
236 .section ".proc.info.init", #alloc, #execinstr
238 .type __sa110_proc_info,#object
242 .long PMD_TYPE_SECT | \
243 PMD_SECT_BUFFERABLE | \
244 PMD_SECT_CACHEABLE | \
245 PMD_SECT_AP_WRITE | \
250 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
252 .long sa110_processor_functions
256 .size __sa110_proc_info, . - __sa110_proc_info