blob: 1476fba386cd63b40c27709c433abeedc6913c9a [file] [log] [blame]
Chia-Wei Wanga7556d82022-11-02 17:50:21 +08001/*
2 * Copyright (c) 2023, Aspeed Technology Inc.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <lib/psci/psci.h>
9#include <platform_def.h>
10
11static const unsigned char ast2700_power_domain_tree_desc[] = {
12 PLATFORM_SYSTEM_COUNT,
13 PLATFORM_CORE_COUNT_PER_CLUSTER,
14};
15
16const unsigned char *plat_get_power_domain_tree_desc(void)
17{
18 return ast2700_power_domain_tree_desc;
19}
20
21unsigned int plat_core_pos_by_mpidr(u_register_t mpidr)
22{
23 unsigned int cluster_id, cpu_id;
24
25 mpidr &= MPIDR_AFFINITY_MASK;
26
27 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) {
28 return -1;
29 }
30
31 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
32 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
33
34 if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
35 return -1;
36 }
37
38 if (cpu_id >= PLATFORM_CORE_COUNT_PER_CLUSTER) {
39 return -1;
40 }
41
42 return (cluster_id * PLATFORM_CORE_COUNT_PER_CLUSTER) + cpu_id;
43}