blob: d7ac0a5894dfd99200f008c5a3dac0243af08ec4 [file] [log] [blame]
Benjamin Fair42eea872016-10-14 01:13:47 +00001/*
2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <platform_def.h>
8#include <psci.h>
9
10/* The power domain tree descriptor */
11static unsigned char power_domain_tree_desc[] = {
Andrew F. Davis34d8b682018-06-25 12:10:53 -050012 PLATFORM_SYSTEM_COUNT,
Benjamin Fair42eea872016-10-14 01:13:47 +000013 PLATFORM_CLUSTER_COUNT,
14 K3_CLUSTER0_CORE_COUNT,
15#if K3_CLUSTER1_MSMC_PORT != UNUSED
16 K3_CLUSTER1_CORE_COUNT,
17#endif /* K3_CLUSTER1_MSMC_PORT != UNUSED */
18#if K3_CLUSTER2_MSMC_PORT != UNUSED
19 K3_CLUSTER2_CORE_COUNT,
20#endif /* K3_CLUSTER2_MSMC_PORT != UNUSED */
21#if K3_CLUSTER3_MSMC_PORT != UNUSED
22 K3_CLUSTER3_CORE_COUNT,
23#endif /* K3_CLUSTER3_MSMC_PORT != UNUSED */
24};
25
26const unsigned char *plat_get_power_domain_tree_desc(void)
27{
28 return power_domain_tree_desc;
29}
30
31int plat_core_pos_by_mpidr(u_register_t mpidr)
32{
33 unsigned int cpu_id;
34
35 mpidr &= MPIDR_AFFINITY_MASK;
36
37 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
38 return -1;
39
40 cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
41
42 switch (MPIDR_AFFLVL1_VAL(mpidr)) {
43 case K3_CLUSTER0_MSMC_PORT:
44 if (cpu_id < K3_CLUSTER0_CORE_COUNT)
45 return cpu_id;
46 return -1;
47#if K3_CLUSTER1_MSMC_PORT != UNUSED
48 case K3_CLUSTER1_MSMC_PORT:
49 if (cpu_id < K3_CLUSTER1_CORE_COUNT)
50 return K3_CLUSTER0_CORE_COUNT + cpu_id;
51 return -1;
52#endif /* K3_CLUSTER1_MSMC_PORT != UNUSED */
53#if K3_CLUSTER2_MSMC_PORT != UNUSED
54 case K3_CLUSTER2_MSMC_PORT:
55 if (cpu_id < K3_CLUSTER2_CORE_COUNT)
56 return K3_CLUSTER0_CORE_COUNT +
57 K3_CLUSTER1_CORE_COUNT + cpu_id;
58 return -1;
59#endif /* K3_CLUSTER2_MSMC_PORT != UNUSED */
60#if K3_CLUSTER3_MSMC_PORT != UNUSED
61 case K3_CLUSTER3_MSMC_PORT:
62 if (cpu_id < K3_CLUSTER3_CORE_COUNT)
63 return K3_CLUSTER0_CORE_COUNT +
64 K3_CLUSTER1_CORE_COUNT +
65 K3_CLUSTER2_CORE_COUNT + cpu_id;
66 return -1;
67#endif /* K3_CLUSTER3_MSMC_PORT != UNUSED */
68 default:
69 return -1;
70 }
71}