Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 Marvell International Ltd. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * https://spdx.org/licenses |
| 6 | */ |
| 7 | |
| 8 | /* LLC driver is the Last Level Cache (L3C) driver |
| 9 | * for Marvell SoCs in AP806, AP807, and AP810 |
| 10 | */ |
| 11 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 12 | #ifndef CACHE_LLC_H |
| 13 | #define CACHE_LLC_H |
Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 14 | |
| 15 | #define LLC_CTRL(ap) (MVEBU_LLC_BASE(ap) + 0x100) |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 16 | #define LLC_SECURE_CTRL(ap) (MVEBU_LLC_BASE(ap) + 0x10C) |
Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 17 | #define LLC_SYNC(ap) (MVEBU_LLC_BASE(ap) + 0x700) |
Konstantin Porotchkin | fa8c130 | 2019-03-25 15:35:41 +0200 | [diff] [blame] | 18 | #define LLC_BANKED_MNT_AHR(ap) (MVEBU_LLC_BASE(ap) + 0x724) |
| 19 | #define LLC_INV_WAY(ap) (MVEBU_LLC_BASE(ap) + 0x77C) |
| 20 | #define LLC_BLK_ALOC(ap) (MVEBU_LLC_BASE(ap) + 0x78c) |
| 21 | #define LLC_CLEAN_WAY(ap) (MVEBU_LLC_BASE(ap) + 0x7BC) |
| 22 | #define LLC_CLEAN_INV_WAY(ap) (MVEBU_LLC_BASE(ap) + 0x7FC) |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 23 | #define LLC_TCN_LOCK(ap, tc) (MVEBU_LLC_BASE(ap) + 0x920 + 4 * (tc)) |
Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 24 | |
| 25 | #define MASTER_LLC_CTRL LLC_CTRL(MVEBU_AP0) |
Konstantin Porotchkin | fa8c130 | 2019-03-25 15:35:41 +0200 | [diff] [blame] | 26 | #define MASTER_LLC_INV_WAY LLC_INV_WAY(MVEBU_AP0) |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 27 | #define MASTER_LLC_TC0_LOCK LLC_TCN_LOCK(MVEBU_AP0, 0) |
Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 28 | |
| 29 | #define LLC_CTRL_EN 1 |
| 30 | #define LLC_EXCLUSIVE_EN 0x100 |
Konstantin Porotchkin | fa8c130 | 2019-03-25 15:35:41 +0200 | [diff] [blame] | 31 | #define LLC_ALL_WAYS_MASK 0xFFFFFFFF |
| 32 | |
| 33 | /* AP806/AP807 - 1MB 8-ways LLC */ |
| 34 | #define LLC_WAYS 8 |
| 35 | #define LLC_WAY_MASK ((1 << LLC_WAYS) - 1) |
| 36 | #define LLC_SIZE (1024 * 1024) |
| 37 | #define LLC_WAY_SIZE (LLC_SIZE / LLC_WAYS) |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 38 | #define LLC_TC_NUM 15 |
Konstantin Porotchkin | fa8c130 | 2019-03-25 15:35:41 +0200 | [diff] [blame] | 39 | |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 40 | #define LLC_BLK_ALOC_WAY_ID(way) ((way) & 0x1f) |
| 41 | #define LLC_BLK_ALOC_WAY_DATA_DSBL (0x0 << 6) |
| 42 | #define LLC_BLK_ALOC_WAY_DATA_CLR (0x1 << 6) |
| 43 | #define LLC_BLK_ALOC_WAY_DATA_SET (0x3 << 6) |
Konstantin Porotchkin | 1e1ab1d | 2019-04-04 10:02:20 +0300 | [diff] [blame] | 44 | #define LLC_BLK_ALOC_BASE_ADDR(addr) ((addr) & ~(LLC_WAY_SIZE - 1)) |
Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 45 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 46 | #ifndef __ASSEMBLER__ |
Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 47 | void llc_cache_sync(int ap_index); |
| 48 | void llc_flush_all(int ap_index); |
| 49 | void llc_clean_all(int ap_index); |
| 50 | void llc_inv_all(int ap_index); |
| 51 | void llc_disable(int ap_index); |
| 52 | void llc_enable(int ap_index, int excl_mode); |
| 53 | int llc_is_exclusive(int ap_index); |
| 54 | void llc_runtime_enable(int ap_index); |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 55 | #if LLC_SRAM |
Konstantin Porotchkin | 1e1ab1d | 2019-04-04 10:02:20 +0300 | [diff] [blame] | 56 | int llc_sram_enable(int ap_index, int size); |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 57 | void llc_sram_disable(int ap_index); |
Konstantin Porotchkin | 1e1ab1d | 2019-04-04 10:02:20 +0300 | [diff] [blame] | 58 | int llc_sram_test(int ap_index, int size, char *msg); |
Konstantin Porotchkin | 2ef36a3 | 2019-03-31 16:58:11 +0300 | [diff] [blame] | 59 | #endif /* LLC_SRAM */ |
| 60 | #endif /* __ASSEMBLY__ */ |
Konstantin Porotchkin | 402fcf1 | 2018-02-26 16:04:25 +0200 | [diff] [blame] | 61 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 62 | #endif /* CACHE_LLC_H */ |