aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/mips-cm.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/include/asm/mips-cm.h')
-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__ */