blob: 405aa33eb3425b49ce63b10ea42ce44b3a3e1deb [file] [log] [blame]
Yann Gautier9d135e42018-07-16 19:36:06 +02001/*
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 */
12static 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 */
18const 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 ******************************************************************************/
29int 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}