blob: d79f1aa21f6ca5ae69fc0c23f135e3934cb3e942 [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
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>
Chandni Cherukuri044e27a2018-08-07 14:52:55 +053011#include <cortex_ares.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
Chandni Cherukuri044e27a2018-08-07 14:52:55 +053062 jump_if_cpu_midr CORTEX_ARES_MIDR, ARES
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
76ARES:
77 mrs x0, CORTEX_ARES_CPUPWRCTLR_EL1
78 bic x0, x0, #CORTEX_ARES_CORE_PWRDN_EN_MASK
79 msr CORTEX_ARES_CPUPWRCTLR_EL1, x0
80 isb
81 ret
Chandni Cherukuri82718852018-08-02 12:29:07 +053082endfunc plat_reset_handler