]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/uniphier/lowlevel_init.S
Merge branch 'karo-tx-uboot' into kc-merge
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / uniphier / lowlevel_init.S
1 /*
2  * Copyright (C) 2012-2014 Panasonic Corporation
3  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <config.h>
9 #include <linux/linkage.h>
10 #include <asm/system.h>
11 #include <asm/arch/led.h>
12 #include <asm/arch/arm-mpcore.h>
13 #include <asm/arch/sbc-regs.h>
14
15 ENTRY(lowlevel_init)
16         mov     r8, lr                  @ persevere link reg across call
17
18         /*
19          * The UniPhier Boot ROM loads SPL code to the L2 cache.
20          * But CPUs can only do instruction fetch now because start.S has
21          * cleared C and M bits.
22          * First we need to turn on MMU and Dcache again to get back
23          * data access to L2.
24          */
25         mrc     p15, 0, r0, c1, c0, 0           @ SCTLR (System Contrl Register)
26         orr     r0, r0, #(CR_C | CR_M)          @ enable MMU and Dcache
27         mcr     p15, 0, r0, c1, c0, 0
28
29 #ifdef CONFIG_DEBUG_LL
30         bl      setup_lowlevel_debug
31 #endif
32
33         /*
34          * Now we are using the page table embedded in the Boot ROM.
35          * It is not handy since it is not a straight mapped table for sLD3.
36          * What we need to do next is to switch over to the page table in SPL.
37          */
38         ldr     r3, =init_page_table    @ page table must be 16KB aligned
39
40         /* Disable MMU and Dcache before switching Page Table */
41         mrc     p15, 0, r0, c1, c0, 0   @ SCTLR (System Contrl Register)
42         bic     r0, r0, #(CR_C | CR_M)  @ disable MMU and Dcache
43         mcr     p15, 0, r0, c1, c0, 0
44
45         bl      enable_mmu
46
47 #ifdef CONFIG_UNIPHIER_SMP
48         /*
49          * ACTLR (Auxiliary Control Register) for Cortex-A9
50          * bit[9]  Parity on
51          * bit[8]  Alloc in one way
52          * bit[7]  EXCL (Exclusive cache bit)
53          * bit[6]  SMP
54          * bit[3]  Write full line of zeros mode
55          * bit[2]  L1 Prefetch enable
56          * bit[1]  L2 prefetch enable
57          * bit[0]  FW (Cache and TLB maintenance broadcast)
58          */
59         mrc     p15, 0, r0, c1, c0, 1   @ ACTLR (Auxiliary Control Register)
60         orr     r0, r0, #0x41           @ enable SMP, FW bit
61         mcr     p15, 0, r0, c1, c0, 1
62
63         /* branch by CPU ID */
64         mrc     p15, 0, r0, c0, c0, 5   @ MPIDR (Multiprocessor Affinity Register)
65         and     r0, r0, #0x3
66         cmp     r0, #0x0
67         beq     primary_cpu
68         ldr     r1, =ROM_BOOT_ROMRSV2
69         mov     r0, #0
70         str     r0, [r1]
71 0:      wfe
72         ldr     r0, [r1]
73         cmp     r0, #0
74         beq     0b
75         bx      r0                      @ r0: entry point of U-Boot main for the secondary CPU
76 primary_cpu:
77         ldr     r1, =ROM_BOOT_ROMRSV2
78         ldr     r0, =_start             @ entry for the secondary CPU
79         str     r0, [r1]
80         ldr     r0, [r1]                @ make sure str is complete before sev
81         sev                             @ kick the sedoncary CPU
82         mrc     p15, 4, r1, c15, c0, 0  @ Configuration Base Address Register
83         bfc     r1, #0, #13             @ clear bit 12-0
84         mov     r0, #-1
85         str     r0, [r1, #SCU_INV_ALL]  @ SCU Invalidate All Register
86         mov     r0, #1                  @ SCU enable
87         str     r0, [r1, #SCU_CTRL]     @ SCU Control Register
88 #endif
89
90         bl      setup_init_ram          @ RAM area for temporary stack pointer
91
92         mov     lr, r8                  @ restore link
93         mov     pc, lr                  @ back to my caller
94 ENDPROC(lowlevel_init)
95
96 ENTRY(enable_mmu)
97         mrc     p15, 0, r0, c2, c0, 2   @ TTBCR (Translation Table Base Control Register)
98         bic     r0, r0, #0x37
99         orr     r0, r0, #0x20           @ disable TTBR1
100         mcr     p15, 0, r0, c2, c0, 2
101
102         orr     r0, r3, #0x8            @ Outer Cacheability for table walks: WBWA
103         mcr     p15, 0, r0, c2, c0, 0   @ TTBR0
104
105         mov     r0, #0
106         mcr     p15, 0, r0, c8, c7, 0   @ invalidate TLBs
107
108         mov     r0, #-1                 @ manager for all domains (No permission check)
109         mcr     p15, 0, r0, c3, c0, 0   @ DACR (Domain Access Control Register)
110
111         dsb
112         isb
113         /*
114          * MMU on:
115          * TLBs was already invalidated in "../start.S"
116          * So, we don't need to invalidate it here.
117          */
118         mrc     p15, 0, r0, c1, c0, 0   @ SCTLR (System Contrl Register)
119         orr     r0, r0, #(CR_C | CR_M)  @ MMU and Dcache enable
120         mcr     p15, 0, r0, c1, c0, 0
121
122         mov     pc, lr
123 ENDPROC(enable_mmu)
124
125 #include <asm/arch/ssc-regs.h>
126
127 #define BOOT_RAM_SIZE    (SSC_WAY_SIZE)
128 #define BOOT_WAY_BITS    (0x00000100)   /* way 8 */
129
130 ENTRY(setup_init_ram)
131         /*
132          * Touch to zero for the boot way
133          */
134 0:
135         /*
136          * set SSCOQM, SSCOQAD, SSCOQSZ, SSCOQWN in this order
137          */
138         ldr     r0, = 0x00408006        @ touch to zero with address range
139         ldr     r1, = SSCOQM
140         str     r0, [r1]
141         ldr     r0, = (CONFIG_SYS_INIT_SP_ADDR - BOOT_RAM_SIZE) @ base address
142         ldr     r1, = SSCOQAD
143         str     r0, [r1]
144         ldr     r0, = BOOT_RAM_SIZE
145         ldr     r1, = SSCOQSZ
146         str     r0, [r1]
147         ldr     r0, = BOOT_WAY_BITS
148         ldr     r1, = SSCOQWN
149         str     r0, [r1]
150         ldr     r1, = SSCOPPQSEF
151         ldr     r0, [r1]
152         cmp     r0, #0                  @ check if the command is successfully set
153         bne     0b                      @ try again if an error occurres
154
155         ldr     r1, = SSCOLPQS
156 1:
157         ldr     r0, [r1]
158         cmp     r0, #0x4
159         bne     1b                      @ wait until the operation is completed
160         str     r0, [r1]                @ clear the complete notification flag
161
162         mov     pc, lr
163 ENDPROC(setup_init_ram)