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