xref: /linux/arch/arm64/include/asm/smp_plat.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
24c7aa002SJavi Merino /*
34c7aa002SJavi Merino  * Definitions specific to SMP platforms.
44c7aa002SJavi Merino  *
54c7aa002SJavi Merino  * Copyright (C) 2013 ARM Ltd.
64c7aa002SJavi Merino  */
74c7aa002SJavi Merino 
84c7aa002SJavi Merino #ifndef __ASM_SMP_PLAT_H
94c7aa002SJavi Merino #define __ASM_SMP_PLAT_H
104c7aa002SJavi Merino 
116ee3c78cSMark Rutland #include <linux/cpumask.h>
126ee3c78cSMark Rutland 
13*e62e0748SCarlos Bilbao #include <asm/smp.h>
144c7aa002SJavi Merino #include <asm/types.h>
154c7aa002SJavi Merino 
16976d7d3fSLorenzo Pieralisi struct mpidr_hash {
17976d7d3fSLorenzo Pieralisi 	u64	mask;
18976d7d3fSLorenzo Pieralisi 	u32	shift_aff[4];
19976d7d3fSLorenzo Pieralisi 	u32	bits;
20976d7d3fSLorenzo Pieralisi };
21976d7d3fSLorenzo Pieralisi 
22976d7d3fSLorenzo Pieralisi extern struct mpidr_hash mpidr_hash;
23976d7d3fSLorenzo Pieralisi 
mpidr_hash_size(void)24976d7d3fSLorenzo Pieralisi static inline u32 mpidr_hash_size(void)
25976d7d3fSLorenzo Pieralisi {
26976d7d3fSLorenzo Pieralisi 	return 1 << mpidr_hash.bits;
27976d7d3fSLorenzo Pieralisi }
28976d7d3fSLorenzo Pieralisi 
294c7aa002SJavi Merino /*
306ee3c78cSMark Rutland  * Retrieve logical cpu index corresponding to a given MPIDR.Aff*
316ee3c78cSMark Rutland  *  - mpidr: MPIDR.Aff* bits to be used for the look-up
326ee3c78cSMark Rutland  *
336ee3c78cSMark Rutland  * Returns the cpu logical index or -EINVAL on look-up error
346ee3c78cSMark Rutland  */
get_logical_index(u64 mpidr)356ee3c78cSMark Rutland static inline int get_logical_index(u64 mpidr)
366ee3c78cSMark Rutland {
376ee3c78cSMark Rutland 	int cpu;
386ee3c78cSMark Rutland 	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
396ee3c78cSMark Rutland 		if (cpu_logical_map(cpu) == mpidr)
406ee3c78cSMark Rutland 			return cpu;
416ee3c78cSMark Rutland 	return -EINVAL;
426ee3c78cSMark Rutland }
434c7aa002SJavi Merino 
444c7aa002SJavi Merino #endif /* __ASM_SMP_PLAT_H */
45