blob: 2b98acb278b5867d22664ad6686164a29063a276 [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>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <lib/psci/psci.h>
Benjamin Fair42eea872016-10-14 01:13:47 +000010
11/* The power domain tree descriptor */
12static unsigned char power_domain_tree_desc[] = {
Andrew F. Davis34d8b682018-06-25 12:10:53 -050013 PLATFORM_SYSTEM_COUNT,
Benjamin Fair42eea872016-10-14 01:13:47 +000014 PLATFORM_CLUSTER_COUNT,
15 K3_CLUSTER0_CORE_COUNT,
16#if K3_CLUSTER1_MSMC_PORT != UNUSED
17 K3_CLUSTER1_CORE_COUNT,
18#endif /* K3_CLUSTER1_MSMC_PORT != UNUSED */
19#if K3_CLUSTER2_MSMC_PORT != UNUSED
20 K3_CLUSTER2_CORE_COUNT,
21#endif /* K3_CLUSTER2_MSMC_PORT != UNUSED */
22#if K3_CLUSTER3_MSMC_PORT != UNUSED
23 K3_CLUSTER3_CORE_COUNT,
24#endif /* K3_CLUSTER3_MSMC_PORT != UNUSED */
25};
26
27const unsigned char *plat_get_power_domain_tree_desc(void)
28{
29 return power_domain_tree_desc;
30}
31
32int plat_core_pos_by_mpidr(u_register_t mpidr)
33{
34 unsigned int cpu_id;
35
36 mpidr &= MPIDR_AFFINITY_MASK;
37
38 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
39 return -1;
40
41 cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
42
43 switch (MPIDR_AFFLVL1_VAL(mpidr)) {
44 case K3_CLUSTER0_MSMC_PORT:
45 if (cpu_id < K3_CLUSTER0_CORE_COUNT)
46 return cpu_id;
47 return -1;
48#if K3_CLUSTER1_MSMC_PORT != UNUSED
49 case K3_CLUSTER1_MSMC_PORT:
50 if (cpu_id < K3_CLUSTER1_CORE_COUNT)
51 return K3_CLUSTER0_CORE_COUNT + cpu_id;
52 return -1;
53#endif /* K3_CLUSTER1_MSMC_PORT != UNUSED */
54#if K3_CLUSTER2_MSMC_PORT != UNUSED
55 case K3_CLUSTER2_MSMC_PORT:
56 if (cpu_id < K3_CLUSTER2_CORE_COUNT)
57 return K3_CLUSTER0_CORE_COUNT +
58 K3_CLUSTER1_CORE_COUNT + cpu_id;
59 return -1;
60#endif /* K3_CLUSTER2_MSMC_PORT != UNUSED */
61#if K3_CLUSTER3_MSMC_PORT != UNUSED
62 case K3_CLUSTER3_MSMC_PORT:
63 if (cpu_id < K3_CLUSTER3_CORE_COUNT)
64 return K3_CLUSTER0_CORE_COUNT +
65 K3_CLUSTER1_CORE_COUNT +
66 K3_CLUSTER2_CORE_COUNT + cpu_id;
67 return -1;
68#endif /* K3_CLUSTER3_MSMC_PORT != UNUSED */
69 default:
70 return -1;
71 }
72}