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 9 #include <lib/psci/psci.h> 10 11 /* The power domain tree descriptor */ 12 static unsigned char power_domain_tree_desc[] = { 13 PLATFORM_SYSTEM_COUNT, 14 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 27 const unsigned char *plat_get_power_domain_tree_desc(void) 28 { 29 return power_domain_tree_desc; 30 } 31 32 int 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 } 73