blob: ee2ce496239f57f14f3638e133a8fbd14e7d2bfa [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mm/proc-sa110.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-110.
15 */
16#include <linux/linkage.h>
17#include <linux/init.h>
18#include <asm/assembler.h>
Sam Ravnborge6ae7442005-09-09 21:08:59 +020019#include <asm/asm-offsets.h>
Russell King5ec94072008-09-07 19:15:31 +010020#include <asm/hwcap.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010021#include <mach/hardware.h>
Russell King74945c82006-03-16 14:44:36 +000022#include <asm/pgtable-hwdef.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <asm/pgtable.h>
24#include <asm/ptrace.h>
25
Thomas Gleixnerbb8d5a52006-07-03 02:21:18 +020026#include "proc-macros.S"
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028/*
29 * the cache line size of the I and D cache
30 */
31#define DCACHELINESIZE 32
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 .text
34
35/*
36 * cpu_sa110_proc_init()
37 */
38ENTRY(cpu_sa110_proc_init)
39 mov r0, #0
40 mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
Russell King6ebbf2c2014-06-30 16:29:12 +010041 ret lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43/*
44 * cpu_sa110_proc_fin()
45 */
46ENTRY(cpu_sa110_proc_fin)
Russell King9ca03a22010-07-26 12:22:12 +010047 mov r0, #0
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
49 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
50 bic r0, r0, #0x1000 @ ...i............
51 bic r0, r0, #0x000e @ ............wca.
52 mcr p15, 0, r0, c1, c0, 0 @ disable caches
Russell King6ebbf2c2014-06-30 16:29:12 +010053 ret lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55/*
56 * cpu_sa110_reset(loc)
57 *
58 * Perform a soft reset of the system. Put the CPU into the
59 * same state as it would be if it had been reset, and branch
60 * to what would be the reset vector.
61 *
62 * loc: location to jump to for soft reset
63 */
64 .align 5
Will Deacon1a4baaf2011-11-15 13:25:04 +000065 .pushsection .idmap.text, "ax"
Linus Torvalds1da177e2005-04-16 15:20:36 -070066ENTRY(cpu_sa110_reset)
67 mov ip, #0
68 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
69 mcr p15, 0, ip, c7, c10, 4 @ drain WB
Hyok S. Choid090ddd2006-06-28 14:10:01 +010070#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
Hyok S. Choid090ddd2006-06-28 14:10:01 +010072#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
74 bic ip, ip, #0x000f @ ............wcam
75 bic ip, ip, #0x1100 @ ...i...s........
76 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
Russell King6ebbf2c2014-06-30 16:29:12 +010077 ret r0
Will Deacon1a4baaf2011-11-15 13:25:04 +000078ENDPROC(cpu_sa110_reset)
79 .popsection
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81/*
82 * cpu_sa110_do_idle(type)
83 *
84 * Cause the processor to idle
85 *
86 * type: call type:
87 * 0 = slow idle
88 * 1 = fast idle
89 * 2 = switch to slow processor clock
90 * 3 = switch to fast processor clock
91 */
92 .align 5
93
94ENTRY(cpu_sa110_do_idle)
95 mcr p15, 0, ip, c15, c2, 2 @ disable clock switching
96 ldr r1, =UNCACHEABLE_ADDR @ load from uncacheable loc
97 ldr r1, [r1, #0] @ force switch to MCLK
98 mov r0, r0 @ safety
99 mov r0, r0 @ safety
100 mov r0, r0 @ safety
101 mcr p15, 0, r0, c15, c8, 2 @ Wait for interrupt, cache aligned
102 mov r0, r0 @ safety
103 mov r0, r0 @ safety
104 mov r0, r0 @ safety
105 mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
Russell King6ebbf2c2014-06-30 16:29:12 +0100106 ret lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108/* ================================= CACHE ================================ */
109
110/*
111 * cpu_sa110_dcache_clean_area(addr,sz)
112 *
113 * Clean the specified entry of any caches such that the MMU
114 * translation fetches will obtain correct data.
115 *
116 * addr: cache-unaligned virtual address
117 */
118 .align 5
119ENTRY(cpu_sa110_dcache_clean_area)
1201: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
121 add r0, r0, #DCACHELINESIZE
122 subs r1, r1, #DCACHELINESIZE
123 bhi 1b
Russell King6ebbf2c2014-06-30 16:29:12 +0100124 ret lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126/* =============================== PageTable ============================== */
127
128/*
129 * cpu_sa110_switch_mm(pgd)
130 *
131 * Set the translation base pointer to be as described by pgd.
132 *
133 * pgd: new page tables
134 */
135 .align 5
136ENTRY(cpu_sa110_switch_mm)
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100137#ifdef CONFIG_MMU
Russell King95f3df62006-04-07 13:17:15 +0100138 str lr, [sp, #-4]!
139 bl v4wb_flush_kern_cache_all @ clears IP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
Russell King95f3df62006-04-07 13:17:15 +0100141 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
142 ldr pc, [sp], #4
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100143#else
Russell King6ebbf2c2014-06-30 16:29:12 +0100144 ret lr
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100145#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147/*
Russell Kingad1ae2f2006-12-13 14:34:43 +0000148 * cpu_sa110_set_pte_ext(ptep, pte, ext)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 *
150 * Set a PTE and flush it out
151 */
152 .align 5
Russell Kingad1ae2f2006-12-13 14:34:43 +0000153ENTRY(cpu_sa110_set_pte_ext)
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100154#ifdef CONFIG_MMU
Russell Kingda091652008-09-06 17:19:08 +0100155 armv3_set_pte_ext wc_disable=0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 mov r0, r0
157 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
158 mcr p15, 0, r0, c7, c10, 4 @ drain WB
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100159#endif
Russell King6ebbf2c2014-06-30 16:29:12 +0100160 ret lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 .type __sa110_setup, #function
163__sa110_setup:
164 mov r10, #0
165 mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4
166 mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100167#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4
Hyok S. Choid090ddd2006-06-28 14:10:01 +0100169#endif
Russell King22b190862006-06-29 15:09:57 +0100170
171 adr r5, sa110_crval
172 ldmia r5, {r5, r6}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 mrc p15, 0, r0, c1, c0 @ get control register v4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 bic r0, r0, r5
Russell King22b190862006-06-29 15:09:57 +0100175 orr r0, r0, r6
Russell King6ebbf2c2014-06-30 16:29:12 +0100176 ret lr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 .size __sa110_setup, . - __sa110_setup
178
179 /*
180 * R
181 * .RVI ZFRS BLDP WCAM
182 * ..01 0001 ..11 1101
183 *
184 */
Russell King22b190862006-06-29 15:09:57 +0100185 .type sa110_crval, #object
186sa110_crval:
187 crval clear=0x00003f3f, mmuset=0x0000113d, ucset=0x00001130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189 __INITDATA
190
Dave Martin5973ba52011-06-23 17:25:11 +0100191 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
192 define_processor_functions sa110, dabort=v4_early_abort, pabort=legacy_pabort
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
194 .section ".rodata"
195
Dave Martin5973ba52011-06-23 17:25:11 +0100196 string cpu_arch_name, "armv4"
197 string cpu_elf_name, "v4"
198 string cpu_sa110_name, "StrongARM-110"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200 .align
201
Ard Biesheuvelbf357062015-03-18 07:29:32 +0100202 .section ".proc.info.init", #alloc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204 .type __sa110_proc_info,#object
205__sa110_proc_info:
206 .long 0x4401a100
207 .long 0xfffffff0
208 .long PMD_TYPE_SECT | \
209 PMD_SECT_BUFFERABLE | \
210 PMD_SECT_CACHEABLE | \
211 PMD_SECT_AP_WRITE | \
212 PMD_SECT_AP_READ
Russell King8799ee92006-06-29 18:24:21 +0100213 .long PMD_TYPE_SECT | \
214 PMD_SECT_AP_WRITE | \
215 PMD_SECT_AP_READ
Ard Biesheuvelbf357062015-03-18 07:29:32 +0100216 initfn __sa110_setup, __sa110_proc_info
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 .long cpu_arch_name
218 .long cpu_elf_name
219 .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
220 .long cpu_sa110_name
221 .long sa110_processor_functions
222 .long v4wb_tlb_fns
223 .long v4wb_user_fns
224 .long v4wb_cache_fns
225 .size __sa110_proc_info, . - __sa110_proc_info