plat_topology.c 916 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2023, Aspeed Technology Inc.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <lib/psci/psci.h>
  8. #include <platform_def.h>
  9. static const unsigned char ast2700_power_domain_tree_desc[] = {
  10. PLATFORM_SYSTEM_COUNT,
  11. PLATFORM_CORE_COUNT_PER_CLUSTER,
  12. };
  13. const unsigned char *plat_get_power_domain_tree_desc(void)
  14. {
  15. return ast2700_power_domain_tree_desc;
  16. }
  17. unsigned int plat_core_pos_by_mpidr(u_register_t mpidr)
  18. {
  19. unsigned int cluster_id, cpu_id;
  20. mpidr &= MPIDR_AFFINITY_MASK;
  21. if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) {
  22. return -1;
  23. }
  24. cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
  25. cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
  26. if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
  27. return -1;
  28. }
  29. if (cpu_id >= PLATFORM_CORE_COUNT_PER_CLUSTER) {
  30. return -1;
  31. }
  32. return (cluster_id * PLATFORM_CORE_COUNT_PER_CLUSTER) + cpu_id;
  33. }