blob: cc2f760ed2d79c2a659e94cd2e2dcf930ff7c95f [file] [log] [blame]
Usama Arifbec5afd2020-04-17 16:13:39 +01001/*
Jagdish Gediya4df2d372024-04-22 13:30:51 +00002 * Copyright (c) 2024, ARM Limited and Contributors. All rights reserved.
Usama Arifbec5afd2020-04-17 16:13:39 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <platform_def.h>
10#include <cpu_macros.S>
11
Jagdish Gediya8583ed42024-07-05 11:15:15 +000012#include <cortex_gelas.h>
13
Jagdish Gediya71d2d2b2024-07-17 15:34:28 +010014#define TC_HANDLER(rev) plat_reset_handler_tc##rev
15#define PLAT_RESET_HANDLER(rev) TC_HANDLER(rev)
16
Usama Arifbec5afd2020-04-17 16:13:39 +010017 .globl plat_arm_calc_core_pos
18 .globl plat_reset_handler
19
20 /* ---------------------------------------------------------------------
21 * unsigned int plat_arm_calc_core_pos(u_register_t mpidr)
22 *
Usama Ariff1513622021-04-09 17:07:41 +010023 * Function to calculate the core position on TC.
Usama Arifbec5afd2020-04-17 16:13:39 +010024 *
25 * (ClusterId * PLAT_MAX_CPUS_PER_CLUSTER * PLAT_MAX_PE_PER_CPU) +
26 * (CPUId * PLAT_MAX_PE_PER_CPU) +
27 * ThreadId
28 *
29 * which can be simplified as:
30 *
31 * ((ClusterId * PLAT_MAX_CPUS_PER_CLUSTER + CPUId) * PLAT_MAX_PE_PER_CPU)
32 * + ThreadId
33 * ---------------------------------------------------------------------
34 */
35func plat_arm_calc_core_pos
36 /*
37 * Check for MT bit in MPIDR. If not set, shift MPIDR to left to make it
38 * look as if in a multi-threaded implementation.
39 */
40 tst x0, #MPIDR_MT_MASK
41 lsl x3, x0, #MPIDR_AFFINITY_BITS
42 csel x3, x3, x0, eq
43
44 /* Extract individual affinity fields from MPIDR */
45 ubfx x0, x3, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS
46 ubfx x1, x3, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS
47 ubfx x2, x3, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
48
49 /* Compute linear position */
50 mov x4, #PLAT_MAX_CPUS_PER_CLUSTER
51 madd x1, x2, x4, x1
52 mov x5, #PLAT_MAX_PE_PER_CPU
53 madd x0, x1, x5, x0
54 ret
55endfunc plat_arm_calc_core_pos
56
Jagdish Gediyabfab8eb2024-07-23 15:41:34 +010057func mark_extllc_presence
58#ifdef MCN_CONFIG_ADDR
Jagdish Gediya5e386592024-06-19 08:50:45 +000059 mov_imm x0, (MCN_CONFIG_ADDR(0))
Jagdish Gediyabfab8eb2024-07-23 15:41:34 +010060 ldr w1, [x0]
61 ubfx x1, x1, #MCN_CONFIG_SLC_PRESENT_BIT, #1
Jagdish Gediya8583ed42024-07-05 11:15:15 +000062 jump_if_cpu_midr CORTEX_GELAS_MIDR, GELAS
63 sysreg_bitfield_insert_from_gpr CPUECTLR_EL1, x1, CPUECTLR_EL1_EXTLLC_BIT, 1
64 ret
65GELAS:
66 sysreg_bitfield_insert_from_gpr CORTEX_GELAS_IMP_CPUECTLR_EL1, x1, CPUECTLR2_EL1_EXTLLC_BIT, 1
Jagdish Gediyabfab8eb2024-07-23 15:41:34 +010067#endif
68 ret
69endfunc mark_extllc_presence
70
Jagdish Gediya71d2d2b2024-07-17 15:34:28 +010071func enable_dsu_pmu_el1_access
72 sysreg_bit_set actlr_el2, CPUACTLR_CLUSTERPMUEN
73 sysreg_bit_set actlr_el3, CPUACTLR_CLUSTERPMUEN
74 ret
75endfunc enable_dsu_pmu_el1_access
76
77func TC_HANDLER(2)
78 ret
79endfunc TC_HANDLER(2)
80
81func TC_HANDLER(3)
82 mov x9, lr
Jagdish Gediyabfab8eb2024-07-23 15:41:34 +010083 bl mark_extllc_presence
Jagdish Gediya71d2d2b2024-07-17 15:34:28 +010084 bl enable_dsu_pmu_el1_access
85 mov lr, x9
86 ret
87endfunc TC_HANDLER(3)
88
Jackson Cooper-Driver3653ded2023-12-14 14:32:40 +000089func TC_HANDLER(4)
Jagdish Gediyaeb0bcdf2024-06-19 06:59:22 +000090 mov x9, lr
Jagdish Gediya8583ed42024-07-05 11:15:15 +000091 bl mark_extllc_presence
Jagdish Gediyaeb0bcdf2024-06-19 06:59:22 +000092 bl enable_dsu_pmu_el1_access
93 mov lr, x9
Jackson Cooper-Driver3653ded2023-12-14 14:32:40 +000094 ret
95endfunc TC_HANDLER(4)
96
Usama Arifbec5afd2020-04-17 16:13:39 +010097 /* -----------------------------------------------------
98 * void plat_reset_handler(void);
Usama Arifbec5afd2020-04-17 16:13:39 +010099 * -----------------------------------------------------
100 */
101func plat_reset_handler
Jagdish Gediya71d2d2b2024-07-17 15:34:28 +0100102 mov x8, lr
103 bl PLAT_RESET_HANDLER(TARGET_PLATFORM)
104 mov lr, x8
Usama Arifbec5afd2020-04-17 16:13:39 +0100105 ret
106endfunc plat_reset_handler