plat_topology.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2018-2022, Xilinx, Inc. All rights reserved.
  4. * Copyright (c) 2022, Advanced Micro Devices, Inc. All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #include <common/debug.h>
  9. #include <plat/common/platform.h>
  10. #include <plat_private.h>
  11. #include <platform_def.h>
  12. static const uint8_t plat_power_domain_tree_desc[] = {
  13. /* Number of root nodes */
  14. 1,
  15. /* Number of clusters */
  16. PLATFORM_CLUSTER_COUNT,
  17. /* Number of children for the first cluster node */
  18. PLATFORM_CORE_COUNT_PER_CLUSTER,
  19. /* Number of children for the second cluster node */
  20. PLATFORM_CORE_COUNT_PER_CLUSTER,
  21. /* Number of children for the third cluster node */
  22. PLATFORM_CORE_COUNT_PER_CLUSTER,
  23. /* Number of children for the fourth cluster node */
  24. PLATFORM_CORE_COUNT_PER_CLUSTER,
  25. };
  26. const uint8_t *plat_get_power_domain_tree_desc(void)
  27. {
  28. return plat_power_domain_tree_desc;
  29. }
  30. /*******************************************************************************
  31. * This function implements a part of the critical interface between the psci
  32. * generic layer and the platform that allows the former to query the platform
  33. * to convert an MPIDR to a unique linear index. An error code (-1) is returned
  34. * in case the MPIDR is invalid.
  35. ******************************************************************************/
  36. int32_t plat_core_pos_by_mpidr(u_register_t mpidr)
  37. {
  38. uint32_t cluster_id, cpu_id;
  39. mpidr &= MPIDR_AFFINITY_MASK;
  40. cluster_id = MPIDR_AFFLVL2_VAL(mpidr);
  41. cpu_id = MPIDR_AFFLVL1_VAL(mpidr);
  42. if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
  43. return -3;
  44. }
  45. /*
  46. * Validate cpu_id by checking whether it represents a CPU in
  47. * one of the two clusters present on the platform.
  48. */
  49. if (cpu_id >= PLATFORM_CORE_COUNT_PER_CLUSTER) {
  50. return -1;
  51. }
  52. return (cpu_id + (cluster_id * PLATFORM_CORE_COUNT_PER_CLUSTER));
  53. }