plat_topology.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /* Project Includes */
  7. #include <arch.h>
  8. #include <arch_helpers.h>
  9. #include <lib/psci/psci.h>
  10. /* Platform Includes */
  11. #include <plat_helpers.h>
  12. #include <platform_def.h>
  13. const unsigned char mtk_power_domain_tree_desc[] = {
  14. /* Number of root nodes */
  15. PLATFORM_SYSTEM_COUNT,
  16. /* Number of children for the root node */
  17. PLATFORM_MCUSYS_COUNT,
  18. /* Number of children for the mcusys node */
  19. PLATFORM_CLUSTER_COUNT,
  20. /* Number of children for the first cluster node */
  21. PLATFORM_CLUSTER0_CORE_COUNT,
  22. };
  23. /*******************************************************************************
  24. * This function returns the MT8192 default topology tree information.
  25. ******************************************************************************/
  26. const unsigned char *plat_get_power_domain_tree_desc(void)
  27. {
  28. return mtk_power_domain_tree_desc;
  29. }
  30. /*******************************************************************************
  31. * This function implements a part of the critical interface between the psci
  32. * generic layer and the platform that allows the former to query the platform
  33. * to convert an MPIDR to a unique linear index. An error code (-1) is returned
  34. * in case the MPIDR is invalid.
  35. ******************************************************************************/
  36. int plat_core_pos_by_mpidr(u_register_t mpidr)
  37. {
  38. unsigned int cluster_id, cpu_id;
  39. if (read_mpidr() & MPIDR_MT_MASK) {
  40. /* ARMv8.2 arch */
  41. if (mpidr & (MPIDR_AFFLVL_MASK << MPIDR_AFF0_SHIFT)) {
  42. return -1;
  43. }
  44. return plat_mediatek_calc_core_pos(mpidr);
  45. }
  46. mpidr &= MPIDR_AFFINITY_MASK;
  47. if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) {
  48. return -1;
  49. }
  50. cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
  51. cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
  52. if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
  53. return -1;
  54. }
  55. /*
  56. * Validate cpu_id by checking whether it represents a CPU in
  57. * one of the two clusters present on the platform.
  58. */
  59. if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER) {
  60. return -1;
  61. }
  62. return (cpu_id + (cluster_id * 8));
  63. }