blob: 213ec143e2774cf1c48a60feb566610ee3b81375 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +09002/*
3 * arch/arm/cpu/armv8/rcar_gen3/lowlevel_init.S
4 * This file is lowlevel initialize routine.
5 *
6 * (C) Copyright 2015 Renesas Electronics Corporation
7 *
8 * This file is based on the arch/arm/cpu/armv8/start.S
9 *
10 * (C) Copyright 2013
11 * David Feng <fenghua@phytium.com.cn>
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +090012 */
13
14#include <asm-offsets.h>
15#include <config.h>
16#include <linux/linkage.h>
17#include <asm/macro.h>
18
Marek Vasutbca66e22018-10-18 18:38:05 +020019.align 8
20.globl rcar_atf_boot_args
21rcar_atf_boot_args:
22 .dword 0
23 .dword 0
24 .dword 0
25 .dword 0
26
27ENTRY(save_boot_params)
28 adr x8, rcar_atf_boot_args
29 stp x0, x1, [x8], #16
30 stp x2, x3, [x8], #16
31 b save_boot_params_ret
32ENDPROC(save_boot_params)
33
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +090034ENTRY(lowlevel_init)
35 mov x29, lr /* Save LR */
36
37#ifndef CONFIG_ARMV8_MULTIENTRY
38 /*
39 * For single-entry systems the lowlevel init is very simple.
40 */
41 ldr x0, =GICD_BASE
42 bl gic_init_secure
43
44#else /* CONFIG_ARMV8_MULTIENTRY is set */
45
46#if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
47 branch_if_slave x0, 1f
48 ldr x0, =GICD_BASE
49 bl gic_init_secure
501:
51#if defined(CONFIG_GICV3)
52 ldr x0, =GICR_BASE
53 bl gic_init_secure_percpu
54#elif defined(CONFIG_GICV2)
55 ldr x0, =GICD_BASE
56 ldr x1, =GICC_BASE
57 bl gic_init_secure_percpu
58#endif
59#endif
60
61 branch_if_master x0, x1, 2f
62
63 /*
64 * Slave should wait for master clearing spin table.
65 * This sync prevent salves observing incorrect
66 * value of spin table and jumping to wrong place.
67 */
68#if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
69#ifdef CONFIG_GICV2
70 ldr x0, =GICC_BASE
71#endif
72 bl gic_wait_for_interrupt
73#endif
74
75 /*
76 * All slaves will enter EL2 and optionally EL1.
77 */
Alison Wangeb2088d2017-01-17 09:39:17 +080078 adr x4, lowlevel_in_el2
79 ldr x5, =ES_TO_AARCH64
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +090080 bl armv8_switch_to_el2
Alison Wang73818d52016-11-10 10:49:03 +080081
82lowlevel_in_el2:
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +090083#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
Alison Wangeb2088d2017-01-17 09:39:17 +080084 adr x4, lowlevel_in_el1
85 ldr x5, =ES_TO_AARCH64
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +090086 bl armv8_switch_to_el1
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +090087
Alison Wang73818d52016-11-10 10:49:03 +080088lowlevel_in_el1:
89#endif
Nobuhiro Iwamatsu4dc515a2016-04-01 03:51:34 +090090#endif /* CONFIG_ARMV8_MULTIENTRY */
91
92 bl s_init
93
942:
95 mov lr, x29 /* Restore LR */
96 ret
97ENDPROC(lowlevel_init)