| 
									
										
										
										
											2009-09-27 20:55:43 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * ARM specific SMP header, this contains our implementation | 
					
						
							|  |  |  |  * details. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #ifndef __ASMARM_SMP_PLAT_H
 | 
					
						
							|  |  |  | #define __ASMARM_SMP_PLAT_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-17 17:36:24 +00:00
										 |  |  | #include <linux/cpumask.h>
 | 
					
						
							|  |  |  | #include <linux/err.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-27 20:55:43 +01:00
										 |  |  | #include <asm/cputype.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-04 10:47:48 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * 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
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-27 20:55:43 +01:00
										 |  |  | /* all SMP configurations have the extended CPUID registers */ | 
					
						
							|  |  |  | static inline int tlb_ops_need_broadcast(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-05 16:40:13 +01:00
										 |  |  | 	if (!is_smp()) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-27 20:55:43 +01:00
										 |  |  | 	return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-13 15:58:37 +01:00
										 |  |  | #if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
 | 
					
						
							|  |  |  | #define cache_ops_need_broadcast()	0
 | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-11-05 13:29:36 +00:00
										 |  |  | static inline int cache_ops_need_broadcast(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-05 16:40:13 +01:00
										 |  |  | 	if (!is_smp()) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-05 13:29:36 +00:00
										 |  |  | 	return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-09-13 15:58:37 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-11-05 13:29:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-20 12:01:12 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Logical CPU mapping. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | extern int __cpu_logical_map[]; | 
					
						
							|  |  |  | #define cpu_logical_map(cpu)	__cpu_logical_map[cpu]
 | 
					
						
							| 
									
										
										
										
											2011-11-17 17:36:24 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * 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; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2012-01-20 12:01:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-27 20:55:43 +01:00
										 |  |  | #endif
 |