aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@imgtec.com>2015-07-09 05:40:42 -0400
committerRalf Baechle <ralf@linux-mips.org>2015-08-26 09:23:11 -0400
commit7d53e9c4cd21cbc82b7422c90852e56baaf7ddae (patch)
tree8a2f1ea52ccb9057dbe7ccd83a46dfaae92efd72
parent0ba3c125aa0ff9f993c0f9629945a0dd18d42568 (diff)
MIPS: CM3: Add support for CM3 L2 cache.
Detect the L2 cache configuration from GCR_L2_CONFIG when a CM3 is present in the system, rather than from Config2 which does not expose the L2 configuration on I6400. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/10641/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/mm/sc-mips.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index 4ceafd13870c..5fa452e8cff9 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -14,6 +14,7 @@
14#include <asm/pgtable.h> 14#include <asm/pgtable.h>
15#include <asm/mmu_context.h> 15#include <asm/mmu_context.h>
16#include <asm/r4kcache.h> 16#include <asm/r4kcache.h>
17#include <asm/mips-cm.h>
17 18
18/* 19/*
19 * MIPS32/MIPS64 L2 cache handling 20 * MIPS32/MIPS64 L2 cache handling
@@ -94,6 +95,34 @@ static inline int mips_sc_is_activated(struct cpuinfo_mips *c)
94 return 1; 95 return 1;
95} 96}
96 97
98static int __init mips_sc_probe_cm3(void)
99{
100 struct cpuinfo_mips *c = &current_cpu_data;
101 unsigned long cfg = read_gcr_l2_config();
102 unsigned long sets, line_sz, assoc;
103
104 if (cfg & CM_GCR_L2_CONFIG_BYPASS_MSK)
105 return 0;
106
107 sets = cfg & CM_GCR_L2_CONFIG_SET_SIZE_MSK;
108 sets >>= CM_GCR_L2_CONFIG_SET_SIZE_SHF;
109 c->scache.sets = 64 << sets;
110
111 line_sz = cfg & CM_GCR_L2_CONFIG_LINE_SIZE_MSK;
112 line_sz >>= CM_GCR_L2_CONFIG_LINE_SIZE_SHF;
113 c->scache.linesz = 2 << line_sz;
114
115 assoc = cfg & CM_GCR_L2_CONFIG_ASSOC_MSK;
116 assoc >>= CM_GCR_L2_CONFIG_ASSOC_SHF;
117 c->scache.ways = assoc + 1;
118 c->scache.waysize = c->scache.sets * c->scache.linesz;
119 c->scache.waybit = __ffs(c->scache.waysize);
120
121 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
122
123 return 1;
124}
125
97static inline int __init mips_sc_probe(void) 126static inline int __init mips_sc_probe(void)
98{ 127{
99 struct cpuinfo_mips *c = &current_cpu_data; 128 struct cpuinfo_mips *c = &current_cpu_data;
@@ -103,6 +132,9 @@ static inline int __init mips_sc_probe(void)
103 /* Mark as not present until probe completed */ 132 /* Mark as not present until probe completed */
104 c->scache.flags |= MIPS_CACHE_NOT_PRESENT; 133 c->scache.flags |= MIPS_CACHE_NOT_PRESENT;
105 134
135 if (mips_cm_revision() >= CM_REV_CM3)
136 return mips_sc_probe_cm3();
137
106 /* Ignore anything but MIPSxx processors */ 138 /* Ignore anything but MIPSxx processors */
107 if (!(c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 | 139 if (!(c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
108 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R1 | 140 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R1 |