blob: cb5eed3cfa12934617db8a24fd618e7028cce75c (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*
* ***************************************************************************
* Copyright (C) 2015 Marvell International Ltd.
* ***************************************************************************
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 2 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ***************************************************************************
*/
#include <assert.h>
#include <mmio.h>
#include <plat_def.h>
#define LLC_CTRL 0x100
#define LLC_CACHE_SYNC 0x700
#define L2X0_INV_WAY 0x77C
#define L2X0_CLEAN_WAY 0x7BC
#define L2X0_CLEAN_INV_WAY 0x7FC
#define LLC_CTRL_EN 1
#define LLC_EXCLUSIVE_EN 0x100
#define LLC_WAY_MASK 0xFFFFFFFF
void llc_cache_sync(void)
{
mmio_write_32(MVEBU_LLC_BASE + LLC_CACHE_SYNC, 0);
/* Atumic write no need to wait */
}
void llc_flush_all(void)
{
mmio_write_32(MVEBU_LLC_BASE + L2X0_CLEAN_INV_WAY, LLC_WAY_MASK);
llc_cache_sync();
}
void llc_clean_all(void)
{
mmio_write_32(MVEBU_LLC_BASE + L2X0_CLEAN_WAY, LLC_WAY_MASK);
llc_cache_sync();
}
void llc_inv_all(void)
{
mmio_write_32(MVEBU_LLC_BASE + L2X0_INV_WAY, LLC_WAY_MASK);
llc_cache_sync();
}
void llc_disable(void)
{
llc_flush_all();
mmio_write_32(MVEBU_LLC_BASE + LLC_CTRL, 0);
__asm__ volatile("dsb st");
}
void llc_enable(int excl_mode)
{
uint32_t val;
__asm__ volatile("dsb sy");
llc_inv_all();
__asm__ volatile("dsb sy");
val = LLC_CTRL_EN;
if (excl_mode)
val |= LLC_EXCLUSIVE_EN;
mmio_write_32(MVEBU_LLC_BASE + LLC_CTRL, val);
__asm__ volatile("dsb sy");
}
int llc_is_exclusive(void)
{
uint32_t reg;
reg = mmio_read_32(MVEBU_LLC_BASE + LLC_CTRL);
if ((reg & (LLC_CTRL_EN | LLC_EXCLUSIVE_EN)) == (LLC_CTRL_EN | LLC_EXCLUSIVE_EN))
return 1;
return 0;
}
void llc_save(void)
{
/* TBD */
}
void llc_resume(void)
{
/* TBD */
}
|