summaryrefslogtreecommitdiff
path: root/arch/powerpc/cpu/mpc8xx/cache.c
blob: 41559009caca334e17d3a15a8847442742e1d9d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: GPL-2.0+
/*
 * (C) Copyright 2017
 * Christophe Leroy, CS Systemes d'Information, christophe.leroy@c-s.fr
 */

#include <common.h>
#include <cpu_func.h>
#include <asm/processor.h>
#include <asm/ppc.h>
#include <asm/io.h>
#include <asm/mmu.h>

int icache_status(void)
{
	return !!(mfspr(IC_CST) & IDC_ENABLED);
}

void icache_enable(void)
{
	sync();
	mtspr(IC_CST, IDC_INVALL);
	mtspr(IC_CST, IDC_ENABLE);
}

void icache_disable(void)
{
	sync();
	mtspr(IC_CST, IDC_DISABLE);
}

int dcache_status(void)
{
	return !!(mfspr(IC_CST) & IDC_ENABLED);
}

void dcache_enable(void)
{
	mtspr(MD_CTR, MD_RESETVAL);	/* Set cache mode with MMU off */
	mtspr(DC_CST, IDC_INVALL);
	mtspr(DC_CST, IDC_ENABLE);
}

void dcache_disable(void)
{
	sync();
	mtspr(DC_CST, IDC_DISABLE);
	mtspr(DC_CST, IDC_INVALL);
}