1e616c591SRussell King /* 2e616c591SRussell King * ARM specific SMP header, this contains our implementation 3e616c591SRussell King * details. 4e616c591SRussell King */ 5e616c591SRussell King #ifndef __ASMARM_SMP_PLAT_H 6e616c591SRussell King #define __ASMARM_SMP_PLAT_H 7e616c591SRussell King 87f124aafSLorenzo Pieralisi #include <linux/cpumask.h> 97f124aafSLorenzo Pieralisi #include <linux/err.h> 107f124aafSLorenzo Pieralisi 11e616c591SRussell King #include <asm/cputype.h> 12e616c591SRussell King 13f00ec48fSRussell King /* 14f00ec48fSRussell King * Return true if we are running on a SMP platform 15f00ec48fSRussell King */ 16f00ec48fSRussell King static inline bool is_smp(void) 17f00ec48fSRussell King { 18f00ec48fSRussell King #ifndef CONFIG_SMP 19f00ec48fSRussell King return false; 20f00ec48fSRussell King #elif defined(CONFIG_SMP_ON_UP) 21f00ec48fSRussell King extern unsigned int smp_on_up; 22f00ec48fSRussell King return !!smp_on_up; 23f00ec48fSRussell King #else 24f00ec48fSRussell King return true; 25f00ec48fSRussell King #endif 26f00ec48fSRussell King } 27f00ec48fSRussell King 28e616c591SRussell King /* all SMP configurations have the extended CPUID registers */ 29e616c591SRussell King static inline int tlb_ops_need_broadcast(void) 30e616c591SRussell King { 317511db9dSTony Lindgren if (!is_smp()) 327511db9dSTony Lindgren return 0; 337511db9dSTony Lindgren 34e616c591SRussell King return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2; 35e616c591SRussell King } 36e616c591SRussell King 3785848dd7SCatalin Marinas #if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7 3885848dd7SCatalin Marinas #define cache_ops_need_broadcast() 0 3985848dd7SCatalin Marinas #else 402ef7f3dbSRussell King static inline int cache_ops_need_broadcast(void) 412ef7f3dbSRussell King { 427511db9dSTony Lindgren if (!is_smp()) 437511db9dSTony Lindgren return 0; 447511db9dSTony Lindgren 452ef7f3dbSRussell King return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1; 462ef7f3dbSRussell King } 4785848dd7SCatalin Marinas #endif 482ef7f3dbSRussell King 49eb50439bSWill Deacon /* 50eb50439bSWill Deacon * Logical CPU mapping. 51eb50439bSWill Deacon */ 52*18d7f152SLorenzo Pieralisi extern u32 __cpu_logical_map[]; 53eb50439bSWill Deacon #define cpu_logical_map(cpu) __cpu_logical_map[cpu] 547f124aafSLorenzo Pieralisi /* 557f124aafSLorenzo Pieralisi * Retrieve logical cpu index corresponding to a given MPIDR[23:0] 567f124aafSLorenzo Pieralisi * - mpidr: MPIDR[23:0] to be used for the look-up 577f124aafSLorenzo Pieralisi * 587f124aafSLorenzo Pieralisi * Returns the cpu logical index or -EINVAL on look-up error 597f124aafSLorenzo Pieralisi */ 607f124aafSLorenzo Pieralisi static inline int get_logical_index(u32 mpidr) 617f124aafSLorenzo Pieralisi { 627f124aafSLorenzo Pieralisi int cpu; 637f124aafSLorenzo Pieralisi for (cpu = 0; cpu < nr_cpu_ids; cpu++) 647f124aafSLorenzo Pieralisi if (cpu_logical_map(cpu) == mpidr) 657f124aafSLorenzo Pieralisi return cpu; 667f124aafSLorenzo Pieralisi return -EINVAL; 677f124aafSLorenzo Pieralisi } 68eb50439bSWill Deacon 69e616c591SRussell King #endif 70