uniphier_topology.c 953 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <plat/common/platform.h>
  8. #include "uniphier.h"
  9. static unsigned char uniphier_power_domain_tree_desc[UNIPHIER_CLUSTER_COUNT + 1];
  10. const unsigned char *plat_get_power_domain_tree_desc(void)
  11. {
  12. int i;
  13. uniphier_power_domain_tree_desc[0] = UNIPHIER_CLUSTER_COUNT;
  14. for (i = 0; i < UNIPHIER_CLUSTER_COUNT; i++)
  15. uniphier_power_domain_tree_desc[i + 1] =
  16. UNIPHIER_MAX_CPUS_PER_CLUSTER;
  17. return uniphier_power_domain_tree_desc;
  18. }
  19. int plat_core_pos_by_mpidr(u_register_t mpidr)
  20. {
  21. unsigned int cluster_id, cpu_id;
  22. cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
  23. if (cluster_id >= UNIPHIER_CLUSTER_COUNT)
  24. return -1;
  25. cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
  26. if (cpu_id >= UNIPHIER_MAX_CPUS_PER_CLUSTER)
  27. return -1;
  28. return uniphier_calc_core_pos(mpidr);
  29. }