blob: d8cdc0e90db733a01d19c548728cc12c6a7ad836 [file] [log] [blame]
Stephan Gerhold14fdf072021-12-01 20:01:11 +01001/*
Stephan Gerholdf0ed7282022-09-16 10:45:19 +02002 * Copyright (c) 2022, Stephan Gerhold <stephan@gerhold.net>
Stephan Gerhold14fdf072021-12-01 20:01:11 +01003 * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include <arch.h>
9#include <plat/common/platform.h>
10
11#include <platform_def.h>
12
Stephan Gerholdf0ed7282022-09-16 10:45:19 +020013static const unsigned char plat_power_domain_tree_desc[] = {
Stephan Gerhold14fdf072021-12-01 20:01:11 +010014 PLATFORM_SYSTEM_COUNT,
15 PLATFORM_CLUSTER_COUNT,
Stephan Gerholdf0ed7282022-09-16 10:45:19 +020016 PLATFORM_CPUS_PER_CLUSTER,
17#if PLATFORM_CLUSTER_COUNT > 1
18 PLATFORM_CPUS_PER_CLUSTER,
19#endif
Stephan Gerhold14fdf072021-12-01 20:01:11 +010020};
21
22int plat_core_pos_by_mpidr(u_register_t mpidr)
23{
Stephan Gerholdf0ed7282022-09-16 10:45:19 +020024 unsigned int cluster = MPIDR_AFFLVL1_VAL(mpidr);
Stephan Gerhold14fdf072021-12-01 20:01:11 +010025 unsigned int core = MPIDR_AFFLVL0_VAL(mpidr);
26
27 if (MPIDR_AFFLVL3_VAL(mpidr) > 0 ||
28 MPIDR_AFFLVL2_VAL(mpidr) > 0 ||
Stephan Gerholdf0ed7282022-09-16 10:45:19 +020029 cluster >= PLATFORM_CLUSTER_COUNT ||
30 core >= PLATFORM_CPUS_PER_CLUSTER) {
Stephan Gerhold14fdf072021-12-01 20:01:11 +010031 return -1;
32 }
Stephan Gerholdf0ed7282022-09-16 10:45:19 +020033 return core | (cluster << PLATFORM_CPU_PER_CLUSTER_SHIFT);
Stephan Gerhold14fdf072021-12-01 20:01:11 +010034}
35
36const unsigned char *plat_get_power_domain_tree_desc(void)
37{
38 return plat_power_domain_tree_desc;
39}