blob: 139f1fdb1bc90ea9cb38a37c72f33fbdc67dc465 [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,
Benjamin Fair42eea872016-10-14 01:13:47 +000016 K3_CLUSTER1_CORE_COUNT,
Benjamin Fair42eea872016-10-14 01:13:47 +000017 K3_CLUSTER2_CORE_COUNT,
Benjamin Fair42eea872016-10-14 01:13:47 +000018 K3_CLUSTER3_CORE_COUNT,
Benjamin Fair42eea872016-10-14 01:13:47 +000019};
20
21const unsigned char *plat_get_power_domain_tree_desc(void)
22{
23 return power_domain_tree_desc;
24}
25
26int plat_core_pos_by_mpidr(u_register_t mpidr)
27{
Andrew F. Davisb208ae32019-03-27 09:37:10 -050028 unsigned int cluster = MPIDR_AFFLVL1_VAL(mpidr);
29 unsigned int core = MPIDR_AFFLVL0_VAL(mpidr);
Benjamin Fair42eea872016-10-14 01:13:47 +000030
Andrew F. Davisb208ae32019-03-27 09:37:10 -050031 if (MPIDR_AFFLVL3_VAL(mpidr) > 0 ||
32 MPIDR_AFFLVL2_VAL(mpidr) > 0) {
Benjamin Fair42eea872016-10-14 01:13:47 +000033 return -1;
Andrew F. Davisb208ae32019-03-27 09:37:10 -050034 }
Benjamin Fair42eea872016-10-14 01:13:47 +000035
Andrew F. Davisb208ae32019-03-27 09:37:10 -050036 if (cluster > 0)
37 core += K3_CLUSTER0_CORE_COUNT;
38 if (cluster > 1)
39 core += K3_CLUSTER1_CORE_COUNT;
40 if (cluster > 2)
41 core += K3_CLUSTER2_CORE_COUNT;
42 if (cluster > 3)
Benjamin Fair42eea872016-10-14 01:13:47 +000043 return -1;
Andrew F. Davisb208ae32019-03-27 09:37:10 -050044
45 return core;
Benjamin Fair42eea872016-10-14 01:13:47 +000046}