nuvoton_topology.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2015-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * Copyright (C) 2022-2023 Nuvoton Ltd.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #include <arch.h>
  9. #include <arch_helpers.h>
  10. #include <common/debug.h>
  11. #include <lib/psci/psci.h>
  12. #include <lib/semihosting.h>
  13. #include <plat/common/platform.h>
  14. /*
  15. * Since NPCM845 have only powered/non-powered state,
  16. * the tree is structure of level 0
  17. * (Single cluster == 0) and 4 representing a "leaf" for every CPU
  18. */
  19. const unsigned char npcm845x_power_domain_tree_desc[] = {
  20. PLATFORM_CLUSTER_COUNT,
  21. PLATFORM_MAX_CPU_PER_CLUSTER
  22. };
  23. const unsigned char *plat_get_power_domain_tree_desc(void)
  24. {
  25. /* A single cluster with 4 CPUs */
  26. return npcm845x_power_domain_tree_desc;
  27. }
  28. int plat_core_pos_by_mpidr(u_register_t mpidr)
  29. {
  30. unsigned int cluster_id, cpu_id;
  31. mpidr &= MPIDR_AFFINITY_MASK;
  32. if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) {
  33. return -1;
  34. }
  35. cluster_id = (unsigned int)MPIDR_AFFLVL1_VAL(mpidr);
  36. cpu_id = (unsigned int)MPIDR_AFFLVL0_VAL(mpidr);
  37. if (cluster_id > PLATFORM_CLUSTER_COUNT ||
  38. cpu_id > PLATFORM_MAX_CPU_PER_CLUSTER) {
  39. return -1;
  40. }
  41. return (int)(cpu_id + (cluster_id * 4));
  42. }