blob: 6462a721ebd4cc52105fec3e8f6970614ca1d82e [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 */
Will Deacon5c709e62012-02-28 12:56:06 +000029#ifndef CONFIG_MMU
30#define tlb_ops_need_broadcast() 0
31#else
Russell Kinge616c592009-09-27 20:55:43 +010032static inline int tlb_ops_need_broadcast(void)
33{
Tony Lindgren7511db92010-10-05 16:40:13 +010034 if (!is_smp())
35 return 0;
36
Russell Kinge616c592009-09-27 20:55:43 +010037 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
38}
Will Deacon5c709e62012-02-28 12:56:06 +000039#endif
Russell Kinge616c592009-09-27 20:55:43 +010040
Catalin Marinas85848dd2010-09-13 15:58:37 +010041#if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
42#define cache_ops_need_broadcast() 0
43#else
Russell King2ef7f3d2009-11-05 13:29:36 +000044static inline int cache_ops_need_broadcast(void)
45{
Tony Lindgren7511db92010-10-05 16:40:13 +010046 if (!is_smp())
47 return 0;
48
Russell King2ef7f3d2009-11-05 13:29:36 +000049 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
50}
Catalin Marinas85848dd2010-09-13 15:58:37 +010051#endif
Russell King2ef7f3d2009-11-05 13:29:36 +000052
Will Deaconeb504392012-01-20 12:01:12 +010053/*
54 * Logical CPU mapping.
55 */
Lorenzo Pieralisi18d7f152013-06-19 10:40:48 +010056extern u32 __cpu_logical_map[];
Will Deaconeb504392012-01-20 12:01:12 +010057#define cpu_logical_map(cpu) __cpu_logical_map[cpu]
Lorenzo Pieralisi7f124aa2011-11-17 17:36:24 +000058/*
59 * Retrieve logical cpu index corresponding to a given MPIDR[23:0]
60 * - mpidr: MPIDR[23:0] to be used for the look-up
61 *
62 * Returns the cpu logical index or -EINVAL on look-up error
63 */
64static inline int get_logical_index(u32 mpidr)
65{
66 int cpu;
67 for (cpu = 0; cpu < nr_cpu_ids; cpu++)
68 if (cpu_logical_map(cpu) == mpidr)
69 return cpu;
70 return -EINVAL;
71}
Will Deaconeb504392012-01-20 12:01:12 +010072
Lorenzo Pieralisi76045372013-05-16 10:34:30 +010073/*
74 * NOTE ! Assembly code relies on the following
75 * structure memory layout in order to carry out load
76 * multiple from its base address. For more
77 * information check arch/arm/kernel/sleep.S
78 */
Lorenzo Pieralisi8cf72172013-05-16 10:32:09 +010079struct mpidr_hash {
Lorenzo Pieralisi76045372013-05-16 10:34:30 +010080 u32 mask; /* used by sleep.S */
81 u32 shift_aff[3]; /* used by sleep.S */
Lorenzo Pieralisi8cf72172013-05-16 10:32:09 +010082 u32 bits;
83};
84
85extern struct mpidr_hash mpidr_hash;
86
87static inline u32 mpidr_hash_size(void)
88{
89 return 1 << mpidr_hash.bits;
90}
Russell Kinge616c592009-09-27 20:55:43 +010091#endif