smp_plat.h 1.36 KB
Newer Older
1 2 3 4 5 6 7
/*
 * ARM specific SMP header, this contains our implementation
 * details.
 */
#ifndef __ASMARM_SMP_PLAT_H
#define __ASMARM_SMP_PLAT_H

8 9 10
#include <linux/cpumask.h>
#include <linux/err.h>

11 12
#include <asm/cputype.h>

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * Return true if we are running on a SMP platform
 */
static inline bool is_smp(void)
{
#ifndef CONFIG_SMP
	return false;
#elif defined(CONFIG_SMP_ON_UP)
	extern unsigned int smp_on_up;
	return !!smp_on_up;
#else
	return true;
#endif
}

28 29 30
/* all SMP configurations have the extended CPUID registers */
static inline int tlb_ops_need_broadcast(void)
{
31 32 33
	if (!is_smp())
		return 0;

34 35 36
	return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
}

37 38 39
#if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
#define cache_ops_need_broadcast()	0
#else
Russell King's avatar
Russell King committed
40 41
static inline int cache_ops_need_broadcast(void)
{
42 43 44
	if (!is_smp())
		return 0;

Russell King's avatar
Russell King committed
45 46
	return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
}
47
#endif
Russell King's avatar
Russell King committed
48

49 50 51
/*
 * Logical CPU mapping.
 */
52
extern u32 __cpu_logical_map[];
53
#define cpu_logical_map(cpu)	__cpu_logical_map[cpu]
54 55 56 57 58 59 60 61 62 63 64 65 66 67
/*
 * Retrieve logical cpu index corresponding to a given MPIDR[23:0]
 *  - mpidr: MPIDR[23:0] to be used for the look-up
 *
 * Returns the cpu logical index or -EINVAL on look-up error
 */
static inline int get_logical_index(u32 mpidr)
{
	int cpu;
	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
		if (cpu_logical_map(cpu) == mpidr)
			return cpu;
	return -EINVAL;
}
68

69
#endif