Yann Gautier | 9d135e4 | 2018-07-16 19:36:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <platform_def.h> |
| 8 | #include <platform.h> |
| 9 | #include <psci.h> |
| 10 | |
| 11 | /* 1 cluster, all cores into */ |
| 12 | static const unsigned char stm32mp1_power_domain_tree_desc[] = { |
| 13 | PLATFORM_CLUSTER_COUNT, |
| 14 | PLATFORM_CORE_COUNT, |
| 15 | }; |
| 16 | |
| 17 | /* This function returns the platform topology */ |
| 18 | const unsigned char *plat_get_power_domain_tree_desc(void) |
| 19 | { |
| 20 | return stm32mp1_power_domain_tree_desc; |
| 21 | } |
| 22 | |
| 23 | /******************************************************************************* |
| 24 | * This function implements a part of the critical interface between the psci |
| 25 | * generic layer and the platform that allows the former to query the platform |
| 26 | * to convert an MPIDR to a unique linear index. An error code (-1) is returned |
| 27 | * in case the MPIDR is invalid. |
| 28 | ******************************************************************************/ |
| 29 | int plat_core_pos_by_mpidr(u_register_t mpidr) |
| 30 | { |
| 31 | unsigned int cluster_id, cpu_id; |
| 32 | u_register_t mpidr_copy = mpidr; |
| 33 | |
| 34 | mpidr_copy &= MPIDR_AFFINITY_MASK; |
| 35 | |
| 36 | if ((mpidr_copy & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) != 0U) { |
| 37 | return -1; |
| 38 | } |
| 39 | |
| 40 | cluster_id = (mpidr_copy >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK; |
| 41 | cpu_id = (mpidr_copy >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK; |
| 42 | |
| 43 | if (cluster_id >= PLATFORM_CLUSTER_COUNT) { |
| 44 | return -1; |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Validate cpu_id by checking whether it represents a CPU in one |
| 49 | * of the two clusters present on the platform. |
| 50 | */ |
| 51 | if (cpu_id >= PLATFORM_CORE_COUNT) { |
| 52 | return -1; |
| 53 | } |
| 54 | |
| 55 | return (int)cpu_id; |
| 56 | } |