blob: f415f87723ad29596b632e8a85d89300eeb8c6b3 [file] [log] [blame]
Tony Xief6118cc2016-01-15 17:17:32 +08001/*
2 * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Tony Xief6118cc2016-01-15 17:17:32 +08005 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <bl_common.h>
10#include <cortex_a53.h>
11#include <cortex_a72.h>
12#include <plat_private.h>
13#include <platform_def.h>
Tony Xie42e113e2016-07-16 11:16:51 +080014#include <plat_pmu_macros.S>
Tony Xief6118cc2016-01-15 17:17:32 +080015
16 .globl cpuson_entry_point
17 .globl cpuson_flags
18 .globl platform_cpu_warmboot
19 .globl plat_secondary_cold_boot_setup
20 .globl plat_report_exception
21 .globl platform_is_primary_cpu
Tony Xief6118cc2016-01-15 17:17:32 +080022 .globl plat_my_core_pos
23 .globl plat_reset_handler
Julius Werner624b5572017-06-19 17:05:30 -070024 .globl plat_panic_handler
Tony Xief6118cc2016-01-15 17:17:32 +080025
Tony Xief6118cc2016-01-15 17:17:32 +080026 /*
27 * void plat_reset_handler(void);
28 *
29 * Determine the SOC type and call the appropriate reset
30 * handler.
31 *
32 */
33func plat_reset_handler
Tony Xie42e113e2016-07-16 11:16:51 +080034 mrs x0, midr_el1
35 ubfx x0, x0, MIDR_PN_SHIFT, #12
36 cmp w0, #((CORTEX_A72_MIDR >> MIDR_PN_SHIFT) & MIDR_PN_MASK)
37 b.eq handler_a72
38 b handler_end
39handler_a72:
40 /*
41 * This handler does the following:
42 * Set the L2 Data RAM latency for Cortex-A72.
43 * Set the L2 Tag RAM latency to for Cortex-A72.
44 */
Varun Wadekar1384a162017-06-05 14:54:46 -070045 mov x0, #((5 << CORTEX_A72_L2CTLR_DATA_RAM_LATENCY_SHIFT) | \
Tony Xie42e113e2016-07-16 11:16:51 +080046 (0x1 << 5))
Varun Wadekar1384a162017-06-05 14:54:46 -070047 msr CORTEX_A72_L2CTLR_EL1, x0
Tony Xie42e113e2016-07-16 11:16:51 +080048 isb
49handler_end:
50 ret
Tony Xief6118cc2016-01-15 17:17:32 +080051endfunc plat_reset_handler
52
53func plat_my_core_pos
54 mrs x0, mpidr_el1
55 and x1, x0, #MPIDR_CPU_MASK
56 and x0, x0, #MPIDR_CLUSTER_MASK
Tony Xie42e113e2016-07-16 11:16:51 +080057 add x0, x1, x0, LSR #PLAT_RK_CLST_TO_CPUID_SHIFT
Tony Xief6118cc2016-01-15 17:17:32 +080058 ret
59endfunc plat_my_core_pos
60
61 /* --------------------------------------------------------------------
62 * void plat_secondary_cold_boot_setup (void);
63 *
64 * This function performs any platform specific actions
65 * needed for a secondary cpu after a cold reset e.g
66 * mark the cpu's presence, mechanism to place it in a
67 * holding pen etc.
68 * --------------------------------------------------------------------
69 */
70func plat_secondary_cold_boot_setup
71 /* rk3368 does not do cold boot for secondary CPU */
72cb_panic:
73 b cb_panic
74endfunc plat_secondary_cold_boot_setup
75
76func platform_is_primary_cpu
77 and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
78 cmp x0, #PLAT_RK_PRIMARY_CPU
79 cset x0, eq
80 ret
81endfunc platform_is_primary_cpu
82
83 /* --------------------------------------------------------------------
Julius Werner624b5572017-06-19 17:05:30 -070084 * void plat_panic_handler(void)
85 * Call system reset function on panic. Set up an emergency stack so we
86 * can run C functions (it only needs to last for a few calls until we
87 * reboot anyway).
88 * --------------------------------------------------------------------
89 */
90func plat_panic_handler
91 msr spsel, #0
92 bl plat_set_my_stack
93 b rockchip_soc_soft_reset
94endfunc plat_panic_handler
95
96 /* --------------------------------------------------------------------
Tony Xief6118cc2016-01-15 17:17:32 +080097 * void platform_cpu_warmboot (void);
98 * cpus online or resume enterpoint
99 * --------------------------------------------------------------------
100 */
Julius Wernerb4c75e92017-08-01 15:16:36 -0700101func platform_cpu_warmboot _align=16
Tony Xief6118cc2016-01-15 17:17:32 +0800102 mrs x0, MPIDR_EL1
Tony Xie42e113e2016-07-16 11:16:51 +0800103 and x19, x0, #MPIDR_CPU_MASK
104 and x20, x0, #MPIDR_CLUSTER_MASK
105 mov x0, x20
106 func_rockchip_clst_warmboot
Tony Xief6118cc2016-01-15 17:17:32 +0800107 /* --------------------------------------------------------------------
108 * big cluster id is 1
109 * big cores id is from 0-3, little cores id 4-7
110 * --------------------------------------------------------------------
111 */
Tony Xie42e113e2016-07-16 11:16:51 +0800112 add x21, x19, x20, lsr #PLAT_RK_CLST_TO_CPUID_SHIFT
Tony Xief6118cc2016-01-15 17:17:32 +0800113 /* --------------------------------------------------------------------
114 * get per cpuup flag
115 * --------------------------------------------------------------------
116 */
117 adr x4, cpuson_flags
Tony Xie42e113e2016-07-16 11:16:51 +0800118 add x4, x4, x21, lsl #2
Tony Xief6118cc2016-01-15 17:17:32 +0800119 ldr w1, [x4]
120 /* --------------------------------------------------------------------
Tony Xief6118cc2016-01-15 17:17:32 +0800121 * check cpuon reason
122 * --------------------------------------------------------------------
123 */
Tony Xie42e113e2016-07-16 11:16:51 +0800124 cmp w1, PMU_CPU_AUTO_PWRDN
Tony Xief6118cc2016-01-15 17:17:32 +0800125 b.eq boot_entry
Tony Xie42e113e2016-07-16 11:16:51 +0800126 cmp w1, PMU_CPU_HOTPLUG
Tony Xief6118cc2016-01-15 17:17:32 +0800127 b.eq boot_entry
128 /* --------------------------------------------------------------------
129 * If the boot core cpuson_flags or cpuson_entry_point is not
130 * expection. force the core into wfe.
131 * --------------------------------------------------------------------
132 */
133wfe_loop:
134 wfe
135 b wfe_loop
136boot_entry:
Tony Xie42e113e2016-07-16 11:16:51 +0800137 str wzr, [x4]
Caesar Wang59e41b52016-04-10 14:11:07 +0800138 /* --------------------------------------------------------------------
139 * get per cpuup boot addr
140 * --------------------------------------------------------------------
141 */
142 adr x5, cpuson_entry_point
Tony Xie42e113e2016-07-16 11:16:51 +0800143 ldr x2, [x5, x21, lsl #3]
Tony Xief6118cc2016-01-15 17:17:32 +0800144 br x2
145endfunc platform_cpu_warmboot
146
147 /* --------------------------------------------------------------------
148 * Per-CPU Secure entry point - resume or power up
149 * --------------------------------------------------------------------
150 */
151 .section tzfw_coherent_mem, "a"
152 .align 3
153cpuson_entry_point:
154 .rept PLATFORM_CORE_COUNT
155 .quad 0
156 .endr
157cpuson_flags:
158 .rept PLATFORM_CORE_COUNT
Caesar Wang59e41b52016-04-10 14:11:07 +0800159 .word 0
Tony Xief6118cc2016-01-15 17:17:32 +0800160 .endr
Tony Xie42e113e2016-07-16 11:16:51 +0800161rockchip_clst_warmboot_data