aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@imgtec.com>2015-09-22 14:29:09 -0400
committerRalf Baechle <ralf@linux-mips.org>2015-09-27 08:11:17 -0400
commit7573b94e08aeb5b814e2f277210bdcdf21a83869 (patch)
tree6e62d9f7039636db8000afc71f322c09eb205a3d /arch/mips/include/asm
parent43d104db596977a8fddc1e71245859a7fe85a658 (diff)
MIPS: CM: Provide a function to map from CPU to VP ID.
The VP ID of a given CPU may not match up with the CPU number used by Linux. For example, if the width of the VP part of the VP ID is wider than log2(number of VPs per core) and the system has multiple cores then this will be the case. Alternatively, if a pre-r6 system implements the MT ASE with multiple VPEs per core and Linux is built without support for the MT ASE then the numbers won't match up either. Provide a function to convert from CPU number to VP ID. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Cc: James Hogan <james.hogan@imgtec.com> Cc: Markos Chandras <markos.chandras@imgtec.com> Patchwork: https://patchwork.linux-mips.org/patch/11211/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include/asm')
-rw-r--r--arch/mips/include/asm/mips-cm.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
index d75b75e78ebb..1f1927ab4269 100644
--- a/arch/mips/include/asm/mips-cm.h
+++ b/arch/mips/include/asm/mips-cm.h
@@ -194,6 +194,7 @@ BUILD_CM_RW(reg3_mask, MIPS_CM_GCB_OFS + 0xc8)
194BUILD_CM_R_(gic_status, MIPS_CM_GCB_OFS + 0xd0) 194BUILD_CM_R_(gic_status, MIPS_CM_GCB_OFS + 0xd0)
195BUILD_CM_R_(cpc_status, MIPS_CM_GCB_OFS + 0xf0) 195BUILD_CM_R_(cpc_status, MIPS_CM_GCB_OFS + 0xf0)
196BUILD_CM_RW(l2_config, MIPS_CM_GCB_OFS + 0x130) 196BUILD_CM_RW(l2_config, MIPS_CM_GCB_OFS + 0x130)
197BUILD_CM_RW(sys_config2, MIPS_CM_GCB_OFS + 0x150)
197 198
198/* Core Local & Core Other register accessor functions */ 199/* Core Local & Core Other register accessor functions */
199BUILD_CM_Cx_RW(reset_release, 0x00) 200BUILD_CM_Cx_RW(reset_release, 0x00)
@@ -316,6 +317,10 @@ BUILD_CM_Cx_R_(tcid_8_priority, 0x80)
316#define CM_GCR_L2_CONFIG_ASSOC_SHF 0 317#define CM_GCR_L2_CONFIG_ASSOC_SHF 0
317#define CM_GCR_L2_CONFIG_ASSOC_MSK (_ULCAST_(0xff) << 0) 318#define CM_GCR_L2_CONFIG_ASSOC_MSK (_ULCAST_(0xff) << 0)
318 319
320/* GCR_SYS_CONFIG2 register fields */
321#define CM_GCR_SYS_CONFIG2_MAXVPW_SHF 0
322#define CM_GCR_SYS_CONFIG2_MAXVPW_MSK (_ULCAST_(0xf) << 0)
323
319/* GCR_Cx_COHERENCE register fields */ 324/* GCR_Cx_COHERENCE register fields */
320#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_SHF 0 325#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_SHF 0
321#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_MSK (_ULCAST_(0xff) << 0) 326#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_MSK (_ULCAST_(0xff) << 0)
@@ -405,4 +410,38 @@ static inline int mips_cm_revision(void)
405 return read_gcr_rev(); 410 return read_gcr_rev();
406} 411}
407 412
413/**
414 * mips_cm_max_vp_width() - return the width in bits of VP indices
415 *
416 * Return: the width, in bits, of VP indices in fields that combine core & VP
417 * indices.
418 */
419static inline unsigned int mips_cm_max_vp_width(void)
420{
421 extern int smp_num_siblings;
422
423 if (mips_cm_revision() >= CM_REV_CM3)
424 return read_gcr_sys_config2() & CM_GCR_SYS_CONFIG2_MAXVPW_MSK;
425
426 return smp_num_siblings;
427}
428
429/**
430 * mips_cm_vp_id() - calculate the hardware VP ID for a CPU
431 * @cpu: the CPU whose VP ID to calculate
432 *
433 * Hardware such as the GIC uses identifiers for VPs which may not match the
434 * CPU numbers used by Linux. This function calculates the hardware VP
435 * identifier corresponding to a given CPU.
436 *
437 * Return: the VP ID for the CPU.
438 */
439static inline unsigned int mips_cm_vp_id(unsigned int cpu)
440{
441 unsigned int core = cpu_data[cpu].core;
442 unsigned int vp = cpu_vpe_id(&cpu_data[cpu]);
443
444 return (core * mips_cm_max_vp_width()) + vp;
445}
446
408#endif /* __MIPS_ASM_MIPS_CM_H__ */ 447#endif /* __MIPS_ASM_MIPS_CM_H__ */