blob: 3582c2bde36e2670569fb8d6933185122b872a49 [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001/*
2 * Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <debug.h>
8#include <platform_def.h>
9#include <psci.h>
10
11static const unsigned char rcar_power_domain_tree_desc[] = {
12 1,
13 PLATFORM_CLUSTER_COUNT,
14 PLATFORM_CLUSTER0_CORE_COUNT,
15 PLATFORM_CLUSTER1_CORE_COUNT
16};
17
18const unsigned char *plat_get_power_domain_tree_desc(void)
19{
20 return rcar_power_domain_tree_desc;
21}
22
23int plat_core_pos_by_mpidr(u_register_t mpidr)
24{
25 unsigned int cluster_id, cpu_id;
26
27 mpidr &= MPIDR_AFFINITY_MASK;
28
29 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
30 return -1;
31
32 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
33 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
34
35 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
36 return -1;
37
38 if (cluster_id == 0 && cpu_id >= PLATFORM_CLUSTER0_CORE_COUNT)
39 return -1;
40
41 if (cluster_id == 1 && cpu_id >= PLATFORM_CLUSTER1_CORE_COUNT)
42 return -1;
43
44 return (cpu_id + cluster_id * PLATFORM_CLUSTER0_CORE_COUNT);
45}
46