blob: e9c47271732ddcc3687e31b7c1c7b2795d35c95a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mm/proc-sa1100.S
3 *
4 * Copyright (C) 1997-2002 Russell King
Hyok S. Choid090ddd2006-06-28 14:10:01 +01005 * hacked for non-paged-MM by Hyok S. Choi, 2003.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
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-1100 and StrongARM-1110.
15 *
16 * Note that SA1100 and SA1110 share everything but their name and CPU ID.
17 *
18 * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
19 * Flush the read buffer at context switches
20 */
21#include <linux/linkage.h>
22#include <linux/init.h>
23#include <asm/assembler.h>
Sam Ravnborge6ae7442005-09-09 21:08:59 +020024#include <asm/asm-offsets.h>
Russell King5ec94072008-09-07 19:15:31 +010025#include <asm/hwcap.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/hardware.h>
Russell King74945c82006-03-16 14:44:36 +000027#include <asm/pgtable-hwdef.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/pgtable.h>
29
Thomas Gleixnerbb8d5a52006-07-03 02:21:18 +020030#include "proc-macros.S"
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032/*
33 * the cache line size of the I and D cache
34 */
35#define DCACHELINESIZE 32
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Russell Kingb69874e2011-06-21 18:57:31 +010037 .section .text
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/*
40 * cpu_sa1100_proc_init()
41 */
42ENTRY(cpu_sa1100_proc_init)
43 mov r0, #0
44 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
45 mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
46 mov pc, lr
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048/*
49 * cpu_sa1100_proc_fin()
50 *
51 * Prepare the CPU for reset:
52 * - Disable interrupts
53 * - Clean and turn off caches.
54 */
55ENTRY(cpu_sa1100_proc_fin)
Russell King95f3df62006-04-07 13:17:15 +010056 mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
58 bic r0, r0, #0x1000 @ ...i............
59 bic r0, r0, #0x000e @ ............wca.
60 mcr p15, 0, r0, c1, c0, 0 @ disable caches
Russell King9ca03a22010-07-26 12:22:12 +010061 mov pc, lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63/*
64 * cpu_sa1100_reset(loc)
65 *
66 * Perform a soft reset of the system. Put the CPU into the
67 * same state as it would be if it had been reset, and branch
68 * to what would be the reset vector.
69 *
70 * loc: location to jump to for soft reset
71 */
72 .align 5
73ENTRY(cpu_sa1100_reset)
74 mov ip, #0
75 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
76 mcr p15, 0, ip, c7, c10, 4 @ drain WB
Hyok S. Choid090ddd2006-06-28 14:10:01 +010077#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
Hyok S. Choid090ddd2006-06-28 14:10:01 +010079#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
81 bic ip, ip, #0x000f @ ............wcam
82 bic ip, ip, #0x1100 @ ...i...s........
83 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
84 mov pc, r0
85
86/*
87 * cpu_sa1100_do_idle(type)
88 *
89 * Cause the processor to idle
90 *
91 * type: call type:
92 * 0 = slow idle
93 * 1 = fast idle
94 * 2 = switch to slow processor clock
95 * 3 = switch to fast processor clock
96 */
97 .align 5
98ENTRY(cpu_sa1100_do_idle)
99 mov r0, r0 @ 4 nop padding
100 mov r0, r0
101 mov r0, r0
102 mov r0, r0 @ 4 nop padding
103 mov r0, r0
104 mov r0, r0
105 mov r0, #0
106 ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
107 @ --- aligned to a cache line
108 mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
109 ldr r1, [r1, #0] @ force switch to MCLK
110 mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
111 mov r0, r0 @ safety
112 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
113 mov pc, lr
114
115/* ================================= CACHE ================================ */
116
117/*
118 * cpu_sa1100_dcache_clean_area(addr,sz)
119 *
120 * Clean the specified entry of any caches such that the MMU
121 * translation fetches will obtain correct data.
122 *
123 * addr: cache-unaligned virtual address
124 */
125 .align 5
126ENTRY(cpu_sa1100_dcache_clean_area)
1271: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
128 add r0, r0, #DCACHELINESIZE
129 subs r1, r1, #DCACHELINESIZE
130 bhi 1b
131 mov pc, lr
132
133/* =============================== PageTable ============================== */
134
135/*
136 * cpu_sa1100_switch_mm(pgd)
137 *
138 * Set the translation base pointer to be as described by pgd.
139 *
140 * pgd: new page tables
141 */
142 .align 5
143ENTRY(cpu_sa1100_switch_mm)
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100144#ifdef CONFIG_MMU
Russell King95f3df62006-04-07 13:17:15 +0100145 str lr, [sp, #-4]!
146 bl v4wb_flush_kern_cache_all @ clears IP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
149 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
Russell King95f3df62006-04-07 13:17:15 +0100150 ldr pc, [sp], #4
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100151#else
152 mov pc, lr
153#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155/*
Russell Kingad1ae2f2006-12-13 14:34:43 +0000156 * cpu_sa1100_set_pte_ext(ptep, pte, ext)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 *
158 * Set a PTE and flush it out
159 */
160 .align 5
Russell Kingad1ae2f2006-12-13 14:34:43 +0000161ENTRY(cpu_sa1100_set_pte_ext)
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100162#ifdef CONFIG_MMU
Russell Kingda091652008-09-06 17:19:08 +0100163 armv3_set_pte_ext wc_disable=0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 mov r0, r0
165 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
166 mcr p15, 0, r0, c7, c10, 4 @ drain WB
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100167#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 mov pc, lr
169
Russell Kingf6b0fa02011-02-06 15:48:39 +0000170.globl cpu_sa1100_suspend_size
171.equ cpu_sa1100_suspend_size, 4*4
Russell King29ea23f2011-04-02 10:08:55 +0100172#ifdef CONFIG_PM_SLEEP
Russell Kingf6b0fa02011-02-06 15:48:39 +0000173ENTRY(cpu_sa1100_do_suspend)
174 stmfd sp!, {r4 - r7, lr}
175 mrc p15, 0, r4, c3, c0, 0 @ domain ID
176 mrc p15, 0, r5, c2, c0, 0 @ translation table base addr
177 mrc p15, 0, r6, c13, c0, 0 @ PID
178 mrc p15, 0, r7, c1, c0, 0 @ control reg
179 stmia r0, {r4 - r7} @ store cp regs
180 ldmfd sp!, {r4 - r7, pc}
181ENDPROC(cpu_sa1100_do_suspend)
182
183ENTRY(cpu_sa1100_do_resume)
184 ldmia r0, {r4 - r7} @ load cp regs
185 mov r1, #0
186 mcr p15, 0, r1, c8, c7, 0 @ flush I+D TLBs
187 mcr p15, 0, r1, c7, c7, 0 @ flush I&D cache
188 mcr p15, 0, r1, c9, c0, 0 @ invalidate RB
189 mcr p15, 0, r1, c9, c0, 5 @ allow user space to use RB
190
191 mcr p15, 0, r4, c3, c0, 0 @ domain ID
192 mcr p15, 0, r5, c2, c0, 0 @ translation table base addr
193 mcr p15, 0, r6, c13, c0, 0 @ PID
194 mov r0, r7 @ control register
195 mov r2, r5, lsr #14 @ get TTB0 base
196 mov r2, r2, lsl #14
197 ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \
198 PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE
199 b cpu_resume_mmu
200ENDPROC(cpu_sa1100_do_resume)
201#else
202#define cpu_sa1100_do_suspend 0
203#define cpu_sa1100_do_resume 0
204#endif
205
Russell King5085f3f2010-10-01 15:37:05 +0100206 __CPUINIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208 .type __sa1100_setup, #function
209__sa1100_setup:
210 mov r0, #0
211 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
212 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100213#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100215#endif
Russell King22b19082006-06-29 15:09:57 +0100216 adr r5, sa1100_crval
217 ldmia r5, {r5, r6}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 mrc p15, 0, r0, c1, c0 @ get control register v4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 bic r0, r0, r5
Russell King22b19082006-06-29 15:09:57 +0100220 orr r0, r0, r6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 mov pc, lr
222 .size __sa1100_setup, . - __sa1100_setup
223
224 /*
225 * R
226 * .RVI ZFRS BLDP WCAM
227 * ..11 0001 ..11 1101
228 *
229 */
Russell King22b19082006-06-29 15:09:57 +0100230 .type sa1100_crval, #object
231sa1100_crval:
232 crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234 __INITDATA
235
236/*
237 * Purpose : Function pointers used to access above functions - all calls
238 * come through these
239 */
240
241/*
242 * SA1100 and SA1110 share the same function calls
243 */
244 .type sa1100_processor_functions, #object
245ENTRY(sa1100_processor_functions)
246 .word v4_early_abort
Kirill A. Shutemov4fb28472009-09-25 13:39:47 +0100247 .word legacy_pabort
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .word cpu_sa1100_proc_init
249 .word cpu_sa1100_proc_fin
250 .word cpu_sa1100_reset
251 .word cpu_sa1100_do_idle
252 .word cpu_sa1100_dcache_clean_area
253 .word cpu_sa1100_switch_mm
Russell Kingad1ae2f2006-12-13 14:34:43 +0000254 .word cpu_sa1100_set_pte_ext
Russell Kingf6b0fa02011-02-06 15:48:39 +0000255 .word cpu_sa1100_suspend_size
256 .word cpu_sa1100_do_suspend
257 .word cpu_sa1100_do_resume
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .size sa1100_processor_functions, . - sa1100_processor_functions
259
260 .section ".rodata"
261
262 .type cpu_arch_name, #object
263cpu_arch_name:
264 .asciz "armv4"
265 .size cpu_arch_name, . - cpu_arch_name
266
267 .type cpu_elf_name, #object
268cpu_elf_name:
269 .asciz "v4"
270 .size cpu_elf_name, . - cpu_elf_name
271
272 .type cpu_sa1100_name, #object
273cpu_sa1100_name:
274 .asciz "StrongARM-1100"
275 .size cpu_sa1100_name, . - cpu_sa1100_name
276
277 .type cpu_sa1110_name, #object
278cpu_sa1110_name:
279 .asciz "StrongARM-1110"
280 .size cpu_sa1110_name, . - cpu_sa1110_name
281
282 .align
283
Ben Dooks02b7dd12005-09-20 16:35:03 +0100284 .section ".proc.info.init", #alloc, #execinstr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 .type __sa1100_proc_info,#object
287__sa1100_proc_info:
288 .long 0x4401a110
289 .long 0xfffffff0
290 .long PMD_TYPE_SECT | \
291 PMD_SECT_BUFFERABLE | \
292 PMD_SECT_CACHEABLE | \
293 PMD_SECT_AP_WRITE | \
294 PMD_SECT_AP_READ
Russell King8799ee92006-06-29 18:24:21 +0100295 .long PMD_TYPE_SECT | \
296 PMD_SECT_AP_WRITE | \
297 PMD_SECT_AP_READ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 b __sa1100_setup
299 .long cpu_arch_name
300 .long cpu_elf_name
301 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
302 .long cpu_sa1100_name
303 .long sa1100_processor_functions
304 .long v4wb_tlb_fns
305 .long v4_mc_user_fns
306 .long v4wb_cache_fns
307 .size __sa1100_proc_info, . - __sa1100_proc_info
308
309 .type __sa1110_proc_info,#object
310__sa1110_proc_info:
311 .long 0x6901b110
312 .long 0xfffffff0
313 .long PMD_TYPE_SECT | \
314 PMD_SECT_BUFFERABLE | \
315 PMD_SECT_CACHEABLE | \
316 PMD_SECT_AP_WRITE | \
317 PMD_SECT_AP_READ
Russell King8799ee92006-06-29 18:24:21 +0100318 .long PMD_TYPE_SECT | \
319 PMD_SECT_AP_WRITE | \
320 PMD_SECT_AP_READ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 b __sa1100_setup
322 .long cpu_arch_name
323 .long cpu_elf_name
324 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
325 .long cpu_sa1110_name
326 .long sa1100_processor_functions
327 .long v4wb_tlb_fns
328 .long v4_mc_user_fns
329 .long v4wb_cache_fns
330 .size __sa1110_proc_info, . - __sa1110_proc_info