1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/linkage.h>
14#include <linux/init.h>
15#include <asm/assembler.h>
16#include <asm/hwcap.h>
17#include <asm/pgtable-hwdef.h>
18#include <asm/pgtable.h>
19#include <asm/ptrace.h>
20#include "proc-macros.S"
21
22
23
24
25
26#define CACHE_DSIZE (CONFIG_CPU_DCACHE_SIZE)
27#define CACHE_DLINESIZE 32
28#define CACHE_DSEGMENTS 4
29#define CACHE_DENTRIES (CACHE_DSIZE / CACHE_DSEGMENTS / CACHE_DLINESIZE)
30#define CACHE_DLIMIT (CACHE_DSIZE * 4)
31
32 .text
33
34
35
36
37
38
39ENTRY(cpu_arm946_proc_init)
40ENTRY(cpu_arm946_switch_mm)
41 mov pc, lr
42
43
44
45
46ENTRY(cpu_arm946_proc_fin)
47 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
48 bic r0, r0,
49 bic r0, r0,
50 mcr p15, 0, r0, c1, c0, 0 @ disable caches
51 mov pc, lr
52
53
54
55
56
57
58 .pushsection .idmap.text, "ax"
59ENTRY(cpu_arm946_reset)
60 mov ip,
61 mcr p15, 0, ip, c7, c5, 0 @ flush I cache
62 mcr p15, 0, ip, c7, c6, 0 @ flush D cache
63 mcr p15, 0, ip, c7, c10, 4 @ drain WB
64 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
65 bic ip, ip,
66 bic ip, ip,
67 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
68 mov pc, r0
69ENDPROC(cpu_arm946_reset)
70 .popsection
71
72
73
74
75 .align 5
76ENTRY(cpu_arm946_do_idle)
77 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
78 mov pc, lr
79
80
81
82
83
84
85ENTRY(arm946_flush_icache_all)
86 mov r0,
87 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
88 mov pc, lr
89ENDPROC(arm946_flush_icache_all)
90
91
92
93
94ENTRY(arm946_flush_user_cache_all)
95
96
97
98
99
100
101
102ENTRY(arm946_flush_kern_cache_all)
103 mov r2,
104 mov ip,
105__flush_whole_cache:
106#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
107 mcr p15, 0, ip, c7, c6, 0 @ flush D cache
108#else
109 mov r1,
1101: orr r3, r1,
1112: mcr p15, 0, r3, c7, c14, 2 @ clean/flush D index
112 subs r3, r3,
113 bcs 2b @ entries n to 0
114 subs r1, r1,
115 bcs 1b @ segments 3 to 0
116#endif
117 tst r2,
118 mcrne p15, 0, ip, c7, c5, 0 @ flush I cache
119 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
120 mov pc, lr
121
122
123
124
125
126
127
128
129
130
131
132
133ENTRY(arm946_flush_user_cache_range)
134 mov ip,
135 sub r3, r1, r0 @ calculate total size
136 cmp r3,
137 bhs __flush_whole_cache
138
1391: tst r2,
140#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
141 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
142 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
143 add r0, r0,
144 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
145 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
146 add r0, r0,
147#else
148 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
149 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
150 add r0, r0,
151 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
152 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
153 add r0, r0,
154#endif
155 cmp r0, r1
156 blo 1b
157 tst r2,
158 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
159 mov pc, lr
160
161
162
163
164
165
166
167
168
169
170
171ENTRY(arm946_coherent_kern_range)
172
173
174
175
176
177
178
179
180
181
182
183
184
185ENTRY(arm946_coherent_user_range)
186 bic r0, r0,
1871: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
188 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
189 add r0, r0,
190 cmp r0, r1
191 blo 1b
192 mcr p15, 0, r0, c7, c10, 4 @ drain WB
193 mov r0,
194 mov pc, lr
195
196
197
198
199
200
201
202
203
204
205
206ENTRY(arm946_flush_kern_dcache_area)
207 add r1, r0, r1
2081: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
209 add r0, r0,
210 cmp r0, r1
211 blo 1b
212 mov r0,
213 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
214 mcr p15, 0, r0, c7, c10, 4 @ drain WB
215 mov pc, lr
216
217
218
219
220
221
222
223
224
225
226
227
228
229arm946_dma_inv_range:
230#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
231 tst r0,
232 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
233 tst r1,
234 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
235#endif
236 bic r0, r0,
2371: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
238 add r0, r0,
239 cmp r0, r1
240 blo 1b
241 mcr p15, 0, r0, c7, c10, 4 @ drain WB
242 mov pc, lr
243
244
245
246
247
248
249
250
251
252
253
254arm946_dma_clean_range:
255#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
256 bic r0, r0,
2571: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
258 add r0, r0,
259 cmp r0, r1
260 blo 1b
261#endif
262 mcr p15, 0, r0, c7, c10, 4 @ drain WB
263 mov pc, lr
264
265
266
267
268
269
270
271
272
273
274
275ENTRY(arm946_dma_flush_range)
276 bic r0, r0,
2771:
278#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
279 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
280#else
281 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
282#endif
283 add r0, r0,
284 cmp r0, r1
285 blo 1b
286 mcr p15, 0, r0, c7, c10, 4 @ drain WB
287 mov pc, lr
288
289
290
291
292
293
294
295ENTRY(arm946_dma_map_area)
296 add r1, r1, r0
297 cmp r2,
298 beq arm946_dma_clean_range
299 bcs arm946_dma_inv_range
300 b arm946_dma_flush_range
301ENDPROC(arm946_dma_map_area)
302
303
304
305
306
307
308
309ENTRY(arm946_dma_unmap_area)
310 mov pc, lr
311ENDPROC(arm946_dma_unmap_area)
312
313 .globl arm946_flush_kern_cache_louis
314 .equ arm946_flush_kern_cache_louis, arm946_flush_kern_cache_all
315
316 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
317 define_cache_functions arm946
318
319ENTRY(cpu_arm946_dcache_clean_area)
320#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
3211: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
322 add r0, r0,
323 subs r1, r1,
324 bhi 1b
325#endif
326 mcr p15, 0, r0, c7, c10, 4 @ drain WB
327 mov pc, lr
328
329 __CPUINIT
330
331 .type __arm946_setup,
332__arm946_setup:
333 mov r0,
334 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
335 mcr p15, 0, r0, c7, c6, 0 @ invalidate D cache
336 mcr p15, 0, r0, c7, c10, 4 @ drain WB
337
338 mcr p15, 0, r0, c6, c3, 0 @ disable memory region 3~7
339 mcr p15, 0, r0, c6, c4, 0
340 mcr p15, 0, r0, c6, c5, 0
341 mcr p15, 0, r0, c6, c6, 0
342 mcr p15, 0, r0, c6, c7, 0
343
344 mov r0,
345 mcr p15, 0, r0, c6, c0, 0 @ set region 0, default
346
347 ldr r0, =(CONFIG_DRAM_BASE & 0xFFFFF000) @ base[31:12] of RAM
348 ldr r1, =(CONFIG_DRAM_SIZE >> 12) @ size of RAM (must be >= 4KB)
349 mov r2,
3501: add r2, r2,
351 mov r1, r1, lsr
352 bne 1b @ count not zero r-shift
353 orr r0, r0, r2, lsl
354 orr r0, r0,
355 mcr p15, 0, r0, c6, c1, 0 @ set region 1, RAM
356
357 ldr r0, =(CONFIG_FLASH_MEM_BASE & 0xFFFFF000) @ base[31:12] of FLASH
358 ldr r1, =(CONFIG_FLASH_SIZE >> 12) @ size of FLASH (must be >= 4KB)
359 mov r2,
3601: add r2, r2,
361 mov r1, r1, lsr
362 bne 1b @ count not zero r-shift
363 orr r0, r0, r2, lsl
364 orr r0, r0,
365 mcr p15, 0, r0, c6, c2, 0 @ set region 2, ROM/FLASH
366
367 mov r0,
368 mcr p15, 0, r0, c2, c0, 0 @ region 1,2 d-cacheable
369 mcr p15, 0, r0, c2, c0, 1 @ region 1,2 i-cacheable
370#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
371 mov r0,
372#else
373 mov r0,
374#endif
375 mcr p15, 0, r0, c3, c0, 0
376
377
378
379
380
381
382
383
384
385
386 mov r0,
387 orr r0, r0,
388 mcr p15, 0, r0, c5, c0, 2 @ set data access permission
389 mcr p15, 0, r0, c5, c0, 3 @ set inst. access permission
390
391 mrc p15, 0, r0, c1, c0 @ get control register
392 orr r0, r0,
393 orr r0, r0,
394#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
395 orr r0, r0,
396#endif
397 mov pc, lr
398
399 .size __arm946_setup, . - __arm946_setup
400
401 __INITDATA
402
403 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
404 define_processor_functions arm946, dabort=nommu_early_abort, pabort=legacy_pabort, nommu=1
405
406 .section ".rodata"
407
408 string cpu_arch_name, "armv5te"
409 string cpu_elf_name, "v5t"
410 string cpu_arm946_name, "ARM946E-S"
411
412 .align
413
414 .section ".proc.info.init",
415 .type __arm946_proc_info,
416__arm946_proc_info:
417 .long 0x41009460
418 .long 0xff00fff0
419 .long 0
420 .long 0
421 b __arm946_setup
422 .long cpu_arch_name
423 .long cpu_elf_name
424 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
425 .long cpu_arm946_name
426 .long arm946_processor_functions
427 .long 0
428 .long 0
429 .long arm946_cache_fns
430 .size __arm946_proc_info, . - __arm946_proc_info
431
432