xref: /rk3399_ARM-atf/include/drivers/marvell/cache_llc.h (revision e180cdbac177ae14794edd1fe352b379e0a97336)
1152b0e47SKonstantin Porotchkin /*
2*c959ea78SManish V Badarkhe  * Copyright (C) 2018-2020 Marvell International Ltd.
3152b0e47SKonstantin Porotchkin  *
4152b0e47SKonstantin Porotchkin  * SPDX-License-Identifier:     BSD-3-Clause
5152b0e47SKonstantin Porotchkin  * https://spdx.org/licenses
6152b0e47SKonstantin Porotchkin  */
7152b0e47SKonstantin Porotchkin 
8152b0e47SKonstantin Porotchkin /* LLC driver is the Last Level Cache (L3C) driver
9152b0e47SKonstantin Porotchkin  * for Marvell SoCs in AP806, AP807, and AP810
10152b0e47SKonstantin Porotchkin  */
11152b0e47SKonstantin Porotchkin 
12c3cf06f1SAntonio Nino Diaz #ifndef CACHE_LLC_H
13c3cf06f1SAntonio Nino Diaz #define CACHE_LLC_H
14152b0e47SKonstantin Porotchkin 
15152b0e47SKonstantin Porotchkin #define LLC_CTRL(ap)			(MVEBU_LLC_BASE(ap) + 0x100)
165a40d70fSKonstantin Porotchkin #define LLC_SECURE_CTRL(ap)		(MVEBU_LLC_BASE(ap) + 0x10C)
17152b0e47SKonstantin Porotchkin #define LLC_SYNC(ap)			(MVEBU_LLC_BASE(ap) + 0x700)
18772aa5baSKonstantin Porotchkin #define LLC_BANKED_MNT_AHR(ap)		(MVEBU_LLC_BASE(ap) + 0x724)
19772aa5baSKonstantin Porotchkin #define LLC_INV_WAY(ap)			(MVEBU_LLC_BASE(ap) + 0x77C)
20772aa5baSKonstantin Porotchkin #define LLC_BLK_ALOC(ap)		(MVEBU_LLC_BASE(ap) + 0x78c)
21772aa5baSKonstantin Porotchkin #define LLC_CLEAN_WAY(ap)		(MVEBU_LLC_BASE(ap) + 0x7BC)
22772aa5baSKonstantin Porotchkin #define LLC_CLEAN_INV_WAY(ap)		(MVEBU_LLC_BASE(ap) + 0x7FC)
235a40d70fSKonstantin Porotchkin #define LLC_TCN_LOCK(ap, tc)		(MVEBU_LLC_BASE(ap) + 0x920 + 4 * (tc))
24152b0e47SKonstantin Porotchkin 
25152b0e47SKonstantin Porotchkin #define MASTER_LLC_CTRL			LLC_CTRL(MVEBU_AP0)
26772aa5baSKonstantin Porotchkin #define MASTER_LLC_INV_WAY		LLC_INV_WAY(MVEBU_AP0)
275a40d70fSKonstantin Porotchkin #define MASTER_LLC_TC0_LOCK		LLC_TCN_LOCK(MVEBU_AP0, 0)
28152b0e47SKonstantin Porotchkin 
29152b0e47SKonstantin Porotchkin #define LLC_CTRL_EN			1
30152b0e47SKonstantin Porotchkin #define LLC_EXCLUSIVE_EN		0x100
31772aa5baSKonstantin Porotchkin #define LLC_ALL_WAYS_MASK		0xFFFFFFFF
32772aa5baSKonstantin Porotchkin 
33772aa5baSKonstantin Porotchkin /* AP806/AP807 - 1MB 8-ways LLC */
34772aa5baSKonstantin Porotchkin #define LLC_WAYS			8
35772aa5baSKonstantin Porotchkin #define LLC_WAY_MASK			((1 << LLC_WAYS) - 1)
36772aa5baSKonstantin Porotchkin #define LLC_SIZE			(1024 * 1024)
37772aa5baSKonstantin Porotchkin #define LLC_WAY_SIZE			(LLC_SIZE / LLC_WAYS)
385a40d70fSKonstantin Porotchkin #define LLC_TC_NUM			15
39772aa5baSKonstantin Porotchkin 
405a40d70fSKonstantin Porotchkin #define LLC_BLK_ALOC_WAY_ID(way)	((way) & 0x1f)
415a40d70fSKonstantin Porotchkin #define LLC_BLK_ALOC_WAY_DATA_DSBL	(0x0 << 6)
425a40d70fSKonstantin Porotchkin #define LLC_BLK_ALOC_WAY_DATA_CLR	(0x1 << 6)
435a40d70fSKonstantin Porotchkin #define LLC_BLK_ALOC_WAY_DATA_SET	(0x3 << 6)
44506ff4c0SKonstantin Porotchkin #define LLC_BLK_ALOC_BASE_ADDR(addr)	((addr) & ~(LLC_WAY_SIZE - 1))
45152b0e47SKonstantin Porotchkin 
46d5dfdeb6SJulius Werner #ifndef __ASSEMBLER__
47152b0e47SKonstantin Porotchkin void llc_cache_sync(int ap_index);
48152b0e47SKonstantin Porotchkin void llc_flush_all(int ap_index);
49152b0e47SKonstantin Porotchkin void llc_clean_all(int ap_index);
50152b0e47SKonstantin Porotchkin void llc_inv_all(int ap_index);
51152b0e47SKonstantin Porotchkin void llc_disable(int ap_index);
52152b0e47SKonstantin Porotchkin void llc_enable(int ap_index, int excl_mode);
53152b0e47SKonstantin Porotchkin int llc_is_exclusive(int ap_index);
54152b0e47SKonstantin Porotchkin void llc_runtime_enable(int ap_index);
555a40d70fSKonstantin Porotchkin #if LLC_SRAM
56506ff4c0SKonstantin Porotchkin int llc_sram_enable(int ap_index, int size);
575a40d70fSKonstantin Porotchkin void llc_sram_disable(int ap_index);
58506ff4c0SKonstantin Porotchkin int llc_sram_test(int ap_index, int size, char *msg);
595a40d70fSKonstantin Porotchkin #endif /* LLC_SRAM */
60*c959ea78SManish V Badarkhe #endif /* __ASSEMBLER__ */
61152b0e47SKonstantin Porotchkin 
62c3cf06f1SAntonio Nino Diaz #endif /* CACHE_LLC_H */
63