1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* 3 * Copyright (C) 2024, Charleye <wangkart@aliyun.com> 4 * All rights reserved. 5 */ 6 7 #include <platform_def.h> 8 #include <lua_def.h> 9 10 #include <arch.h> 11 12 unsigned char lua_pd_tree_desc[PLAT_CLUSTER_COUNT + 1]; 13 14 int plat_core_pos_by_mpidr(u_register_t mpidr) 15 { 16 unsigned int cluster_id, cpu_id; 17 18 mpidr >>= 8; 19 20 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK; 21 if (cluster_id >= PLAT_CLUSTER_COUNT) 22 return -1; 23 24 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK; 25 if (cpu_id >= PLAT_MAX_CORES_PER_CLUSTER) 26 return -1; 27 28 return lua_calc_core_pos(mpidr); 29 } 30 31 const unsigned char *plat_get_power_domain_tree_desc(void) 32 { 33 int i; 34 35 lua_pd_tree_desc[0] = PLAT_CLUSTER_COUNT; 36 37 for (i = 0; i < PLAT_CLUSTER_COUNT; i++) 38 lua_pd_tree_desc[i + 1] = PLAT_MAX_CORES_PER_CLUSTER; 39 40 return lua_pd_tree_desc; 41 } 42