stm32mp2_topology.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2024, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <lib/psci/psci.h>
  7. #include <plat/common/platform.h>
  8. #include <platform_def.h>
  9. /* 1 cluster, all cores into */
  10. static const unsigned char stm32mp2_power_domain_tree_desc[] = {
  11. PLATFORM_CLUSTER_COUNT,
  12. PLATFORM_CORE_COUNT,
  13. };
  14. /* This function returns the platform topology */
  15. const unsigned char *plat_get_power_domain_tree_desc(void)
  16. {
  17. return stm32mp2_power_domain_tree_desc;
  18. }
  19. /*******************************************************************************
  20. * This function implements a part of the critical interface between the psci
  21. * generic layer and the platform that allows the former to query the platform
  22. * to convert an MPIDR to a unique linear index. An error code (-1) is returned
  23. * in case the MPIDR is invalid.
  24. ******************************************************************************/
  25. int plat_core_pos_by_mpidr(u_register_t mpidr)
  26. {
  27. unsigned int cluster_id, cpu_id;
  28. u_register_t mpidr_copy = mpidr;
  29. mpidr_copy &= MPIDR_AFFINITY_MASK;
  30. if ((mpidr_copy & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) != 0U) {
  31. return -1;
  32. }
  33. cluster_id = (mpidr_copy >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
  34. cpu_id = (mpidr_copy >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
  35. if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
  36. return -1;
  37. }
  38. /*
  39. * Validate cpu_id by checking whether it represents a CPU in one
  40. * of the two clusters present on the platform.
  41. */
  42. if (cpu_id >= PLATFORM_CORE_COUNT) {
  43. return -1;
  44. }
  45. return (int)cpu_id;
  46. }