1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/arm/mm/proc-sa1100.S
5 * Copyright (C) 1997-2002 Russell King
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
8 * MMU functions for SA110
10 * These are the low level assembler for performing cache and TLB
11 * functions on the StrongARM-1100 and StrongARM-1110.
13 * Note that SA1100 and SA1110 share everything but their name and CPU ID.
15 * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
16 * Flush the read buffer at context switches
18 #include <linux/linkage.h>
19 #include <linux/init.h>
20 #include <linux/cfi_types.h>
21 #include <linux/pgtable.h>
22 #include <asm/assembler.h>
23 #include <asm/asm-offsets.h>
24 #include <asm/hwcap.h>
25 #include <mach/hardware.h>
26 #include <asm/pgtable-hwdef.h>
28 #include "proc-macros.S"
31 * the cache line size of the I and D cache
33 #define DCACHELINESIZE 32
38 * cpu_sa1100_proc_init()
40 SYM_TYPED_FUNC_START(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
45 SYM_FUNC_END(cpu_sa1100_proc_init)
48 * cpu_sa1100_proc_fin()
50 * Prepare the CPU for reset:
51 * - Disable interrupts
52 * - Clean and turn off caches.
54 SYM_TYPED_FUNC_START(cpu_sa1100_proc_fin)
55 mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
56 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
57 bic r0, r0, #0x1000 @ ...i............
58 bic r0, r0, #0x000e @ ............wca.
59 mcr p15, 0, r0, c1, c0, 0 @ disable caches
61 SYM_FUNC_END(cpu_sa1100_proc_fin)
64 * cpu_sa1100_reset(loc)
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.
70 * loc: location to jump to for soft reset
73 .pushsection .idmap.text, "ax"
74 SYM_TYPED_FUNC_START(cpu_sa1100_reset)
76 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
77 mcr p15, 0, ip, c7, c10, 4 @ drain WB
79 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
86 SYM_FUNC_END(cpu_sa1100_reset)
90 * cpu_sa1100_do_idle(type)
92 * Cause the processor to idle
97 * 2 = switch to slow processor clock
98 * 3 = switch to fast processor clock
101 SYM_TYPED_FUNC_START(cpu_sa1100_do_idle)
102 mov r0, r0 @ 4 nop padding
105 mov r0, r0 @ 4 nop padding
109 ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
110 @ --- aligned to a cache line
111 mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
112 ldr r1, [r1, #0] @ force switch to MCLK
113 mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
115 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
117 SYM_FUNC_END(cpu_sa1100_do_idle)
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 SYM_TYPED_FUNC_START(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
136 SYM_FUNC_END(cpu_sa1100_dcache_clean_area)
138 /* =============================== PageTable ============================== */
141 * cpu_sa1100_switch_mm(pgd)
143 * Set the translation base pointer to be as described by pgd.
145 * pgd: new page tables
148 SYM_TYPED_FUNC_START(cpu_sa1100_switch_mm)
151 bl v4wb_flush_kern_cache_all @ clears IP
152 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
153 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
154 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
159 SYM_FUNC_END(cpu_sa1100_switch_mm)
162 * cpu_sa1100_set_pte_ext(ptep, pte, ext)
164 * Set a PTE and flush it out
167 SYM_TYPED_FUNC_START(cpu_sa1100_set_pte_ext)
169 armv3_set_pte_ext wc_disable=0
171 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
172 mcr p15, 0, r0, c7, c10, 4 @ drain WB
175 SYM_FUNC_END(cpu_sa1100_set_pte_ext)
177 .globl cpu_sa1100_suspend_size
178 .equ cpu_sa1100_suspend_size, 4 * 3
179 #ifdef CONFIG_ARM_CPU_SUSPEND
180 SYM_TYPED_FUNC_START(cpu_sa1100_do_suspend)
181 stmfd sp!, {r4 - r6, lr}
182 mrc p15, 0, r4, c3, c0, 0 @ domain ID
183 mrc p15, 0, r5, c13, c0, 0 @ PID
184 mrc p15, 0, r6, c1, c0, 0 @ control reg
185 stmia r0, {r4 - r6} @ store cp regs
186 ldmfd sp!, {r4 - r6, pc}
187 SYM_FUNC_END(cpu_sa1100_do_suspend)
189 SYM_TYPED_FUNC_START(cpu_sa1100_do_resume)
190 ldmia r0, {r4 - r6} @ load cp regs
192 mcr p15, 0, ip, c8, c7, 0 @ flush I+D TLBs
193 mcr p15, 0, ip, c7, c7, 0 @ flush I&D cache
194 mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
195 mcr p15, 0, ip, c9, c0, 5 @ allow user space to use RB
197 mcr p15, 0, r4, c3, c0, 0 @ domain ID
198 mcr p15, 0, r1, c2, c0, 0 @ translation table base addr
199 mcr p15, 0, r5, c13, c0, 0 @ PID
200 mov r0, r6 @ control register
202 SYM_FUNC_END(cpu_sa1100_do_resume)
205 .type __sa1100_setup, #function
208 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
209 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
211 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
215 mrc p15, 0, r0, c1, c0 @ get control register v4
219 .size __sa1100_setup, . - __sa1100_setup
223 * .RVI ZFRS BLDP WCAM
224 * ..11 0001 ..11 1101
227 .type sa1100_crval, #object
229 crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130
234 * SA1100 and SA1110 share the same function calls
237 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
238 define_processor_functions sa1100, dabort=v4_early_abort, pabort=legacy_pabort, suspend=1
242 string cpu_arch_name, "armv4"
243 string cpu_elf_name, "v4"
244 string cpu_sa1100_name, "StrongARM-1100"
245 string cpu_sa1110_name, "StrongARM-1110"
249 .section ".proc.info.init", "a"
251 .macro sa1100_proc_info name:req, cpu_val:req, cpu_mask:req, cpu_name:req
252 .type __\name\()_proc_info,#object
253 __\name\()_proc_info:
256 .long PMD_TYPE_SECT | \
257 PMD_SECT_BUFFERABLE | \
258 PMD_SECT_CACHEABLE | \
259 PMD_SECT_AP_WRITE | \
261 .long PMD_TYPE_SECT | \
262 PMD_SECT_AP_WRITE | \
264 initfn __sa1100_setup, __\name\()_proc_info
267 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
269 .long sa1100_processor_functions
273 .size __\name\()_proc_info, . - __\name\()_proc_info
276 sa1100_proc_info sa1100, 0x4401a110, 0xfffffff0, cpu_sa1100_name
277 sa1100_proc_info sa1110, 0x6901b110, 0xfffffff0, cpu_sa1110_name