blob: b80903d06199b25d1bef4681d1e6eb55b5cfc4ea [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
John Tsichritzis56369c12019-02-19 13:49:06 +00002 * Copyright (c) 2018-2019, 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>
Deepak Pandeyb5615362018-10-11 13:44:43 +053012#include <cpu_macros.S>
Nariman Poushin0ece80f2018-02-26 06:52:04 +000013
Nariman Poushin0ece80f2018-02-26 06:52:04 +000014 .globl plat_arm_calc_core_pos
Chandni Cherukuri82718852018-08-02 12:29:07 +053015 .globl plat_reset_handler
Nariman Poushin0ece80f2018-02-26 06:52:04 +000016
17 /* -----------------------------------------------------
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053018 * unsigned int plat_arm_calc_core_pos(u_register_t mpidr)
19 *
20 * Helper function to calculate the core position.
21 * (ClusterId * CSS_SGI_MAX_CPUS_PER_CLUSTER * CSS_SGI_MAX_PE_PER_CPU) +
22 * (CPUId * CSS_SGI_MAX_PE_PER_CPU) +
23 * ThreadId
24 *
25 * which can be simplified as:
26 *
27 * ((ClusterId * CSS_SGI_MAX_CPUS_PER_CLUSTER + CPUId) *
28 * CSS_SGI_MAX_PE_PER_CPU) + ThreadId
29 * ------------------------------------------------------
30 */
31
Nariman Poushin0ece80f2018-02-26 06:52:04 +000032func plat_arm_calc_core_pos
Vishwanatha HG64f0b6f2018-05-08 17:15:37 +053033 mov x3, x0
34
35 /*
36 * The MT bit in MPIDR is always set for SGI platforms
37 * and the affinity level 0 corresponds to thread affinity level.
38 */
39
40 /* Extract individual affinity fields from MPIDR */
41 ubfx x0, x3, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS
42 ubfx x1, x3, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS
43 ubfx x2, x3, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
44
45 /* Compute linear position */
46 mov x4, #CSS_SGI_MAX_CPUS_PER_CLUSTER
47 madd x1, x2, x4, x1
48 mov x5, #CSS_SGI_MAX_PE_PER_CPU
49 madd x0, x1, x5, x0
Nariman Poushin0ece80f2018-02-26 06:52:04 +000050 ret
51endfunc plat_arm_calc_core_pos
Chandni Cherukuri82718852018-08-02 12:29:07 +053052
Chandni Cherukuri82718852018-08-02 12:29:07 +053053 /* -----------------------------------------------------
54 * void plat_reset_handler(void);
55 *
56 * Determine the CPU MIDR and disable power down bit for
57 * that CPU.
58 * -----------------------------------------------------
59 */
60func plat_reset_handler
61 jump_if_cpu_midr CORTEX_A75_MIDR, A75
John Tsichritzis56369c12019-02-19 13:49:06 +000062 jump_if_cpu_midr NEOVERSE_N1_MIDR, N1
Chandni Cherukuri82718852018-08-02 12:29:07 +053063 ret
64
65 /* -----------------------------------------------------
66 * Disable CPU power down bit in power control register
67 * -----------------------------------------------------
68 */
69A75:
70 mrs x0, CORTEX_A75_CPUPWRCTLR_EL1
71 bic x0, x0, #CORTEX_A75_CORE_PWRDN_EN_MASK
72 msr CORTEX_A75_CPUPWRCTLR_EL1, x0
73 isb
74 ret
Chandni Cherukuri044e27a2018-08-07 14:52:55 +053075
John Tsichritzis56369c12019-02-19 13:49:06 +000076N1:
77 mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1
78 bic x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK
79 msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0
Chandni Cherukuri044e27a2018-08-07 14:52:55 +053080 isb
81 ret
Chandni Cherukuri82718852018-08-02 12:29:07 +053082endfunc plat_reset_handler