]> git.ipfire.org Git - thirdparty/u-boot.git/blame - arch/arm/mach-exynos/lowlevel_init.c
common: Drop net.h from common header
[thirdparty/u-boot.git] / arch / arm / mach-exynos / lowlevel_init.c
CommitLineData
643be9c0
RS
1/*
2 * Lowlevel setup for EXYNOS5 based board
3 *
4 * Copyright (C) 2013 Samsung Electronics
5 * Rajeshwari Shinde <rajeshwari.s@samsung.com>
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27#include <config.h>
7fb57396 28#include <debug_uart.h>
90526e9f 29#include <asm/system.h>
643be9c0
RS
30#include <asm/arch/cpu.h>
31#include <asm/arch/dmc.h>
32#include <asm/arch/power.h>
33#include <asm/arch/tzpc.h>
34#include <asm/arch/periph.h>
35#include <asm/arch/pinmux.h>
ac0d98cd 36#include <asm/arch/system.h>
67a0652c 37#include <asm/armv7.h>
643be9c0 38#include "common_setup.h"
ac0d98cd 39#include "exynos5_setup.h"
643be9c0
RS
40
41/* These are the things we can do during low-level init */
42enum {
43 DO_WAKEUP = 1 << 0,
44 DO_CLOCKS = 1 << 1,
45 DO_MEM_RESET = 1 << 2,
46 DO_UART = 1 << 3,
567802bb 47 DO_POWER = 1 << 4,
643be9c0
RS
48};
49
ac0d98cd 50#ifdef CONFIG_EXYNOS5420
67a0652c
AS
51/*
52 * Power up secondary CPUs.
53 */
54static void secondary_cpu_start(void)
55{
56 v7_enable_smp(EXYNOS5420_INFORM_BASE);
57 svc32_mode_en();
cecf2db2 58 branch_bx(CONFIG_EXYNOS_RELOCATE_CODE_BASE);
67a0652c
AS
59}
60
61/*
62 * This is the entry point of hotplug-in and
63 * cluster switching.
64 */
65static void low_power_start(void)
66{
67 uint32_t val, reg_val;
68
69 reg_val = readl(EXYNOS5420_SPARE_BASE);
70 if (reg_val != CPU_RST_FLAG_VAL) {
71 writel(0x0, CONFIG_LOWPOWER_FLAG);
c8fd8e66 72 branch_bx(0x0);
67a0652c
AS
73 }
74
75 reg_val = readl(CONFIG_PHY_IRAM_BASE + 0x4);
76 if (reg_val != (uint32_t)&low_power_start) {
77 /* Store jump address as low_power_start if not present */
78 writel((uint32_t)&low_power_start, CONFIG_PHY_IRAM_BASE + 0x4);
79 dsb();
80 sev();
81 }
82
83 /* Set the CPU to SVC32 mode */
84 svc32_mode_en();
7e514eef
AS
85
86#ifndef CONFIG_SYS_L2CACHE_OFF
87 /* Read MIDR for Primary Part Number */
88 mrc_midr(val);
89 val = (val >> 4);
90 val &= 0xf;
91
92 if (val == 0xf) {
93 configure_l2_ctlr();
94 configure_l2_actlr();
95 v7_enable_l2_hazard_detect();
96 }
97#endif
67a0652c
AS
98
99 /* Invalidate L1 & TLB */
100 val = 0x0;
101 mcr_tlb(val);
102 mcr_icache(val);
103
104 /* Disable MMU stuff and caches */
105 mrc_sctlr(val);
106
107 val &= ~((0x2 << 12) | 0x7);
108 val |= ((0x1 << 12) | (0x8 << 8) | 0x2);
109 mcr_sctlr(val);
110
111 /* CPU state is hotplug or reset */
112 secondary_cpu_start();
113
114 /* Core should not enter into WFI here */
115 wfi();
116}
117
ac0d98cd
AS
118/*
119 * Pointer to this function is stored in iRam which is used
120 * for jump and power down of a specific core.
121 */
122static void power_down_core(void)
123{
124 uint32_t tmp, core_id, core_config;
125
126 /* Get the unique core id */
127 /*
128 * Multiprocessor Affinity Register
129 * [11:8] Cluster ID
130 * [1:0] CPU ID
131 */
132 mrc_mpafr(core_id);
133 tmp = core_id & 0x3;
134 core_id = (core_id >> 6) & ~3;
135 core_id |= tmp;
136 core_id &= 0x3f;
137
138 /* Set the status of the core to low */
139 core_config = (core_id * CPU_CONFIG_STATUS_OFFSET);
140 core_config += EXYNOS5420_CPU_CONFIG_BASE;
141 writel(0x0, core_config);
142
143 /* Core enter WFI */
144 wfi();
145}
146
147/*
148 * Configurations for secondary cores are inapt at this stage.
149 * Reconfigure secondary cores. Shutdown and change the status
150 * of all cores except the primary core.
151 */
152static void secondary_cores_configure(void)
153{
67a0652c
AS
154 /* Clear secondary boot iRAM base */
155 writel(0x0, (CONFIG_EXYNOS_RELOCATE_CODE_BASE + 0x1C));
156
157 /* set lowpower flag and address */
158 writel(CPU_RST_FLAG_VAL, CONFIG_LOWPOWER_FLAG);
159 writel((uint32_t)&low_power_start, CONFIG_LOWPOWER_ADDR);
160 writel(CPU_RST_FLAG_VAL, EXYNOS5420_SPARE_BASE);
161 /* Store jump address for power down */
ac0d98cd
AS
162 writel((uint32_t)&power_down_core, CONFIG_PHY_IRAM_BASE + 0x4);
163
164 /* Need all core power down check */
165 dsb();
166 sev();
ac0d98cd 167}
67a0652c
AS
168
169extern void relocate_wait_code(void);
ac0d98cd
AS
170#endif
171
643be9c0
RS
172int do_lowlevel_init(void)
173{
174 uint32_t reset_status;
175 int actions = 0;
176
177 arch_cpu_init();
178
14a66afe 179#if !defined(CONFIG_SYS_L2CACHE_OFF) && defined(CONFIG_EXYNOS5420)
306f527e
DA
180 /*
181 * Init L2 cache parameters here for use by boot and resume
182 *
183 * These are here instead of in v7_outer_cache_enable() so that the
184 * L2 cache settings get properly set even at resume time or if we're
185 * running U-Boot with the cache off. The kernel still needs us to
186 * set these for it.
187 */
188 configure_l2_ctlr();
189 configure_l2_actlr();
190 dsb();
191 isb();
306f527e 192
67a0652c
AS
193 relocate_wait_code();
194
ac0d98cd
AS
195 /* Reconfigure secondary cores */
196 secondary_cores_configure();
197#endif
198
643be9c0
RS
199 reset_status = get_reset_status();
200
201 switch (reset_status) {
202 case S5P_CHECK_SLEEP:
203 actions = DO_CLOCKS | DO_WAKEUP;
204 break;
205 case S5P_CHECK_DIDLE:
206 case S5P_CHECK_LPA:
207 actions = DO_WAKEUP;
208 break;
209 default:
210 /* This is a normal boot (not a wake from sleep) */
567802bb 211 actions = DO_CLOCKS | DO_MEM_RESET | DO_POWER;
643be9c0
RS
212 }
213
567802bb
DA
214 if (actions & DO_POWER)
215 set_ps_hold_ctrl();
216
643be9c0
RS
217 if (actions & DO_CLOCKS) {
218 system_clock_init();
7fb57396 219#ifdef CONFIG_DEBUG_UART
c06bbab6
MV
220#if (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_SERIAL_SUPPORT)) || \
221 !defined(CONFIG_SPL_BUILD)
7fb57396
SG
222 exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
223 debug_uart_init();
c06bbab6 224#endif
7fb57396 225#endif
643be9c0
RS
226 mem_ctrl_init(actions & DO_MEM_RESET);
227 tzpc_init();
228 }
229
230 return actions & DO_WAKEUP;
231}