[ARM] nommu: provide a way for correct control register value selection
[safe/jmp/linux-2.6] / arch / arm / mm / proc-sa110.S
1 /*
2  *  linux/arch/arm/mm/proc-sa110.S
3  *
4  *  Copyright (C) 1997-2002 Russell King
5  *  hacked for non-paged-MM by Hyok S. Choi, 2003.
6  *
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.
10  *
11  *  MMU functions for SA110
12  *
13  *  These are the low level assembler for performing cache and TLB
14  *  functions on the StrongARM-110.
15  */
16 #include <linux/linkage.h>
17 #include <linux/init.h>
18 #include <asm/assembler.h>
19 #include <asm/asm-offsets.h>
20 #include <asm/procinfo.h>
21 #include <asm/hardware.h>
22 #include <asm/pgtable-hwdef.h>
23 #include <asm/pgtable.h>
24 #include <asm/ptrace.h>
25
26 /*
27  * the cache line size of the I and D cache
28  */
29 #define DCACHELINESIZE  32
30
31         .text
32
33 /*
34  * cpu_sa110_proc_init()
35  */
36 ENTRY(cpu_sa110_proc_init)
37         mov     r0, #0
38         mcr     p15, 0, r0, c15, c1, 2          @ Enable clock switching
39         mov     pc, lr
40
41 /*
42  * cpu_sa110_proc_fin()
43  */
44 ENTRY(cpu_sa110_proc_fin)
45         stmfd   sp!, {lr}
46         mov     ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
47         msr     cpsr_c, ip
48         bl      v4wb_flush_kern_cache_all       @ clean caches
49 1:      mov     r0, #0
50         mcr     p15, 0, r0, c15, c2, 2          @ Disable clock switching
51         mrc     p15, 0, r0, c1, c0, 0           @ ctrl register
52         bic     r0, r0, #0x1000                 @ ...i............
53         bic     r0, r0, #0x000e                 @ ............wca.
54         mcr     p15, 0, r0, c1, c0, 0           @ disable caches
55         ldmfd   sp!, {pc}
56
57 /*
58  * cpu_sa110_reset(loc)
59  *
60  * Perform a soft reset of the system.  Put the CPU into the
61  * same state as it would be if it had been reset, and branch
62  * to what would be the reset vector.
63  *
64  * loc: location to jump to for soft reset
65  */
66         .align  5
67 ENTRY(cpu_sa110_reset)
68         mov     ip, #0
69         mcr     p15, 0, ip, c7, c7, 0           @ invalidate I,D caches
70         mcr     p15, 0, ip, c7, c10, 4          @ drain WB
71 #ifdef CONFIG_MMU
72         mcr     p15, 0, ip, c8, c7, 0           @ invalidate I & D TLBs
73 #endif
74         mrc     p15, 0, ip, c1, c0, 0           @ ctrl register
75         bic     ip, ip, #0x000f                 @ ............wcam
76         bic     ip, ip, #0x1100                 @ ...i...s........
77         mcr     p15, 0, ip, c1, c0, 0           @ ctrl register
78         mov     pc, r0
79
80 /*
81  * cpu_sa110_do_idle(type)
82  *
83  * Cause the processor to idle
84  *
85  * type: call type:
86  *   0 = slow idle
87  *   1 = fast idle
88  *   2 = switch to slow processor clock
89  *   3 = switch to fast processor clock
90  */
91         .align  5
92
93 ENTRY(cpu_sa110_do_idle)
94         mcr     p15, 0, ip, c15, c2, 2          @ disable clock switching
95         ldr     r1, =UNCACHEABLE_ADDR           @ load from uncacheable loc
96         ldr     r1, [r1, #0]                    @ force switch to MCLK
97         mov     r0, r0                          @ safety
98         mov     r0, r0                          @ safety
99         mov     r0, r0                          @ safety
100         mcr     p15, 0, r0, c15, c8, 2          @ Wait for interrupt, cache aligned
101         mov     r0, r0                          @ safety
102         mov     r0, r0                          @ safety
103         mov     r0, r0                          @ safety
104         mcr     p15, 0, r0, c15, c1, 2          @ enable clock switching
105         mov     pc, lr
106
107 /* ================================= CACHE ================================ */
108
109 /*
110  * cpu_sa110_dcache_clean_area(addr,sz)
111  *
112  * Clean the specified entry of any caches such that the MMU
113  * translation fetches will obtain correct data.
114  *
115  * addr: cache-unaligned virtual address
116  */
117         .align  5
118 ENTRY(cpu_sa110_dcache_clean_area)
119 1:      mcr     p15, 0, r0, c7, c10, 1          @ clean D entry
120         add     r0, r0, #DCACHELINESIZE
121         subs    r1, r1, #DCACHELINESIZE
122         bhi     1b
123         mov     pc, lr
124
125 /* =============================== PageTable ============================== */
126
127 /*
128  * cpu_sa110_switch_mm(pgd)
129  *
130  * Set the translation base pointer to be as described by pgd.
131  *
132  * pgd: new page tables
133  */
134         .align  5
135 ENTRY(cpu_sa110_switch_mm)
136 #ifdef CONFIG_MMU
137         str     lr, [sp, #-4]!
138         bl      v4wb_flush_kern_cache_all       @ clears IP
139         mcr     p15, 0, r0, c2, c0, 0           @ load page table pointer
140         mcr     p15, 0, ip, c8, c7, 0           @ invalidate I & D TLBs
141         ldr     pc, [sp], #4
142 #else
143         mov     pc, lr
144 #endif
145
146 /*
147  * cpu_sa110_set_pte(ptep, pte)
148  *
149  * Set a PTE and flush it out
150  */
151         .align  5
152 ENTRY(cpu_sa110_set_pte)
153 #ifdef CONFIG_MMU
154         str     r1, [r0], #-2048                @ linux version
155
156         eor     r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
157
158         bic     r2, r1, #PTE_SMALL_AP_MASK
159         bic     r2, r2, #PTE_TYPE_MASK
160         orr     r2, r2, #PTE_TYPE_SMALL
161
162         tst     r1, #L_PTE_USER                 @ User?
163         orrne   r2, r2, #PTE_SMALL_AP_URO_SRW
164
165         tst     r1, #L_PTE_WRITE | L_PTE_DIRTY  @ Write and Dirty?
166         orreq   r2, r2, #PTE_SMALL_AP_UNO_SRW
167
168         tst     r1, #L_PTE_PRESENT | L_PTE_YOUNG        @ Present and Young?
169         movne   r2, #0
170
171         str     r2, [r0]                        @ hardware version
172         mov     r0, r0
173         mcr     p15, 0, r0, c7, c10, 1          @ clean D entry
174         mcr     p15, 0, r0, c7, c10, 4          @ drain WB
175 #endif
176         mov     pc, lr
177
178         __INIT
179
180         .type   __sa110_setup, #function
181 __sa110_setup:
182         mov     r10, #0
183         mcr     p15, 0, r10, c7, c7             @ invalidate I,D caches on v4
184         mcr     p15, 0, r10, c7, c10, 4         @ drain write buffer on v4
185 #ifdef CONFIG_MMU
186         mcr     p15, 0, r10, c8, c7             @ invalidate I,D TLBs on v4
187 #endif
188
189         adr     r5, sa110_crval
190         ldmia   r5, {r5, r6}
191         mrc     p15, 0, r0, c1, c0              @ get control register v4
192         bic     r0, r0, r5
193         orr     r0, r0, r6
194         mov     pc, lr
195         .size   __sa110_setup, . - __sa110_setup
196
197         /*
198          *  R
199          * .RVI ZFRS BLDP WCAM
200          * ..01 0001 ..11 1101
201          * 
202          */
203         .type   sa110_crval, #object
204 sa110_crval:
205         crval   clear=0x00003f3f, mmuset=0x0000113d, ucset=0x00001130
206
207         __INITDATA
208
209 /*
210  * Purpose : Function pointers used to access above functions - all calls
211  *           come through these
212  */
213
214         .type   sa110_processor_functions, #object
215 ENTRY(sa110_processor_functions)
216         .word   v4_early_abort
217         .word   cpu_sa110_proc_init
218         .word   cpu_sa110_proc_fin
219         .word   cpu_sa110_reset
220         .word   cpu_sa110_do_idle
221         .word   cpu_sa110_dcache_clean_area
222         .word   cpu_sa110_switch_mm
223         .word   cpu_sa110_set_pte
224         .size   sa110_processor_functions, . - sa110_processor_functions
225
226         .section ".rodata"
227
228         .type   cpu_arch_name, #object
229 cpu_arch_name:
230         .asciz  "armv4"
231         .size   cpu_arch_name, . - cpu_arch_name
232
233         .type   cpu_elf_name, #object
234 cpu_elf_name:
235         .asciz  "v4"
236         .size   cpu_elf_name, . - cpu_elf_name
237
238         .type   cpu_sa110_name, #object
239 cpu_sa110_name:
240         .asciz  "StrongARM-110"
241         .size   cpu_sa110_name, . - cpu_sa110_name
242
243         .align
244
245         .section ".proc.info.init", #alloc, #execinstr
246
247         .type   __sa110_proc_info,#object
248 __sa110_proc_info:
249         .long   0x4401a100
250         .long   0xfffffff0
251         .long   PMD_TYPE_SECT | \
252                 PMD_SECT_BUFFERABLE | \
253                 PMD_SECT_CACHEABLE | \
254                 PMD_SECT_AP_WRITE | \
255                 PMD_SECT_AP_READ
256         b       __sa110_setup
257         .long   cpu_arch_name
258         .long   cpu_elf_name
259         .long   HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
260         .long   cpu_sa110_name
261         .long   sa110_processor_functions
262         .long   v4wb_tlb_fns
263         .long   v4wb_user_fns
264         .long   v4wb_cache_fns
265         .size   __sa110_proc_info, . - __sa110_proc_info