2 * Copyright (C) 2012-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <linux/linkage.h>
9 #include <linux/sizes.h>
10 #include <asm/system.h>
11 #include <mach/arm-mpcore.h>
12 #include <mach/sbc-regs.h>
13 #include <mach/ssc-regs.h>
16 mov r8, lr @ persevere link reg across call
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
25 mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
26 orr r0, r0, #(CR_C | CR_M) @ enable MMU and Dcache
27 mcr p15, 0, r0, c1, c0, 0
29 #ifdef CONFIG_DEBUG_LL
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.
38 ldr r3, =init_page_table @ page table must be 16KB aligned
40 /* Disable MMU and Dcache before switching Page Table */
41 mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
42 bic r0, r0, #(CR_C | CR_M) @ disable MMU and Dcache
43 mcr p15, 0, r0, c1, c0, 0
47 #ifdef CONFIG_UNIPHIER_SMP
50 * Entry point for secondary CPUs
52 * The Boot ROM has already enabled MMU for the secondary CPUs as well
53 * as for the primary one. The MMU table embedded in the Boot ROM
54 * prohibits the DRAM access, so it is impossible to bring the
55 * secondary CPUs into DRAM directly. They must jump here into SPL,
56 * which is run on L2 cache.
59 * [primary CPU] [secondary CPUs]
60 * start from Boot ROM start from Boot ROM
61 * jump to SPL sleep in Boot ROM
62 * kick secondaries ---(sev)---> jump to SPL
63 * jump to U-Boot main sleep in SPL
65 * kick secondaries ---(sev)---> jump to Linux
68 /* branch by CPU ID */
69 mrc p15, 0, r0, c0, c0, 5 @ MPIDR (Multiprocessor Affinity Register)
73 /* only for secondary CPUs */
74 ldr r1, =ROM_BOOT_ROMRSV2 @ The last data access to L2 cache
75 mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
76 orr r0, r0, #CR_I @ Enable ICache
77 bic r0, r0, #(CR_C | CR_M) @ MMU and Dcache must be disabled
78 mcr p15, 0, r0, c1, c0, 0 @ before jumping to Linux
83 * L2 cache is shared among all the CPUs and it might be disabled by
84 * the primary one. Before that, the following 5 lines must be cached
85 * on the Icaches of the secondary CPUs.
87 0: wfe @ kicked by Linux
90 bxne r0 @ r0: Linux entry for secondary CPUs
93 ldr r1, =ROM_BOOT_ROMRSV2
94 ldr r0, =secondary_startup
96 ldr r0, [r1] @ make sure str is complete before sev
97 sev @ kick the secondary CPU
100 bl setup_init_ram @ RAM area for temporary stack pointer
102 mov lr, r8 @ restore link
103 mov pc, lr @ back to my caller
104 ENDPROC(lowlevel_init)
107 mrc p15, 0, r0, c2, c0, 2 @ TTBCR (Translation Table Base Control Register)
109 orr r0, r0, #0x20 @ disable TTBR1
110 mcr p15, 0, r0, c2, c0, 2
112 orr r0, r3, #0x8 @ Outer Cacheability for table walks: WBWA
113 mcr p15, 0, r0, c2, c0, 0 @ TTBR0
116 mcr p15, 0, r0, c8, c7, 0 @ invalidate TLBs
118 mov r0, #-1 @ manager for all domains (No permission check)
119 mcr p15, 0, r0, c3, c0, 0 @ DACR (Domain Access Control Register)
125 * TLBs was already invalidated in "../start.S"
126 * So, we don't need to invalidate it here.
128 mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
129 orr r0, r0, #(CR_C | CR_M) @ MMU and Dcache enable
130 mcr p15, 0, r0, c1, c0, 0
136 * For PH1-Pro4 or older SoCs, the size of WAY is 32KB.
137 * It is large enough for tmp RAM.
139 #define BOOT_RAM_SIZE (SZ_32K)
140 #define BOOT_WAY_BITS (0x00000100) /* way 8 */
142 ENTRY(setup_init_ram)
144 * Touch to zero for the boot way
148 * set SSCOQM, SSCOQAD, SSCOQSZ, SSCOQWN in this order
150 ldr r0, = 0x00408006 @ touch to zero with address range
153 ldr r0, = (CONFIG_SPL_STACK - BOOT_RAM_SIZE) @ base address
156 ldr r0, = BOOT_RAM_SIZE
159 ldr r0, = BOOT_WAY_BITS
164 cmp r0, #0 @ check if the command is successfully set
165 bne 0b @ try again if an error occurs
171 bne 1b @ wait until the operation is completed
172 str r0, [r1] @ clear the complete notification flag
175 ENDPROC(setup_init_ram)