blob: 1f96f5851a9869f3d9cf6df906acb6a8c5dd0a86 [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>
8#include <platform.h>
9
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}