sbsa_topology.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2020, Nuvia Inc
  3. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #include <arch.h>
  8. #include <common/debug.h>
  9. #include <platform_def.h>
  10. #include "sbsa_private.h"
  11. /* The power domain tree descriptor */
  12. static unsigned char power_domain_tree_desc[PLATFORM_CLUSTER_COUNT + 1];
  13. /*******************************************************************************
  14. * This function returns the sbsa-ref default topology tree information.
  15. ******************************************************************************/
  16. const unsigned char *plat_get_power_domain_tree_desc(void)
  17. {
  18. unsigned int i;
  19. power_domain_tree_desc[0] = PLATFORM_CLUSTER_COUNT;
  20. for (i = 0U; i < PLATFORM_CLUSTER_COUNT; i++) {
  21. power_domain_tree_desc[i + 1] = PLATFORM_MAX_CPUS_PER_CLUSTER;
  22. }
  23. return power_domain_tree_desc;
  24. }
  25. /*******************************************************************************
  26. * This function implements a part of the critical interface between the psci
  27. * generic layer and the platform that allows the former to query the platform
  28. * to convert an MPIDR to a unique linear index. An error code (-1) is returned
  29. * in case the MPIDR is invalid.
  30. ******************************************************************************/
  31. int plat_core_pos_by_mpidr(u_register_t mpidr)
  32. {
  33. unsigned int cluster_id, cpu_id;
  34. mpidr &= MPIDR_AFFINITY_MASK;
  35. if ((mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) != 0U) {
  36. ERROR("Invalid MPIDR\n");
  37. return -1;
  38. }
  39. cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
  40. cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
  41. if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
  42. ERROR("cluster_id >= PLATFORM_CLUSTER_COUNT define\n");
  43. return -1;
  44. }
  45. if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER) {
  46. ERROR("cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER define\n");
  47. return -1;
  48. }
  49. return plat_qemu_calc_core_pos(mpidr);
  50. }