blob: aaa61b6f50fff28e77ded32b66698feb0b72db6e [file] [log] [blame]
Russell Kinge616c592009-09-27 20:55:43 +01001/*
2 * ARM specific SMP header, this contains our implementation
3 * details.
4 */
5#ifndef __ASMARM_SMP_PLAT_H
6#define __ASMARM_SMP_PLAT_H
7
Lorenzo Pieralisi7f124aa2011-11-17 17:36:24 +00008#include <linux/cpumask.h>
9#include <linux/err.h>
10
Russell Kinge616c592009-09-27 20:55:43 +010011#include <asm/cputype.h>
12
Russell Kingf00ec482010-09-04 10:47:48 +010013/*
14 * Return true if we are running on a SMP platform
15 */
16static inline bool is_smp(void)
17{
18#ifndef CONFIG_SMP
19 return false;
20#elif defined(CONFIG_SMP_ON_UP)
21 extern unsigned int smp_on_up;
22 return !!smp_on_up;
23#else
24 return true;
25#endif
26}
27
Russell Kinge616c592009-09-27 20:55:43 +010028/* all SMP configurations have the extended CPUID registers */
29static inline int tlb_ops_need_broadcast(void)
30{
Tony Lindgren7511db92010-10-05 16:40:13 +010031 if (!is_smp())
32 return 0;
33
Russell Kinge616c592009-09-27 20:55:43 +010034 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
35}
36
Catalin Marinas85848dd2010-09-13 15:58:37 +010037#if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
38#define cache_ops_need_broadcast() 0
39#else
Russell King2ef7f3d2009-11-05 13:29:36 +000040static inline int cache_ops_need_broadcast(void)
41{
Tony Lindgren7511db92010-10-05 16:40:13 +010042 if (!is_smp())
43 return 0;
44
Russell King2ef7f3d2009-11-05 13:29:36 +000045 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
46}
Catalin Marinas85848dd2010-09-13 15:58:37 +010047#endif
Russell King2ef7f3d2009-11-05 13:29:36 +000048
Will Deaconeb504392012-01-20 12:01:12 +010049/*
50 * Logical CPU mapping.
51 */
52extern int __cpu_logical_map[];
53#define cpu_logical_map(cpu) __cpu_logical_map[cpu]
Lorenzo Pieralisi7f124aa2011-11-17 17:36:24 +000054/*
55 * Retrieve logical cpu index corresponding to a given MPIDR[23:0]
56 * - mpidr: MPIDR[23:0] to be used for the look-up
57 *
58 * Returns the cpu logical index or -EINVAL on look-up error
59 */
60static inline int get_logical_index(u32 mpidr)
61{
62 int cpu;
63 for (cpu = 0; cpu < nr_cpu_ids; cpu++)
64 if (cpu_logical_map(cpu) == mpidr)
65 return cpu;
66 return -EINVAL;
67}
Will Deaconeb504392012-01-20 12:01:12 +010068
Russell Kinge616c592009-09-27 20:55:43 +010069#endif