a5ds_topology.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2019, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. /* The A5DS power domain tree descriptor */
  8. static const unsigned char a5ds_power_domain_tree_desc[] = {
  9. 1,
  10. /* No of children for the root node */
  11. A5DS_CLUSTER_COUNT,
  12. /* No of children for the first cluster node */
  13. A5DS_CORE_COUNT,
  14. };
  15. /*******************************************************************************
  16. * This function returns the topology according to A5DS_CLUSTER_COUNT.
  17. ******************************************************************************/
  18. const unsigned char *plat_get_power_domain_tree_desc(void)
  19. {
  20. return a5ds_power_domain_tree_desc;
  21. }
  22. /*******************************************************************************
  23. * Get core position using mpidr
  24. ******************************************************************************/
  25. int plat_core_pos_by_mpidr(u_register_t mpidr)
  26. {
  27. unsigned int cluster_id, cpu_id;
  28. mpidr &= MPIDR_AFFINITY_MASK;
  29. if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
  30. return -1;
  31. cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
  32. cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
  33. if (cluster_id >= A5DS_CLUSTER_COUNT)
  34. return -1;
  35. /*
  36. * Validate cpu_id by checking whether it represents a CPU in
  37. * one of the two clusters present on the platform.
  38. */
  39. if (cpu_id >= A5DS_MAX_CPUS_PER_CLUSTER)
  40. return -1;
  41. return (cpu_id + (cluster_id * 4));
  42. }