smp_plat.h 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Definitions specific to SMP platforms.
  4. *
  5. * Copyright (C) 2013 ARM Ltd.
  6. */
  7. #ifndef __ASM_SMP_PLAT_H
  8. #define __ASM_SMP_PLAT_H
  9. #include <linux/cpumask.h>
  10. #include <asm/smp.h>
  11. #include <asm/types.h>
  12. struct mpidr_hash {
  13. u64 mask;
  14. u32 shift_aff[4];
  15. u32 bits;
  16. };
  17. extern struct mpidr_hash mpidr_hash;
  18. static inline u32 mpidr_hash_size(void)
  19. {
  20. return 1 << mpidr_hash.bits;
  21. }
  22. /*
  23. * Retrieve logical cpu index corresponding to a given MPIDR.Aff*
  24. * - mpidr: MPIDR.Aff* bits to be used for the look-up
  25. *
  26. * Returns the cpu logical index or -EINVAL on look-up error
  27. */
  28. static inline int get_logical_index(u64 mpidr)
  29. {
  30. int cpu;
  31. for (cpu = 0; cpu < nr_cpu_ids; cpu++)
  32. if (cpu_logical_map(cpu) == mpidr)
  33. return cpu;
  34. return -EINVAL;
  35. }
  36. #endif /* __ASM_SMP_PLAT_H */