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