smp_plat.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Definitions specific to SMP platforms.
  3. *
  4. * Copyright (C) 2013 ARM Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __ASM_SMP_PLAT_H
  19. #define __ASM_SMP_PLAT_H
  20. #include <linux/cpumask.h>
  21. #include <asm/types.h>
  22. struct mpidr_hash {
  23. u64 mask;
  24. u32 shift_aff[4];
  25. u32 bits;
  26. };
  27. extern struct mpidr_hash mpidr_hash;
  28. static inline u32 mpidr_hash_size(void)
  29. {
  30. return 1 << mpidr_hash.bits;
  31. }
  32. /*
  33. * Logical CPU mapping.
  34. */
  35. extern u64 __cpu_logical_map[NR_CPUS];
  36. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  37. /*
  38. * Retrieve logical cpu index corresponding to a given MPIDR.Aff*
  39. * - mpidr: MPIDR.Aff* bits to be used for the look-up
  40. *
  41. * Returns the cpu logical index or -EINVAL on look-up error
  42. */
  43. static inline int get_logical_index(u64 mpidr)
  44. {
  45. int cpu;
  46. for (cpu = 0; cpu < nr_cpu_ids; cpu++)
  47. if (cpu_logical_map(cpu) == mpidr)
  48. return cpu;
  49. return -EINVAL;
  50. }
  51. #endif /* __ASM_SMP_PLAT_H */