blob: 0d5880d7a2a65a64f50924365d2eb35edb6d16b2 [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
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02007#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <common/debug.h>
10#include <lib/psci/psci.h>
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020011
12static const unsigned char rcar_power_domain_tree_desc[] = {
13 1,
14 PLATFORM_CLUSTER_COUNT,
15 PLATFORM_CLUSTER0_CORE_COUNT,
16 PLATFORM_CLUSTER1_CORE_COUNT
17};
18
19const unsigned char *plat_get_power_domain_tree_desc(void)
20{
21 return rcar_power_domain_tree_desc;
22}
23
24int plat_core_pos_by_mpidr(u_register_t mpidr)
25{
26 unsigned int cluster_id, cpu_id;
27
28 mpidr &= MPIDR_AFFINITY_MASK;
29
30 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
31 return -1;
32
33 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
34 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
35
36 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
37 return -1;
38
39 if (cluster_id == 0 && cpu_id >= PLATFORM_CLUSTER0_CORE_COUNT)
40 return -1;
41
42 if (cluster_id == 1 && cpu_id >= PLATFORM_CLUSTER1_CORE_COUNT)
43 return -1;
44
45 return (cpu_id + cluster_id * PLATFORM_CLUSTER0_CORE_COUNT);
46}
47