sunxi_topology.c 943 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <arch.h>
  8. #include <plat/common/platform.h>
  9. static const unsigned char plat_power_domain_tree_desc[PLAT_MAX_PWR_LVL + 1] = {
  10. /* One root node for the SoC */
  11. 1,
  12. /* One node for each cluster */
  13. PLATFORM_CLUSTER_COUNT,
  14. /* One set of CPUs per cluster */
  15. PLATFORM_MAX_CPUS_PER_CLUSTER,
  16. };
  17. int plat_core_pos_by_mpidr(u_register_t mpidr)
  18. {
  19. unsigned int cluster = MPIDR_AFFLVL1_VAL(mpidr);
  20. unsigned int core = MPIDR_AFFLVL0_VAL(mpidr);
  21. if (MPIDR_AFFLVL3_VAL(mpidr) > 0 ||
  22. MPIDR_AFFLVL2_VAL(mpidr) > 0 ||
  23. cluster >= PLATFORM_CLUSTER_COUNT ||
  24. core >= PLATFORM_MAX_CPUS_PER_CLUSTER) {
  25. return -1;
  26. }
  27. return cluster * PLATFORM_MAX_CPUS_PER_CLUSTER + core;
  28. }
  29. const unsigned char *plat_get_power_domain_tree_desc(void)
  30. {
  31. return plat_power_domain_tree_desc;
  32. }