Samuel Holland | b856664 | 2017-08-12 04:07:39 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Samuel Holland | b856664 | 2017-08-12 04:07:39 -0500 | [diff] [blame] | 7 | #include <platform_def.h> |
| 8 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <arch.h> |
| 10 | #include <plat/common/platform.h> |
| 11 | |
Samuel Holland | 7057b84 | 2019-02-17 15:09:11 -0600 | [diff] [blame] | 12 | static const unsigned char plat_power_domain_tree_desc[PLAT_MAX_PWR_LVL + 1] = { |
Samuel Holland | b856664 | 2017-08-12 04:07:39 -0500 | [diff] [blame] | 13 | /* One root node for the SoC */ |
| 14 | 1, |
| 15 | /* One node for each cluster */ |
| 16 | PLATFORM_CLUSTER_COUNT, |
| 17 | /* One set of CPUs per cluster */ |
| 18 | PLATFORM_MAX_CPUS_PER_CLUSTER, |
| 19 | }; |
| 20 | |
| 21 | int plat_core_pos_by_mpidr(u_register_t mpidr) |
| 22 | { |
| 23 | unsigned int cluster = MPIDR_AFFLVL1_VAL(mpidr); |
| 24 | unsigned int core = MPIDR_AFFLVL0_VAL(mpidr); |
| 25 | |
| 26 | if (MPIDR_AFFLVL3_VAL(mpidr) > 0 || |
| 27 | MPIDR_AFFLVL2_VAL(mpidr) > 0 || |
| 28 | cluster >= PLATFORM_CLUSTER_COUNT || |
| 29 | core >= PLATFORM_MAX_CPUS_PER_CLUSTER) { |
| 30 | return -1; |
| 31 | } |
| 32 | |
| 33 | return cluster * PLATFORM_MAX_CPUS_PER_CLUSTER + core; |
| 34 | } |
| 35 | |
| 36 | const unsigned char *plat_get_power_domain_tree_desc(void) |
| 37 | { |
| 38 | return plat_power_domain_tree_desc; |
| 39 | } |