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