mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-02-28 10:11:48 +00:00
platform: generic: mips p8700: cache geometry detection
P8700 has a read-only cache configuration registers. Provide a CPU specific function to extract cache information. Use this information in the eyeq7h board for informational message Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260223-for-upstream-eyeq7h-v3-14-621d004d1a21@mobileye.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
committed by
Anup Patel
parent
8935f79c95
commit
df7bbe7c2e
@@ -171,6 +171,32 @@ static struct fdt_general_fixup eyeq7h_acc_clusters_fixup = {
|
||||
.do_fixup = eyeq7h_acc_clusters_do_fixup,
|
||||
};
|
||||
|
||||
static void eyeq7h_cache_do_fixup(struct fdt_general_fixup *f, void *fdt)
|
||||
{
|
||||
struct p8700_cache_info l1d, l1i, l2;
|
||||
mips_p8700_cache_info(&l1d, &l1i, &l2);
|
||||
|
||||
sbi_dprintf("Cache geometry:\n"
|
||||
" D: %4d Kbytes line %3d bytes %2d ways %5d sets\n"
|
||||
" I: %4d Kbytes line %3d bytes %2d ways %5d sets\n",
|
||||
l1d.assoc_ways * l1d.line * l1d.sets / 1024,
|
||||
l1d.line, l1d.assoc_ways, l1d.sets,
|
||||
l1i.assoc_ways * l1i.line * l1i.sets / 1024,
|
||||
l1i.line, l1i.assoc_ways, l1i.sets);
|
||||
if (l2.line) {
|
||||
sbi_dprintf(" L2: %4d Kbytes line %3d bytes %2d ways %5d sets\n",
|
||||
l2.assoc_ways * l2.line * l2.sets / 1024,
|
||||
l2.line, l2.assoc_ways, l2.sets);
|
||||
} else {
|
||||
sbi_dprintf(" L2: not present\n");
|
||||
}
|
||||
}
|
||||
|
||||
static struct fdt_general_fixup eyeq7h_cache_fixup = {
|
||||
.name = "cache-fixup",
|
||||
.do_fixup = eyeq7h_cache_do_fixup,
|
||||
};
|
||||
|
||||
static int eyeq7h_final_init(bool cold_boot)
|
||||
{
|
||||
if (!cold_boot)
|
||||
@@ -178,6 +204,7 @@ static int eyeq7h_final_init(bool cold_boot)
|
||||
|
||||
sbi_hsm_set_device(&eyeq7h_hsm);
|
||||
fdt_register_general_fixup(&eyeq7h_acc_clusters_fixup);
|
||||
fdt_register_general_fixup(&eyeq7h_cache_fixup);
|
||||
|
||||
return generic_final_init(cold_boot);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,51 @@ int mips_p8700_hart_stop()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mips_p8700_cache_info(struct p8700_cache_info *l1d, struct p8700_cache_info *l1i,
|
||||
struct p8700_cache_info *l2)
|
||||
{
|
||||
u32 mipsconfig1 = csr_read(CSR_MIPSCONFIG1);
|
||||
|
||||
if (l1d) {
|
||||
u32 da = EXTRACT_FIELD(mipsconfig1, MIPSCONFIG1_DA);
|
||||
u32 dl = EXTRACT_FIELD(mipsconfig1, MIPSCONFIG1_DL);
|
||||
u32 ds = EXTRACT_FIELD(mipsconfig1, MIPSCONFIG1_DS);
|
||||
|
||||
l1d->line = dl ? 1 << (dl + 1) : 0;
|
||||
l1d->assoc_ways = da +1;
|
||||
l1d->sets = ds == 7 ? 32 : 1 << (ds + 6);
|
||||
}
|
||||
if (l1i) {
|
||||
u32 ia = EXTRACT_FIELD(mipsconfig1, MIPSCONFIG1_IA);
|
||||
u32 il = EXTRACT_FIELD(mipsconfig1, MIPSCONFIG1_IL);
|
||||
u32 is = EXTRACT_FIELD(mipsconfig1, MIPSCONFIG1_IS);
|
||||
|
||||
l1i->line = il ? 1 << (il + 1) : 0;
|
||||
l1i->assoc_ways = ia +1;
|
||||
l1i->sets = is == 7 ? 32 : 1 << (is + 6);
|
||||
}
|
||||
if (l2) {
|
||||
if (mipsconfig1 & MIPSCONFIG1_L2C) {
|
||||
void *cm_base = (void *)p8700_cm_info->gcr_base[0];
|
||||
u32 l2_config = readl(cm_base + GCR_L2_CONFIG);
|
||||
|
||||
if (l2_config & GCR_L2_REG_EXISTS) {
|
||||
u32 l2a = EXTRACT_FIELD(l2_config, GCR_L2_ASSOC);
|
||||
u32 l2l = EXTRACT_FIELD(l2_config, GCR_L2_LINE_SIZE);
|
||||
u32 l2s = EXTRACT_FIELD(l2_config, GCR_L2_SET_SIZE);
|
||||
|
||||
l2->assoc_ways = l2a + 1;
|
||||
l2->line = 1 << (l2l + 1);
|
||||
l2->sets = 1 << (l2s + 6);
|
||||
return;
|
||||
}
|
||||
}
|
||||
l2->line = 0;
|
||||
l2->assoc_ways = 0;
|
||||
l2->sets = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int mips_p8700_platform_init(const void *fdt, int nodeoff, const struct fdt_match *match)
|
||||
{
|
||||
const struct p8700_cm_info *data = match->data;
|
||||
|
||||
Reference in New Issue
Block a user