blob: b1a4bb08fdae8e417eff20831144cc0c09059d16 [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
Vijayenthiran Subramaniamdde6d3e2019-10-29 15:56:41 +05302 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
Nariman Poushin0ece80f2018-02-26 06:52:04 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <platform_def.h>
Chandni Cherukuri82718852018-08-02 12:29:07 +053010#include <cortex_a75.h>
John Tsichritzis56369c12019-02-19 13:49:06 +000011#include <neoverse_n1.h>
shriram.ke69c60b2021-08-11 17:39:30 +053012#include <neoverse_v1.h>
Deepak Pandeyb5615362018-10-11 13:44:43 +053013#include <cpu_macros.S>
Nariman Poushin0ece80f2018-02-26 06:52:04 +000014
Nariman Poushin0ece80f2018-02-26 06:52:04 +000015 .globl plat_arm_calc_core_pos
Chandni Cherukuri82718852018-08-02 12:29:07 +053016 .globl plat_reset_handler
Nariman Poushin0ece80f2018-02-26 06:52:04 +000017
18 /* -----------------------------------------------------
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053019 * unsigned int plat_arm_calc_core_pos(u_register_t mpidr)
20 *
21 * Helper function to calculate the core position.
Vijayenthiran Subramaniamdde6d3e2019-10-29 15:56:41 +053022 * (ChipId * PLAT_ARM_CLUSTER_COUNT *
23 * CSS_SGI_MAX_CPUS_PER_CLUSTER * CSS_SGI_MAX_PE_PER_CPU) +
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053024 * (ClusterId * CSS_SGI_MAX_CPUS_PER_CLUSTER * CSS_SGI_MAX_PE_PER_CPU) +
25 * (CPUId * CSS_SGI_MAX_PE_PER_CPU) +
26 * ThreadId
27 *
28 * which can be simplified as:
29 *
Vijayenthiran Subramaniamdde6d3e2019-10-29 15:56:41 +053030 * ((((ChipId * PLAT_ARM_CLUSTER_COUNT) + ClusterId) *
31 * CSS_SGI_MAX_CPUS_PER_CLUSTER) + CPUId) * CSS_SGI_MAX_PE_PER_CPU +
32 * ThreadId
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053033 * ------------------------------------------------------
34 */
35
Nariman Poushin0ece80f2018-02-26 06:52:04 +000036func plat_arm_calc_core_pos
Vijayenthiran Subramaniamdde6d3e2019-10-29 15:56:41 +053037 mov x4, x0
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053038
39 /*
40 * The MT bit in MPIDR is always set for SGI platforms
41 * and the affinity level 0 corresponds to thread affinity level.
42 */
43
44 /* Extract individual affinity fields from MPIDR */
Vijayenthiran Subramaniamdde6d3e2019-10-29 15:56:41 +053045 ubfx x0, x4, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS
46 ubfx x1, x4, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS
47 ubfx x2, x4, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
48 ubfx x3, x4, #MPIDR_AFF3_SHIFT, #MPIDR_AFFINITY_BITS
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053049
50 /* Compute linear position */
Vijayenthiran Subramaniamdde6d3e2019-10-29 15:56:41 +053051 mov x4, #PLAT_ARM_CLUSTER_COUNT
52 madd x2, x3, x4, x2
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053053 mov x4, #CSS_SGI_MAX_CPUS_PER_CLUSTER
54 madd x1, x2, x4, x1
Vijayenthiran Subramaniamdde6d3e2019-10-29 15:56:41 +053055 mov x4, #CSS_SGI_MAX_PE_PER_CPU
56 madd x0, x1, x4, x0
Nariman Poushin0ece80f2018-02-26 06:52:04 +000057 ret
58endfunc plat_arm_calc_core_pos
Chandni Cherukuri82718852018-08-02 12:29:07 +053059
Chandni Cherukuri82718852018-08-02 12:29:07 +053060 /* -----------------------------------------------------
61 * void plat_reset_handler(void);
62 *
63 * Determine the CPU MIDR and disable power down bit for
64 * that CPU.
65 * -----------------------------------------------------
66 */
67func plat_reset_handler
68 jump_if_cpu_midr CORTEX_A75_MIDR, A75
John Tsichritzis56369c12019-02-19 13:49:06 +000069 jump_if_cpu_midr NEOVERSE_N1_MIDR, N1
shriram.ke69c60b2021-08-11 17:39:30 +053070 jump_if_cpu_midr NEOVERSE_V1_MIDR, V1
Chandni Cherukuri82718852018-08-02 12:29:07 +053071 ret
72
73 /* -----------------------------------------------------
74 * Disable CPU power down bit in power control register
75 * -----------------------------------------------------
76 */
77A75:
78 mrs x0, CORTEX_A75_CPUPWRCTLR_EL1
79 bic x0, x0, #CORTEX_A75_CORE_PWRDN_EN_MASK
80 msr CORTEX_A75_CPUPWRCTLR_EL1, x0
81 isb
82 ret
Chandni Cherukuri044e27a2018-08-07 14:52:55 +053083
John Tsichritzis56369c12019-02-19 13:49:06 +000084N1:
85 mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1
86 bic x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK
87 msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0
Chandni Cherukuri044e27a2018-08-07 14:52:55 +053088 isb
89 ret
shriram.ke69c60b2021-08-11 17:39:30 +053090
91V1:
92 mrs x0, NEOVERSE_V1_CPUPWRCTLR_EL1
93 bic x0, x0, #NEOVERSE_V1_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
94 msr NEOVERSE_V1_CPUPWRCTLR_EL1, x0
95 isb
96 ret
Chandni Cherukuri82718852018-08-02 12:29:07 +053097endfunc plat_reset_handler