0001
0002
0003
0004
0005
0006 #ifndef __ASMARM_SMP_PLAT_H
0007 #define __ASMARM_SMP_PLAT_H
0008
0009 #include <linux/cpumask.h>
0010 #include <linux/err.h>
0011
0012 #include <asm/cpu.h>
0013 #include <asm/cputype.h>
0014
0015
0016
0017
0018 static inline bool is_smp(void)
0019 {
0020 #ifndef CONFIG_SMP
0021 return false;
0022 #elif defined(CONFIG_SMP_ON_UP)
0023 extern unsigned int smp_on_up;
0024 return !!smp_on_up;
0025 #else
0026 return true;
0027 #endif
0028 }
0029
0030
0031
0032
0033
0034
0035
0036 static inline unsigned int smp_cpuid_part(int cpu)
0037 {
0038 struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpu);
0039
0040 return is_smp() ? cpu_info->cpuid & ARM_CPU_PART_MASK :
0041 read_cpuid_part();
0042 }
0043
0044
0045 #ifndef CONFIG_MMU
0046 #define tlb_ops_need_broadcast() 0
0047 #else
0048 static inline int tlb_ops_need_broadcast(void)
0049 {
0050 if (!is_smp())
0051 return 0;
0052
0053 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
0054 }
0055 #endif
0056
0057 #if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
0058 #define cache_ops_need_broadcast() 0
0059 #else
0060 static inline int cache_ops_need_broadcast(void)
0061 {
0062 if (!is_smp())
0063 return 0;
0064
0065 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
0066 }
0067 #endif
0068
0069
0070
0071
0072 extern u32 __cpu_logical_map[];
0073 #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
0074
0075
0076
0077
0078
0079
0080 static inline int get_logical_index(u32 mpidr)
0081 {
0082 int cpu;
0083 for (cpu = 0; cpu < nr_cpu_ids; cpu++)
0084 if (cpu_logical_map(cpu) == mpidr)
0085 return cpu;
0086 return -EINVAL;
0087 }
0088
0089
0090
0091
0092
0093
0094
0095 struct mpidr_hash {
0096 u32 mask;
0097 u32 shift_aff[3];
0098 u32 bits;
0099 };
0100
0101 extern struct mpidr_hash mpidr_hash;
0102
0103 static inline u32 mpidr_hash_size(void)
0104 {
0105 return 1 << mpidr_hash.bits;
0106 }
0107
0108 extern int platform_can_secondary_boot(void);
0109 extern int platform_can_cpu_hotplug(void);
0110
0111 #ifdef CONFIG_HOTPLUG_CPU
0112 extern int platform_can_hotplug_cpu(unsigned int cpu);
0113 #else
0114 static inline int platform_can_hotplug_cpu(unsigned int cpu)
0115 {
0116 return 0;
0117 }
0118 #endif
0119
0120 #endif