ARM: soft-reboot into same mode that we entered the kernel
[sfrench/cifs-2.6.git] / arch / arm / mm / proc-v7.S
1 /*
2  *  linux/arch/arm/mm/proc-v7.S
3  *
4  *  Copyright (C) 2001 Deep Blue Solutions Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  *  This is the "shell" of the ARMv7 processor support.
11  */
12 #include <linux/init.h>
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
15 #include <asm/asm-offsets.h>
16 #include <asm/hwcap.h>
17 #include <asm/pgtable-hwdef.h>
18 #include <asm/pgtable.h>
19 #include <asm/memory.h>
20
21 #include "proc-macros.S"
22
23 #ifdef CONFIG_ARM_LPAE
24 #include "proc-v7-3level.S"
25 #else
26 #include "proc-v7-2level.S"
27 #endif
28
29 ENTRY(cpu_v7_proc_init)
30         ret     lr
31 ENDPROC(cpu_v7_proc_init)
32
33 ENTRY(cpu_v7_proc_fin)
34         mrc     p15, 0, r0, c1, c0, 0           @ ctrl register
35         bic     r0, r0, #0x1000                 @ ...i............
36         bic     r0, r0, #0x0006                 @ .............ca.
37         mcr     p15, 0, r0, c1, c0, 0           @ disable caches
38         ret     lr
39 ENDPROC(cpu_v7_proc_fin)
40
41 /*
42  *      cpu_v7_reset(loc)
43  *
44  *      Perform a soft reset of the system.  Put the CPU into the
45  *      same state as it would be if it had been reset, and branch
46  *      to what would be the reset vector.
47  *
48  *      - loc   - location to jump to for soft reset
49  *
50  *      This code must be executed using a flat identity mapping with
51  *      caches disabled.
52  */
53         .align  5
54         .pushsection    .idmap.text, "ax"
55 ENTRY(cpu_v7_reset)
56         mrc     p15, 0, r2, c1, c0, 0           @ ctrl register
57         bic     r2, r2, #0x1                    @ ...............m
58  THUMB( bic     r2, r2, #1 << 30 )              @ SCTLR.TE (Thumb exceptions)
59         mcr     p15, 0, r2, c1, c0, 0           @ disable MMU
60         isb
61 #ifdef CONFIG_ARM_VIRT_EXT
62         teq     r1, #0
63         bne     __hyp_soft_restart
64 #endif
65         bx      r0
66 ENDPROC(cpu_v7_reset)
67         .popsection
68
69 /*
70  *      cpu_v7_do_idle()
71  *
72  *      Idle the processor (eg, wait for interrupt).
73  *
74  *      IRQs are already disabled.
75  */
76 ENTRY(cpu_v7_do_idle)
77         dsb                                     @ WFI may enter a low-power mode
78         wfi
79         ret     lr
80 ENDPROC(cpu_v7_do_idle)
81
82 ENTRY(cpu_v7_dcache_clean_area)
83         ALT_SMP(W(nop))                 @ MP extensions imply L1 PTW
84         ALT_UP_B(1f)
85         ret     lr
86 1:      dcache_line_size r2, r3
87 2:      mcr     p15, 0, r0, c7, c10, 1          @ clean D entry
88         add     r0, r0, r2
89         subs    r1, r1, r2
90         bhi     2b
91         dsb     ishst
92         ret     lr
93 ENDPROC(cpu_v7_dcache_clean_area)
94
95         string  cpu_v7_name, "ARMv7 Processor"
96         .align
97
98 /* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */
99 .globl  cpu_v7_suspend_size
100 .equ    cpu_v7_suspend_size, 4 * 9
101 #ifdef CONFIG_ARM_CPU_SUSPEND
102 ENTRY(cpu_v7_do_suspend)
103         stmfd   sp!, {r4 - r11, lr}
104         mrc     p15, 0, r4, c13, c0, 0  @ FCSE/PID
105         mrc     p15, 0, r5, c13, c0, 3  @ User r/o thread ID
106         stmia   r0!, {r4 - r5}
107 #ifdef CONFIG_MMU
108         mrc     p15, 0, r6, c3, c0, 0   @ Domain ID
109 #ifdef CONFIG_ARM_LPAE
110         mrrc    p15, 1, r5, r7, c2      @ TTB 1
111 #else
112         mrc     p15, 0, r7, c2, c0, 1   @ TTB 1
113 #endif
114         mrc     p15, 0, r11, c2, c0, 2  @ TTB control register
115 #endif
116         mrc     p15, 0, r8, c1, c0, 0   @ Control register
117         mrc     p15, 0, r9, c1, c0, 1   @ Auxiliary control register
118         mrc     p15, 0, r10, c1, c0, 2  @ Co-processor access control
119         stmia   r0, {r5 - r11}
120         ldmfd   sp!, {r4 - r11, pc}
121 ENDPROC(cpu_v7_do_suspend)
122
123 ENTRY(cpu_v7_do_resume)
124         mov     ip, #0
125         mcr     p15, 0, ip, c7, c5, 0   @ invalidate I cache
126         mcr     p15, 0, ip, c13, c0, 1  @ set reserved context ID
127         ldmia   r0!, {r4 - r5}
128         mcr     p15, 0, r4, c13, c0, 0  @ FCSE/PID
129         mcr     p15, 0, r5, c13, c0, 3  @ User r/o thread ID
130         ldmia   r0, {r5 - r11}
131 #ifdef CONFIG_MMU
132         mcr     p15, 0, ip, c8, c7, 0   @ invalidate TLBs
133         mcr     p15, 0, r6, c3, c0, 0   @ Domain ID
134 #ifdef CONFIG_ARM_LPAE
135         mcrr    p15, 0, r1, ip, c2      @ TTB 0
136         mcrr    p15, 1, r5, r7, c2      @ TTB 1
137 #else
138         ALT_SMP(orr     r1, r1, #TTB_FLAGS_SMP)
139         ALT_UP(orr      r1, r1, #TTB_FLAGS_UP)
140         mcr     p15, 0, r1, c2, c0, 0   @ TTB 0
141         mcr     p15, 0, r7, c2, c0, 1   @ TTB 1
142 #endif
143         mcr     p15, 0, r11, c2, c0, 2  @ TTB control register
144         ldr     r4, =PRRR               @ PRRR
145         ldr     r5, =NMRR               @ NMRR
146         mcr     p15, 0, r4, c10, c2, 0  @ write PRRR
147         mcr     p15, 0, r5, c10, c2, 1  @ write NMRR
148 #endif  /* CONFIG_MMU */
149         mrc     p15, 0, r4, c1, c0, 1   @ Read Auxiliary control register
150         teq     r4, r9                  @ Is it already set?
151         mcrne   p15, 0, r9, c1, c0, 1   @ No, so write it
152         mcr     p15, 0, r10, c1, c0, 2  @ Co-processor access control
153         isb
154         dsb
155         mov     r0, r8                  @ control register
156         b       cpu_resume_mmu
157 ENDPROC(cpu_v7_do_resume)
158 #endif
159
160 /*
161  * Cortex-A8
162  */
163         globl_equ       cpu_ca8_proc_init,      cpu_v7_proc_init
164         globl_equ       cpu_ca8_proc_fin,       cpu_v7_proc_fin
165         globl_equ       cpu_ca8_reset,          cpu_v7_reset
166         globl_equ       cpu_ca8_do_idle,        cpu_v7_do_idle
167         globl_equ       cpu_ca8_dcache_clean_area, cpu_v7_dcache_clean_area
168         globl_equ       cpu_ca8_set_pte_ext,    cpu_v7_set_pte_ext
169         globl_equ       cpu_ca8_suspend_size,   cpu_v7_suspend_size
170 #ifdef CONFIG_ARM_CPU_SUSPEND
171         globl_equ       cpu_ca8_do_suspend,     cpu_v7_do_suspend
172         globl_equ       cpu_ca8_do_resume,      cpu_v7_do_resume
173 #endif
174
175 /*
176  * Cortex-A9 processor functions
177  */
178         globl_equ       cpu_ca9mp_proc_init,    cpu_v7_proc_init
179         globl_equ       cpu_ca9mp_proc_fin,     cpu_v7_proc_fin
180         globl_equ       cpu_ca9mp_reset,        cpu_v7_reset
181         globl_equ       cpu_ca9mp_do_idle,      cpu_v7_do_idle
182         globl_equ       cpu_ca9mp_dcache_clean_area, cpu_v7_dcache_clean_area
183         globl_equ       cpu_ca9mp_switch_mm,    cpu_v7_switch_mm
184         globl_equ       cpu_ca9mp_set_pte_ext,  cpu_v7_set_pte_ext
185 .globl  cpu_ca9mp_suspend_size
186 .equ    cpu_ca9mp_suspend_size, cpu_v7_suspend_size + 4 * 2
187 #ifdef CONFIG_ARM_CPU_SUSPEND
188 ENTRY(cpu_ca9mp_do_suspend)
189         stmfd   sp!, {r4 - r5}
190         mrc     p15, 0, r4, c15, c0, 1          @ Diagnostic register
191         mrc     p15, 0, r5, c15, c0, 0          @ Power register
192         stmia   r0!, {r4 - r5}
193         ldmfd   sp!, {r4 - r5}
194         b       cpu_v7_do_suspend
195 ENDPROC(cpu_ca9mp_do_suspend)
196
197 ENTRY(cpu_ca9mp_do_resume)
198         ldmia   r0!, {r4 - r5}
199         mrc     p15, 0, r10, c15, c0, 1         @ Read Diagnostic register
200         teq     r4, r10                         @ Already restored?
201         mcrne   p15, 0, r4, c15, c0, 1          @ No, so restore it
202         mrc     p15, 0, r10, c15, c0, 0         @ Read Power register
203         teq     r5, r10                         @ Already restored?
204         mcrne   p15, 0, r5, c15, c0, 0          @ No, so restore it
205         b       cpu_v7_do_resume
206 ENDPROC(cpu_ca9mp_do_resume)
207 #endif
208
209 #ifdef CONFIG_CPU_PJ4B
210         globl_equ       cpu_pj4b_switch_mm,     cpu_v7_switch_mm
211         globl_equ       cpu_pj4b_set_pte_ext,   cpu_v7_set_pte_ext
212         globl_equ       cpu_pj4b_proc_init,     cpu_v7_proc_init
213         globl_equ       cpu_pj4b_proc_fin,      cpu_v7_proc_fin
214         globl_equ       cpu_pj4b_reset,         cpu_v7_reset
215 #ifdef CONFIG_PJ4B_ERRATA_4742
216 ENTRY(cpu_pj4b_do_idle)
217         dsb                                     @ WFI may enter a low-power mode
218         wfi
219         dsb                                     @barrier
220         ret     lr
221 ENDPROC(cpu_pj4b_do_idle)
222 #else
223         globl_equ       cpu_pj4b_do_idle,       cpu_v7_do_idle
224 #endif
225         globl_equ       cpu_pj4b_dcache_clean_area,     cpu_v7_dcache_clean_area
226 #ifdef CONFIG_ARM_CPU_SUSPEND
227 ENTRY(cpu_pj4b_do_suspend)
228         stmfd   sp!, {r6 - r10}
229         mrc     p15, 1, r6, c15, c1, 0  @ save CP15 - extra features
230         mrc     p15, 1, r7, c15, c2, 0  @ save CP15 - Aux Func Modes Ctrl 0
231         mrc     p15, 1, r8, c15, c1, 2  @ save CP15 - Aux Debug Modes Ctrl 2
232         mrc     p15, 1, r9, c15, c1, 1  @ save CP15 - Aux Debug Modes Ctrl 1
233         mrc     p15, 0, r10, c9, c14, 0  @ save CP15 - PMC
234         stmia   r0!, {r6 - r10}
235         ldmfd   sp!, {r6 - r10}
236         b cpu_v7_do_suspend
237 ENDPROC(cpu_pj4b_do_suspend)
238
239 ENTRY(cpu_pj4b_do_resume)
240         ldmia   r0!, {r6 - r10}
241         mcr     p15, 1, r6, c15, c1, 0  @ restore CP15 - extra features
242         mcr     p15, 1, r7, c15, c2, 0  @ restore CP15 - Aux Func Modes Ctrl 0
243         mcr     p15, 1, r8, c15, c1, 2  @ restore CP15 - Aux Debug Modes Ctrl 2
244         mcr     p15, 1, r9, c15, c1, 1  @ restore CP15 - Aux Debug Modes Ctrl 1
245         mcr     p15, 0, r10, c9, c14, 0  @ restore CP15 - PMC
246         b cpu_v7_do_resume
247 ENDPROC(cpu_pj4b_do_resume)
248 #endif
249 .globl  cpu_pj4b_suspend_size
250 .equ    cpu_pj4b_suspend_size, cpu_v7_suspend_size + 4 * 5
251
252 #endif
253
254 /*
255  *      __v7_setup
256  *
257  *      Initialise TLB, Caches, and MMU state ready to switch the MMU
258  *      on.  Return in r0 the new CP15 C1 control register setting.
259  *
260  *      r1, r2, r4, r5, r9, r13 must be preserved - r13 is not a stack
261  *      r4: TTBR0 (low word)
262  *      r5: TTBR0 (high word if LPAE)
263  *      r8: TTBR1
264  *      r9: Main ID register
265  *
266  *      This should be able to cover all ARMv7 cores.
267  *
268  *      It is assumed that:
269  *      - cache type register is implemented
270  */
271 __v7_ca5mp_setup:
272 __v7_ca9mp_setup:
273 __v7_cr7mp_setup:
274         mov     r10, #(1 << 0)                  @ Cache/TLB ops broadcasting
275         b       1f
276 __v7_ca7mp_setup:
277 __v7_ca12mp_setup:
278 __v7_ca15mp_setup:
279 __v7_b15mp_setup:
280 __v7_ca17mp_setup:
281         mov     r10, #0
282 1:      adr     r0, __v7_setup_stack_ptr
283         ldr     r12, [r0]
284         add     r12, r12, r0                    @ the local stack
285         stmia   r12, {r1-r6, lr}                @ v7_invalidate_l1 touches r0-r6
286         bl      v7_invalidate_l1
287         ldmia   r12, {r1-r6, lr}
288 #ifdef CONFIG_SMP
289         orr     r10, r10, #(1 << 6)             @ Enable SMP/nAMP mode
290         ALT_SMP(mrc     p15, 0, r0, c1, c0, 1)
291         ALT_UP(mov      r0, r10)                @ fake it for UP
292         orr     r10, r10, r0                    @ Set required bits
293         teq     r10, r0                         @ Were they already set?
294         mcrne   p15, 0, r10, c1, c0, 1          @ No, update register
295 #endif
296         b       __v7_setup_cont
297
298 /*
299  * Errata:
300  *  r0, r10 available for use
301  *  r1, r2, r4, r5, r9, r13: must be preserved
302  *  r3: contains MIDR rX number in bits 23-20
303  *  r6: contains MIDR rXpY as 8-bit XY number
304  *  r9: MIDR
305  */
306 __ca8_errata:
307 #if defined(CONFIG_ARM_ERRATA_430973) && !defined(CONFIG_ARCH_MULTIPLATFORM)
308         teq     r3, #0x00100000                 @ only present in r1p*
309         mrceq   p15, 0, r0, c1, c0, 1           @ read aux control register
310         orreq   r0, r0, #(1 << 6)               @ set IBE to 1
311         mcreq   p15, 0, r0, c1, c0, 1           @ write aux control register
312 #endif
313 #ifdef CONFIG_ARM_ERRATA_458693
314         teq     r6, #0x20                       @ only present in r2p0
315         mrceq   p15, 0, r0, c1, c0, 1           @ read aux control register
316         orreq   r0, r0, #(1 << 5)               @ set L1NEON to 1
317         orreq   r0, r0, #(1 << 9)               @ set PLDNOP to 1
318         mcreq   p15, 0, r0, c1, c0, 1           @ write aux control register
319 #endif
320 #ifdef CONFIG_ARM_ERRATA_460075
321         teq     r6, #0x20                       @ only present in r2p0
322         mrceq   p15, 1, r0, c9, c0, 2           @ read L2 cache aux ctrl register
323         tsteq   r0, #1 << 22
324         orreq   r0, r0, #(1 << 22)              @ set the Write Allocate disable bit
325         mcreq   p15, 1, r0, c9, c0, 2           @ write the L2 cache aux ctrl register
326 #endif
327         b       __errata_finish
328
329 __ca9_errata:
330 #ifdef CONFIG_ARM_ERRATA_742230
331         cmp     r6, #0x22                       @ only present up to r2p2
332         mrcle   p15, 0, r0, c15, c0, 1          @ read diagnostic register
333         orrle   r0, r0, #1 << 4                 @ set bit #4
334         mcrle   p15, 0, r0, c15, c0, 1          @ write diagnostic register
335 #endif
336 #ifdef CONFIG_ARM_ERRATA_742231
337         teq     r6, #0x20                       @ present in r2p0
338         teqne   r6, #0x21                       @ present in r2p1
339         teqne   r6, #0x22                       @ present in r2p2
340         mrceq   p15, 0, r0, c15, c0, 1          @ read diagnostic register
341         orreq   r0, r0, #1 << 12                @ set bit #12
342         orreq   r0, r0, #1 << 22                @ set bit #22
343         mcreq   p15, 0, r0, c15, c0, 1          @ write diagnostic register
344 #endif
345 #ifdef CONFIG_ARM_ERRATA_743622
346         teq     r3, #0x00200000                 @ only present in r2p*
347         mrceq   p15, 0, r0, c15, c0, 1          @ read diagnostic register
348         orreq   r0, r0, #1 << 6                 @ set bit #6
349         mcreq   p15, 0, r0, c15, c0, 1          @ write diagnostic register
350 #endif
351 #if defined(CONFIG_ARM_ERRATA_751472) && defined(CONFIG_SMP)
352         ALT_SMP(cmp r6, #0x30)                  @ present prior to r3p0
353         ALT_UP_B(1f)
354         mrclt   p15, 0, r0, c15, c0, 1          @ read diagnostic register
355         orrlt   r0, r0, #1 << 11                @ set bit #11
356         mcrlt   p15, 0, r0, c15, c0, 1          @ write diagnostic register
357 1:
358 #endif
359         b       __errata_finish
360
361 __ca15_errata:
362 #ifdef CONFIG_ARM_ERRATA_773022
363         cmp     r6, #0x4                        @ only present up to r0p4
364         mrcle   p15, 0, r0, c1, c0, 1           @ read aux control register
365         orrle   r0, r0, #1 << 1                 @ disable loop buffer
366         mcrle   p15, 0, r0, c1, c0, 1           @ write aux control register
367 #endif
368         b       __errata_finish
369
370 __ca12_errata:
371 #ifdef CONFIG_ARM_ERRATA_818325_852422
372         mrc     p15, 0, r10, c15, c0, 1         @ read diagnostic register
373         orr     r10, r10, #1 << 12              @ set bit #12
374         mcr     p15, 0, r10, c15, c0, 1         @ write diagnostic register
375 #endif
376 #ifdef CONFIG_ARM_ERRATA_821420
377         mrc     p15, 0, r10, c15, c0, 2         @ read internal feature reg
378         orr     r10, r10, #1 << 1               @ set bit #1
379         mcr     p15, 0, r10, c15, c0, 2         @ write internal feature reg
380 #endif
381 #ifdef CONFIG_ARM_ERRATA_825619
382         mrc     p15, 0, r10, c15, c0, 1         @ read diagnostic register
383         orr     r10, r10, #1 << 24              @ set bit #24
384         mcr     p15, 0, r10, c15, c0, 1         @ write diagnostic register
385 #endif
386         b       __errata_finish
387
388 __ca17_errata:
389 #ifdef CONFIG_ARM_ERRATA_852421
390         cmp     r6, #0x12                       @ only present up to r1p2
391         mrcle   p15, 0, r10, c15, c0, 1         @ read diagnostic register
392         orrle   r10, r10, #1 << 24              @ set bit #24
393         mcrle   p15, 0, r10, c15, c0, 1         @ write diagnostic register
394 #endif
395 #ifdef CONFIG_ARM_ERRATA_852423
396         cmp     r6, #0x12                       @ only present up to r1p2
397         mrcle   p15, 0, r10, c15, c0, 1         @ read diagnostic register
398         orrle   r10, r10, #1 << 12              @ set bit #12
399         mcrle   p15, 0, r10, c15, c0, 1         @ write diagnostic register
400 #endif
401         b       __errata_finish
402
403 __v7_pj4b_setup:
404 #ifdef CONFIG_CPU_PJ4B
405
406 /* Auxiliary Debug Modes Control 1 Register */
407 #define PJ4B_STATIC_BP (1 << 2) /* Enable Static BP */
408 #define PJ4B_INTER_PARITY (1 << 8) /* Disable Internal Parity Handling */
409 #define PJ4B_CLEAN_LINE (1 << 16) /* Disable data transfer for clean line */
410
411 /* Auxiliary Debug Modes Control 2 Register */
412 #define PJ4B_FAST_LDR (1 << 23) /* Disable fast LDR */
413 #define PJ4B_SNOOP_DATA (1 << 25) /* Do not interleave write and snoop data */
414 #define PJ4B_CWF (1 << 27) /* Disable Critical Word First feature */
415 #define PJ4B_OUTSDNG_NC (1 << 29) /* Disable outstanding non cacheable rqst */
416 #define PJ4B_L1_REP_RR (1 << 30) /* L1 replacement - Strict round robin */
417 #define PJ4B_AUX_DBG_CTRL2 (PJ4B_SNOOP_DATA | PJ4B_CWF |\
418                             PJ4B_OUTSDNG_NC | PJ4B_L1_REP_RR)
419
420 /* Auxiliary Functional Modes Control Register 0 */
421 #define PJ4B_SMP_CFB (1 << 1) /* Set SMP mode. Join the coherency fabric */
422 #define PJ4B_L1_PAR_CHK (1 << 2) /* Support L1 parity checking */
423 #define PJ4B_BROADCAST_CACHE (1 << 8) /* Broadcast Cache and TLB maintenance */
424
425 /* Auxiliary Debug Modes Control 0 Register */
426 #define PJ4B_WFI_WFE (1 << 22) /* WFI/WFE - serve the DVM and back to idle */
427
428         /* Auxiliary Debug Modes Control 1 Register */
429         mrc     p15, 1, r0, c15, c1, 1
430         orr     r0, r0, #PJ4B_CLEAN_LINE
431         orr     r0, r0, #PJ4B_INTER_PARITY
432         bic     r0, r0, #PJ4B_STATIC_BP
433         mcr     p15, 1, r0, c15, c1, 1
434
435         /* Auxiliary Debug Modes Control 2 Register */
436         mrc     p15, 1, r0, c15, c1, 2
437         bic     r0, r0, #PJ4B_FAST_LDR
438         orr     r0, r0, #PJ4B_AUX_DBG_CTRL2
439         mcr     p15, 1, r0, c15, c1, 2
440
441         /* Auxiliary Functional Modes Control Register 0 */
442         mrc     p15, 1, r0, c15, c2, 0
443 #ifdef CONFIG_SMP
444         orr     r0, r0, #PJ4B_SMP_CFB
445 #endif
446         orr     r0, r0, #PJ4B_L1_PAR_CHK
447         orr     r0, r0, #PJ4B_BROADCAST_CACHE
448         mcr     p15, 1, r0, c15, c2, 0
449
450         /* Auxiliary Debug Modes Control 0 Register */
451         mrc     p15, 1, r0, c15, c1, 0
452         orr     r0, r0, #PJ4B_WFI_WFE
453         mcr     p15, 1, r0, c15, c1, 0
454
455 #endif /* CONFIG_CPU_PJ4B */
456
457 __v7_setup:
458         adr     r0, __v7_setup_stack_ptr
459         ldr     r12, [r0]
460         add     r12, r12, r0                    @ the local stack
461         stmia   r12, {r1-r6, lr}                @ v7_invalidate_l1 touches r0-r6
462         bl      v7_invalidate_l1
463         ldmia   r12, {r1-r6, lr}
464
465 __v7_setup_cont:
466         and     r0, r9, #0xff000000             @ ARM?
467         teq     r0, #0x41000000
468         bne     __errata_finish
469         and     r3, r9, #0x00f00000             @ variant
470         and     r6, r9, #0x0000000f             @ revision
471         orr     r6, r6, r3, lsr #20-4           @ combine variant and revision
472         ubfx    r0, r9, #4, #12                 @ primary part number
473
474         /* Cortex-A8 Errata */
475         ldr     r10, =0x00000c08                @ Cortex-A8 primary part number
476         teq     r0, r10
477         beq     __ca8_errata
478
479         /* Cortex-A9 Errata */
480         ldr     r10, =0x00000c09                @ Cortex-A9 primary part number
481         teq     r0, r10
482         beq     __ca9_errata
483
484         /* Cortex-A12 Errata */
485         ldr     r10, =0x00000c0d                @ Cortex-A12 primary part number
486         teq     r0, r10
487         beq     __ca12_errata
488
489         /* Cortex-A17 Errata */
490         ldr     r10, =0x00000c0e                @ Cortex-A17 primary part number
491         teq     r0, r10
492         beq     __ca17_errata
493
494         /* Cortex-A15 Errata */
495         ldr     r10, =0x00000c0f                @ Cortex-A15 primary part number
496         teq     r0, r10
497         beq     __ca15_errata
498
499 __errata_finish:
500         mov     r10, #0
501         mcr     p15, 0, r10, c7, c5, 0          @ I+BTB cache invalidate
502 #ifdef CONFIG_MMU
503         mcr     p15, 0, r10, c8, c7, 0          @ invalidate I + D TLBs
504         v7_ttb_setup r10, r4, r5, r8, r3        @ TTBCR, TTBRx setup
505         ldr     r3, =PRRR                       @ PRRR
506         ldr     r6, =NMRR                       @ NMRR
507         mcr     p15, 0, r3, c10, c2, 0          @ write PRRR
508         mcr     p15, 0, r6, c10, c2, 1          @ write NMRR
509 #endif
510         dsb                                     @ Complete invalidations
511 #ifndef CONFIG_ARM_THUMBEE
512         mrc     p15, 0, r0, c0, c1, 0           @ read ID_PFR0 for ThumbEE
513         and     r0, r0, #(0xf << 12)            @ ThumbEE enabled field
514         teq     r0, #(1 << 12)                  @ check if ThumbEE is present
515         bne     1f
516         mov     r3, #0
517         mcr     p14, 6, r3, c1, c0, 0           @ Initialize TEEHBR to 0
518         mrc     p14, 6, r0, c0, c0, 0           @ load TEECR
519         orr     r0, r0, #1                      @ set the 1st bit in order to
520         mcr     p14, 6, r0, c0, c0, 0           @ stop userspace TEEHBR access
521 1:
522 #endif
523         adr     r3, v7_crval
524         ldmia   r3, {r3, r6}
525  ARM_BE8(orr    r6, r6, #1 << 25)               @ big-endian page tables
526 #ifdef CONFIG_SWP_EMULATE
527         orr     r3, r3, #(1 << 10)              @ set SW bit in "clear"
528         bic     r6, r6, #(1 << 10)              @ clear it in "mmuset"
529 #endif
530         mrc     p15, 0, r0, c1, c0, 0           @ read control register
531         bic     r0, r0, r3                      @ clear bits them
532         orr     r0, r0, r6                      @ set them
533  THUMB( orr     r0, r0, #1 << 30        )       @ Thumb exceptions
534         ret     lr                              @ return to head.S:__ret
535
536         .align  2
537 __v7_setup_stack_ptr:
538         .word   PHYS_RELATIVE(__v7_setup_stack, .)
539 ENDPROC(__v7_setup)
540
541         .bss
542         .align  2
543 __v7_setup_stack:
544         .space  4 * 7                           @ 7 registers
545
546         __INITDATA
547
548         @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
549         define_processor_functions v7, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
550 #ifndef CONFIG_ARM_LPAE
551         define_processor_functions ca8, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
552         define_processor_functions ca9mp, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
553 #endif
554 #ifdef CONFIG_CPU_PJ4B
555         define_processor_functions pj4b, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
556 #endif
557
558         .section ".rodata"
559
560         string  cpu_arch_name, "armv7"
561         string  cpu_elf_name, "v7"
562         .align
563
564         .section ".proc.info.init", #alloc
565
566         /*
567          * Standard v7 proc info content
568          */
569 .macro __v7_proc name, initfunc, mm_mmuflags = 0, io_mmuflags = 0, hwcaps = 0, proc_fns = v7_processor_functions
570         ALT_SMP(.long   PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \
571                         PMD_SECT_AF | PMD_FLAGS_SMP | \mm_mmuflags)
572         ALT_UP(.long    PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \
573                         PMD_SECT_AF | PMD_FLAGS_UP | \mm_mmuflags)
574         .long   PMD_TYPE_SECT | PMD_SECT_AP_WRITE | \
575                 PMD_SECT_AP_READ | PMD_SECT_AF | \io_mmuflags
576         initfn  \initfunc, \name
577         .long   cpu_arch_name
578         .long   cpu_elf_name
579         .long   HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_FAST_MULT | \
580                 HWCAP_EDSP | HWCAP_TLS | \hwcaps
581         .long   cpu_v7_name
582         .long   \proc_fns
583         .long   v7wbi_tlb_fns
584         .long   v6_user_fns
585         .long   v7_cache_fns
586 .endm
587
588 #ifndef CONFIG_ARM_LPAE
589         /*
590          * ARM Ltd. Cortex A5 processor.
591          */
592         .type   __v7_ca5mp_proc_info, #object
593 __v7_ca5mp_proc_info:
594         .long   0x410fc050
595         .long   0xff0ffff0
596         __v7_proc __v7_ca5mp_proc_info, __v7_ca5mp_setup
597         .size   __v7_ca5mp_proc_info, . - __v7_ca5mp_proc_info
598
599         /*
600          * ARM Ltd. Cortex A9 processor.
601          */
602         .type   __v7_ca9mp_proc_info, #object
603 __v7_ca9mp_proc_info:
604         .long   0x410fc090
605         .long   0xff0ffff0
606         __v7_proc __v7_ca9mp_proc_info, __v7_ca9mp_setup, proc_fns = ca9mp_processor_functions
607         .size   __v7_ca9mp_proc_info, . - __v7_ca9mp_proc_info
608
609         /*
610          * ARM Ltd. Cortex A8 processor.
611          */
612         .type   __v7_ca8_proc_info, #object
613 __v7_ca8_proc_info:
614         .long   0x410fc080
615         .long   0xff0ffff0
616         __v7_proc __v7_ca8_proc_info, __v7_setup, proc_fns = ca8_processor_functions
617         .size   __v7_ca8_proc_info, . - __v7_ca8_proc_info
618
619 #endif  /* CONFIG_ARM_LPAE */
620
621         /*
622          * Marvell PJ4B processor.
623          */
624 #ifdef CONFIG_CPU_PJ4B
625         .type   __v7_pj4b_proc_info, #object
626 __v7_pj4b_proc_info:
627         .long   0x560f5800
628         .long   0xff0fff00
629         __v7_proc __v7_pj4b_proc_info, __v7_pj4b_setup, proc_fns = pj4b_processor_functions
630         .size   __v7_pj4b_proc_info, . - __v7_pj4b_proc_info
631 #endif
632
633         /*
634          * ARM Ltd. Cortex R7 processor.
635          */
636         .type   __v7_cr7mp_proc_info, #object
637 __v7_cr7mp_proc_info:
638         .long   0x410fc170
639         .long   0xff0ffff0
640         __v7_proc __v7_cr7mp_proc_info, __v7_cr7mp_setup
641         .size   __v7_cr7mp_proc_info, . - __v7_cr7mp_proc_info
642
643         /*
644          * ARM Ltd. Cortex A7 processor.
645          */
646         .type   __v7_ca7mp_proc_info, #object
647 __v7_ca7mp_proc_info:
648         .long   0x410fc070
649         .long   0xff0ffff0
650         __v7_proc __v7_ca7mp_proc_info, __v7_ca7mp_setup
651         .size   __v7_ca7mp_proc_info, . - __v7_ca7mp_proc_info
652
653         /*
654          * ARM Ltd. Cortex A12 processor.
655          */
656         .type   __v7_ca12mp_proc_info, #object
657 __v7_ca12mp_proc_info:
658         .long   0x410fc0d0
659         .long   0xff0ffff0
660         __v7_proc __v7_ca12mp_proc_info, __v7_ca12mp_setup
661         .size   __v7_ca12mp_proc_info, . - __v7_ca12mp_proc_info
662
663         /*
664          * ARM Ltd. Cortex A15 processor.
665          */
666         .type   __v7_ca15mp_proc_info, #object
667 __v7_ca15mp_proc_info:
668         .long   0x410fc0f0
669         .long   0xff0ffff0
670         __v7_proc __v7_ca15mp_proc_info, __v7_ca15mp_setup
671         .size   __v7_ca15mp_proc_info, . - __v7_ca15mp_proc_info
672
673         /*
674          * Broadcom Corporation Brahma-B15 processor.
675          */
676         .type   __v7_b15mp_proc_info, #object
677 __v7_b15mp_proc_info:
678         .long   0x420f00f0
679         .long   0xff0ffff0
680         __v7_proc __v7_b15mp_proc_info, __v7_b15mp_setup
681         .size   __v7_b15mp_proc_info, . - __v7_b15mp_proc_info
682
683         /*
684          * ARM Ltd. Cortex A17 processor.
685          */
686         .type   __v7_ca17mp_proc_info, #object
687 __v7_ca17mp_proc_info:
688         .long   0x410fc0e0
689         .long   0xff0ffff0
690         __v7_proc __v7_ca17mp_proc_info, __v7_ca17mp_setup
691         .size   __v7_ca17mp_proc_info, . - __v7_ca17mp_proc_info
692
693         /*
694          * Qualcomm Inc. Krait processors.
695          */
696         .type   __krait_proc_info, #object
697 __krait_proc_info:
698         .long   0x510f0400              @ Required ID value
699         .long   0xff0ffc00              @ Mask for ID
700         /*
701          * Some Krait processors don't indicate support for SDIV and UDIV
702          * instructions in the ARM instruction set, even though they actually
703          * do support them. They also don't indicate support for fused multiply
704          * instructions even though they actually do support them.
705          */
706         __v7_proc __krait_proc_info, __v7_setup, hwcaps = HWCAP_IDIV | HWCAP_VFPv4
707         .size   __krait_proc_info, . - __krait_proc_info
708
709         /*
710          * Match any ARMv7 processor core.
711          */
712         .type   __v7_proc_info, #object
713 __v7_proc_info:
714         .long   0x000f0000              @ Required ID value
715         .long   0x000f0000              @ Mask for ID
716         __v7_proc __v7_proc_info, __v7_setup
717         .size   __v7_proc_info, . - __v7_proc_info