Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 1 | /* |
| 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 Cherukuri | 8271885 | 2018-08-02 12:29:07 +0530 | [diff] [blame] | 10 | #include <cortex_a75.h> |
Chandni Cherukuri | 044e27a | 2018-08-07 14:52:55 +0530 | [diff] [blame] | 11 | #include <cortex_ares.h> |
Deepak Pandey | b561536 | 2018-10-11 13:44:43 +0530 | [diff] [blame] | 12 | #include <cpu_macros.S> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 13 | |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 14 | .globl plat_arm_calc_core_pos |
Chandni Cherukuri | 8271885 | 2018-08-02 12:29:07 +0530 | [diff] [blame] | 15 | .globl plat_reset_handler |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 16 | |
| 17 | /* ----------------------------------------------------- |
Vishwanatha HG | 64f0b6f | 2018-05-08 17:15:37 +0530 | [diff] [blame] | 18 | * 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 Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 32 | func plat_arm_calc_core_pos |
Vishwanatha HG | 64f0b6f | 2018-05-08 17:15:37 +0530 | [diff] [blame] | 33 | 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 Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 50 | ret |
| 51 | endfunc plat_arm_calc_core_pos |
Chandni Cherukuri | 8271885 | 2018-08-02 12:29:07 +0530 | [diff] [blame] | 52 | |
Chandni Cherukuri | 8271885 | 2018-08-02 12:29:07 +0530 | [diff] [blame] | 53 | /* ----------------------------------------------------- |
| 54 | * void plat_reset_handler(void); |
| 55 | * |
| 56 | * Determine the CPU MIDR and disable power down bit for |
| 57 | * that CPU. |
| 58 | * ----------------------------------------------------- |
| 59 | */ |
| 60 | func plat_reset_handler |
| 61 | jump_if_cpu_midr CORTEX_A75_MIDR, A75 |
Chandni Cherukuri | 044e27a | 2018-08-07 14:52:55 +0530 | [diff] [blame] | 62 | jump_if_cpu_midr CORTEX_ARES_MIDR, ARES |
Chandni Cherukuri | 8271885 | 2018-08-02 12:29:07 +0530 | [diff] [blame] | 63 | ret |
| 64 | |
| 65 | /* ----------------------------------------------------- |
| 66 | * Disable CPU power down bit in power control register |
| 67 | * ----------------------------------------------------- |
| 68 | */ |
| 69 | A75: |
| 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 Cherukuri | 044e27a | 2018-08-07 14:52:55 +0530 | [diff] [blame] | 75 | |
| 76 | ARES: |
| 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 Cherukuri | 8271885 | 2018-08-02 12:29:07 +0530 | [diff] [blame] | 82 | endfunc plat_reset_handler |