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