Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <platform_def.h> |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 9 | #include <sys/types.h> |
Isla Mitchell | e363146 | 2017-07-14 10:46:32 +0100 | [diff] [blame] | 10 | #include "qemu_private.h" |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 11 | |
| 12 | /* The power domain tree descriptor */ |
| 13 | static unsigned char power_domain_tree_desc[] = { |
| 14 | /* Number of root nodes */ |
| 15 | PLATFORM_CLUSTER_COUNT, |
| 16 | /* Number of children for the first node */ |
| 17 | PLATFORM_CLUSTER0_CORE_COUNT, |
| 18 | /* Number of children for the second node */ |
| 19 | PLATFORM_CLUSTER1_CORE_COUNT, |
| 20 | }; |
| 21 | |
| 22 | /******************************************************************************* |
| 23 | * This function returns the ARM default topology tree information. |
| 24 | ******************************************************************************/ |
| 25 | const unsigned char *plat_get_power_domain_tree_desc(void) |
| 26 | { |
| 27 | return power_domain_tree_desc; |
| 28 | } |
| 29 | |
| 30 | /******************************************************************************* |
| 31 | * This function implements a part of the critical interface between the psci |
| 32 | * generic layer and the platform that allows the former to query the platform |
| 33 | * to convert an MPIDR to a unique linear index. An error code (-1) is returned |
| 34 | * in case the MPIDR is invalid. |
| 35 | ******************************************************************************/ |
| 36 | int plat_core_pos_by_mpidr(u_register_t mpidr) |
| 37 | { |
| 38 | unsigned int cluster_id, cpu_id; |
| 39 | |
| 40 | mpidr &= MPIDR_AFFINITY_MASK; |
| 41 | if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) |
| 42 | return -1; |
| 43 | |
| 44 | cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK; |
| 45 | cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK; |
| 46 | |
| 47 | if (cluster_id >= PLATFORM_CLUSTER_COUNT) |
| 48 | return -1; |
| 49 | |
| 50 | if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER) |
| 51 | return -1; |
| 52 | |
| 53 | return plat_qemu_calc_core_pos(mpidr); |
| 54 | } |