blob: c106c98b396529b75112bec74287cb114397cf63 [file] [log] [blame]
Masahiro Yamada574388c2016-09-03 11:37:40 +09001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <plat/common/platform.h>
Masahiro Yamada574388c2016-09-03 11:37:40 +09009
10#include "uniphier.h"
11
12static unsigned char uniphier_power_domain_tree_desc[UNIPHIER_CLUSTER_COUNT + 1];
13
14const unsigned char *plat_get_power_domain_tree_desc(void)
15{
16 int i;
17
18 uniphier_power_domain_tree_desc[0] = UNIPHIER_CLUSTER_COUNT;
19
20 for (i = 0; i < UNIPHIER_CLUSTER_COUNT; i++)
21 uniphier_power_domain_tree_desc[i + 1] =
22 UNIPHIER_MAX_CPUS_PER_CLUSTER;
23
24 return uniphier_power_domain_tree_desc;
25}
26
27int plat_core_pos_by_mpidr(u_register_t mpidr)
28{
29 unsigned int cluster_id, cpu_id;
30
31 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
32 if (cluster_id >= UNIPHIER_CLUSTER_COUNT)
33 return -1;
34
35 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
36 if (cpu_id >= UNIPHIER_MAX_CPUS_PER_CLUSTER)
37 return -1;
38
39 return uniphier_calc_core_pos(mpidr);
40}