1 /* 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 */ 11 static unsigned char power_domain_tree_desc[] = { 12 PLATFORM_CLUSTER_COUNT, 13 K3_CLUSTER0_CORE_COUNT, 14 #if K3_CLUSTER1_MSMC_PORT != UNUSED 15 K3_CLUSTER1_CORE_COUNT, 16 #endif /* K3_CLUSTER1_MSMC_PORT != UNUSED */ 17 #if K3_CLUSTER2_MSMC_PORT != UNUSED 18 K3_CLUSTER2_CORE_COUNT, 19 #endif /* K3_CLUSTER2_MSMC_PORT != UNUSED */ 20 #if K3_CLUSTER3_MSMC_PORT != UNUSED 21 K3_CLUSTER3_CORE_COUNT, 22 #endif /* K3_CLUSTER3_MSMC_PORT != UNUSED */ 23 }; 24 25 const unsigned char *plat_get_power_domain_tree_desc(void) 26 { 27 return power_domain_tree_desc; 28 } 29 30 int plat_core_pos_by_mpidr(u_register_t mpidr) 31 { 32 unsigned int cpu_id; 33 34 mpidr &= MPIDR_AFFINITY_MASK; 35 36 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) 37 return -1; 38 39 cpu_id = MPIDR_AFFLVL0_VAL(mpidr); 40 41 switch (MPIDR_AFFLVL1_VAL(mpidr)) { 42 case K3_CLUSTER0_MSMC_PORT: 43 if (cpu_id < K3_CLUSTER0_CORE_COUNT) 44 return cpu_id; 45 return -1; 46 #if K3_CLUSTER1_MSMC_PORT != UNUSED 47 case K3_CLUSTER1_MSMC_PORT: 48 if (cpu_id < K3_CLUSTER1_CORE_COUNT) 49 return K3_CLUSTER0_CORE_COUNT + cpu_id; 50 return -1; 51 #endif /* K3_CLUSTER1_MSMC_PORT != UNUSED */ 52 #if K3_CLUSTER2_MSMC_PORT != UNUSED 53 case K3_CLUSTER2_MSMC_PORT: 54 if (cpu_id < K3_CLUSTER2_CORE_COUNT) 55 return K3_CLUSTER0_CORE_COUNT + 56 K3_CLUSTER1_CORE_COUNT + cpu_id; 57 return -1; 58 #endif /* K3_CLUSTER2_MSMC_PORT != UNUSED */ 59 #if K3_CLUSTER3_MSMC_PORT != UNUSED 60 case K3_CLUSTER3_MSMC_PORT: 61 if (cpu_id < K3_CLUSTER3_CORE_COUNT) 62 return K3_CLUSTER0_CORE_COUNT + 63 K3_CLUSTER1_CORE_COUNT + 64 K3_CLUSTER2_CORE_COUNT + cpu_id; 65 return -1; 66 #endif /* K3_CLUSTER3_MSMC_PORT != UNUSED */ 67 default: 68 return -1; 69 } 70 } 71