Skip to content

Commit 7d53e9c

Browse files
paulburtonralfbaechle
authored andcommitted
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>
1 parent 0ba3c12 commit 7d53e9c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

arch/mips/mm/sc-mips.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/pgtable.h>
1515
#include <asm/mmu_context.h>
1616
#include <asm/r4kcache.h>
17+
#include <asm/mips-cm.h>
1718

1819
/*
1920
* MIPS32/MIPS64 L2 cache handling
@@ -94,6 +95,34 @@ static inline int mips_sc_is_activated(struct cpuinfo_mips *c)
9495
return 1;
9596
}
9697

98+
static 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+
97126
static inline int __init mips_sc_probe(void)
98127
{
99128
struct cpuinfo_mips *c = &current_cpu_data;
@@ -103,6 +132,9 @@ static inline int __init mips_sc_probe(void)
103132
/* Mark as not present until probe completed */
104133
c->scache.flags |= MIPS_CACHE_NOT_PRESENT;
105134

135+
if (mips_cm_revision() >= CM_REV_CM3)
136+
return mips_sc_probe_cm3();
137+
106138
/* Ignore anything but MIPSxx processors */
107139
if (!(c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
108140
MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R1 |

0 commit comments

Comments
 (0)