Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <config.h> |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 8 | #include <common.h> |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 9 | #include <linux/compiler.h> |
| 10 | #include <linux/kernel.h> |
Alexey Brodkin | 982f6bf | 2017-06-26 11:46:47 +0300 | [diff] [blame] | 11 | #include <linux/log2.h> |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 12 | #include <asm/arcregs.h> |
Alexey Brodkin | 6b95cca | 2015-02-03 13:58:13 +0300 | [diff] [blame] | 13 | #include <asm/cache.h> |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 14 | |
Eugeniy Paltsev | bcedf4d | 2018-03-21 15:58:50 +0300 | [diff] [blame^] | 15 | /* |
| 16 | * [ NOTE 1 ]: |
| 17 | * Data cache (L1 D$ or SL$) entire invalidate operation or data cache disable |
| 18 | * operation may result in unexpected behavior and data loss even if we flush |
| 19 | * data cache right before invalidation. That may happens if we store any context |
| 20 | * on stack (like we store BLINK register on stack before function call). |
| 21 | * BLINK register is the register where return address is automatically saved |
| 22 | * when we do function call with instructions like 'bl'. |
| 23 | * |
| 24 | * There is the real example: |
| 25 | * We may hang in the next code as we store any BLINK register on stack in |
| 26 | * invalidate_dcache_all() function. |
| 27 | * |
| 28 | * void flush_dcache_all() { |
| 29 | * __dc_entire_op(OP_FLUSH); |
| 30 | * // Other code // |
| 31 | * } |
| 32 | * |
| 33 | * void invalidate_dcache_all() { |
| 34 | * __dc_entire_op(OP_INV); |
| 35 | * // Other code // |
| 36 | * } |
| 37 | * |
| 38 | * void foo(void) { |
| 39 | * flush_dcache_all(); |
| 40 | * invalidate_dcache_all(); |
| 41 | * } |
| 42 | * |
| 43 | * Now let's see what really happens during that code execution: |
| 44 | * |
| 45 | * foo() |
| 46 | * |->> call flush_dcache_all |
| 47 | * [return address is saved to BLINK register] |
| 48 | * [push BLINK] (save to stack) ![point 1] |
| 49 | * |->> call __dc_entire_op(OP_FLUSH) |
| 50 | * [return address is saved to BLINK register] |
| 51 | * [flush L1 D$] |
| 52 | * return [jump to BLINK] |
| 53 | * <<------ |
| 54 | * [other flush_dcache_all code] |
| 55 | * [pop BLINK] (get from stack) |
| 56 | * return [jump to BLINK] |
| 57 | * <<------ |
| 58 | * |->> call invalidate_dcache_all |
| 59 | * [return address is saved to BLINK register] |
| 60 | * [push BLINK] (save to stack) ![point 2] |
| 61 | * |->> call __dc_entire_op(OP_FLUSH) |
| 62 | * [return address is saved to BLINK register] |
| 63 | * [invalidate L1 D$] ![point 3] |
| 64 | * // Oops!!! |
| 65 | * // We lose return address from invalidate_dcache_all function: |
| 66 | * // we save it to stack and invalidate L1 D$ after that! |
| 67 | * return [jump to BLINK] |
| 68 | * <<------ |
| 69 | * [other invalidate_dcache_all code] |
| 70 | * [pop BLINK] (get from stack) |
| 71 | * // we don't have this data in L1 dcache as we invalidated it in [point 3] |
| 72 | * // so we get it from next memory level (for example DDR memory) |
| 73 | * // but in the memory we have value which we save in [point 1], which |
| 74 | * // is return address from flush_dcache_all function (instead of |
| 75 | * // address from current invalidate_dcache_all function which we |
| 76 | * // saved in [point 2] !) |
| 77 | * return [jump to BLINK] |
| 78 | * <<------ |
| 79 | * // As BLINK points to invalidate_dcache_all, we call it again and |
| 80 | * // loop forever. |
| 81 | * |
| 82 | * Fortunately we may fix that by using flush & invalidation of D$ with a single |
| 83 | * one instruction (instead of flush and invalidation instructions pair) and |
| 84 | * enabling force function inline with '__attribute__((always_inline))' gcc |
| 85 | * attribute to avoid any function call (and BLINK store) between cache flush |
| 86 | * and disable. |
| 87 | */ |
| 88 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 89 | /* Bit values in IC_CTRL */ |
Eugeniy Paltsev | 6e626f0 | 2018-01-16 19:20:29 +0300 | [diff] [blame] | 90 | #define IC_CTRL_CACHE_DISABLE BIT(0) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 91 | |
| 92 | /* Bit values in DC_CTRL */ |
Eugeniy Paltsev | 6e626f0 | 2018-01-16 19:20:29 +0300 | [diff] [blame] | 93 | #define DC_CTRL_CACHE_DISABLE BIT(0) |
| 94 | #define DC_CTRL_INV_MODE_FLUSH BIT(6) |
| 95 | #define DC_CTRL_FLUSH_STATUS BIT(8) |
Igor Guryanov | bd889f9 | 2014-12-24 16:07:07 +0300 | [diff] [blame] | 96 | #define CACHE_VER_NUM_MASK 0xF |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 97 | |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 98 | #define OP_INV BIT(0) |
| 99 | #define OP_FLUSH BIT(1) |
| 100 | #define OP_FLUSH_N_INV (OP_FLUSH | OP_INV) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 101 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 102 | /* Bit val in SLC_CONTROL */ |
| 103 | #define SLC_CTRL_DIS 0x001 |
| 104 | #define SLC_CTRL_IM 0x040 |
| 105 | #define SLC_CTRL_BUSY 0x100 |
| 106 | #define SLC_CTRL_RGN_OP_INV 0x200 |
| 107 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 108 | /* |
| 109 | * By default that variable will fall into .bss section. |
| 110 | * But .bss section is not relocated and so it will be initilized before |
| 111 | * relocation but will be used after being zeroed. |
| 112 | */ |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 113 | int l1_line_sz __section(".data"); |
Eugeniy Paltsev | 570d551 | 2017-11-30 17:41:32 +0300 | [diff] [blame] | 114 | bool dcache_exists __section(".data") = false; |
| 115 | bool icache_exists __section(".data") = false; |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 116 | |
| 117 | #define CACHE_LINE_MASK (~(l1_line_sz - 1)) |
| 118 | |
| 119 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 120 | int slc_line_sz __section(".data"); |
Eugeniy Paltsev | 570d551 | 2017-11-30 17:41:32 +0300 | [diff] [blame] | 121 | bool slc_exists __section(".data") = false; |
| 122 | bool ioc_exists __section(".data") = false; |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 123 | bool pae_exists __section(".data") = false; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 124 | |
Eugeniy Paltsev | 111161e | 2018-01-16 19:20:28 +0300 | [diff] [blame] | 125 | /* To force enable IOC set ioc_enable to 'true' */ |
| 126 | bool ioc_enable __section(".data") = false; |
| 127 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 128 | void read_decode_mmu_bcr(void) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 129 | { |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 130 | /* TODO: should we compare mmu version from BCR and from CONFIG? */ |
| 131 | #if (CONFIG_ARC_MMU_VER >= 4) |
| 132 | u32 tmp; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 133 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 134 | tmp = read_aux_reg(ARC_AUX_MMU_BCR); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 135 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 136 | struct bcr_mmu_4 { |
| 137 | #ifdef CONFIG_CPU_BIG_ENDIAN |
| 138 | unsigned int ver:8, sasid:1, sz1:4, sz0:4, res:2, pae:1, |
| 139 | n_ways:2, n_entry:2, n_super:2, u_itlb:3, u_dtlb:3; |
| 140 | #else |
| 141 | /* DTLB ITLB JES JE JA */ |
| 142 | unsigned int u_dtlb:3, u_itlb:3, n_super:2, n_entry:2, n_ways:2, |
| 143 | pae:1, res:2, sz0:4, sz1:4, sasid:1, ver:8; |
| 144 | #endif /* CONFIG_CPU_BIG_ENDIAN */ |
| 145 | } *mmu4; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 146 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 147 | mmu4 = (struct bcr_mmu_4 *)&tmp; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 148 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 149 | pae_exists = !!mmu4->pae; |
| 150 | #endif /* (CONFIG_ARC_MMU_VER >= 4) */ |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 151 | } |
| 152 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 153 | static void __slc_entire_op(const int op) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 154 | { |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 155 | unsigned int ctrl; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 156 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 157 | ctrl = read_aux_reg(ARC_AUX_SLC_CTRL); |
| 158 | |
| 159 | if (!(op & OP_FLUSH)) /* i.e. OP_INV */ |
| 160 | ctrl &= ~SLC_CTRL_IM; /* clear IM: Disable flush before Inv */ |
| 161 | else |
| 162 | ctrl |= SLC_CTRL_IM; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 163 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 164 | write_aux_reg(ARC_AUX_SLC_CTRL, ctrl); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 165 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 166 | if (op & OP_INV) /* Inv or flush-n-inv use same cmd reg */ |
| 167 | write_aux_reg(ARC_AUX_SLC_INVALIDATE, 0x1); |
| 168 | else |
| 169 | write_aux_reg(ARC_AUX_SLC_FLUSH, 0x1); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 170 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 171 | /* Make sure "busy" bit reports correct stataus, see STAR 9001165532 */ |
| 172 | read_aux_reg(ARC_AUX_SLC_CTRL); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 173 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 174 | /* Important to wait for flush to complete */ |
| 175 | while (read_aux_reg(ARC_AUX_SLC_CTRL) & SLC_CTRL_BUSY); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 176 | } |
| 177 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 178 | static void slc_upper_region_init(void) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 179 | { |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 180 | /* |
| 181 | * ARC_AUX_SLC_RGN_END1 and ARC_AUX_SLC_RGN_START1 are always == 0 |
| 182 | * as we don't use PAE40. |
| 183 | */ |
| 184 | write_aux_reg(ARC_AUX_SLC_RGN_END1, 0); |
| 185 | write_aux_reg(ARC_AUX_SLC_RGN_START1, 0); |
| 186 | } |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 187 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 188 | static void __slc_rgn_op(unsigned long paddr, unsigned long sz, const int op) |
| 189 | { |
| 190 | unsigned int ctrl; |
| 191 | unsigned long end; |
| 192 | |
| 193 | /* |
| 194 | * The Region Flush operation is specified by CTRL.RGN_OP[11..9] |
| 195 | * - b'000 (default) is Flush, |
| 196 | * - b'001 is Invalidate if CTRL.IM == 0 |
| 197 | * - b'001 is Flush-n-Invalidate if CTRL.IM == 1 |
| 198 | */ |
| 199 | ctrl = read_aux_reg(ARC_AUX_SLC_CTRL); |
| 200 | |
| 201 | /* Don't rely on default value of IM bit */ |
| 202 | if (!(op & OP_FLUSH)) /* i.e. OP_INV */ |
| 203 | ctrl &= ~SLC_CTRL_IM; /* clear IM: Disable flush before Inv */ |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 204 | else |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 205 | ctrl |= SLC_CTRL_IM; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 206 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 207 | if (op & OP_INV) |
| 208 | ctrl |= SLC_CTRL_RGN_OP_INV; /* Inv or flush-n-inv */ |
| 209 | else |
| 210 | ctrl &= ~SLC_CTRL_RGN_OP_INV; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 211 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 212 | write_aux_reg(ARC_AUX_SLC_CTRL, ctrl); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 213 | |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 214 | /* |
| 215 | * Lower bits are ignored, no need to clip |
| 216 | * END needs to be setup before START (latter triggers the operation) |
| 217 | * END can't be same as START, so add (l2_line_sz - 1) to sz |
| 218 | */ |
| 219 | end = paddr + sz + slc_line_sz - 1; |
| 220 | |
| 221 | /* |
| 222 | * Upper addresses (ARC_AUX_SLC_RGN_END1 and ARC_AUX_SLC_RGN_START1) |
| 223 | * are always == 0 as we don't use PAE40, so we only setup lower ones |
| 224 | * (ARC_AUX_SLC_RGN_END and ARC_AUX_SLC_RGN_START) |
| 225 | */ |
| 226 | write_aux_reg(ARC_AUX_SLC_RGN_END, end); |
| 227 | write_aux_reg(ARC_AUX_SLC_RGN_START, paddr); |
| 228 | |
| 229 | /* Make sure "busy" bit reports correct stataus, see STAR 9001165532 */ |
| 230 | read_aux_reg(ARC_AUX_SLC_CTRL); |
| 231 | |
| 232 | while (read_aux_reg(ARC_AUX_SLC_CTRL) & SLC_CTRL_BUSY); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 233 | } |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 234 | #endif /* CONFIG_ISA_ARCV2 */ |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 235 | |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 236 | #ifdef CONFIG_ISA_ARCV2 |
| 237 | static void read_decode_cache_bcr_arcv2(void) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 238 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 239 | union { |
| 240 | struct { |
| 241 | #ifdef CONFIG_CPU_BIG_ENDIAN |
| 242 | unsigned int pad:24, way:2, lsz:2, sz:4; |
| 243 | #else |
| 244 | unsigned int sz:4, lsz:2, way:2, pad:24; |
| 245 | #endif |
| 246 | } fields; |
| 247 | unsigned int word; |
| 248 | } slc_cfg; |
| 249 | |
| 250 | union { |
| 251 | struct { |
| 252 | #ifdef CONFIG_CPU_BIG_ENDIAN |
| 253 | unsigned int pad:24, ver:8; |
| 254 | #else |
| 255 | unsigned int ver:8, pad:24; |
| 256 | #endif |
| 257 | } fields; |
| 258 | unsigned int word; |
| 259 | } sbcr; |
| 260 | |
| 261 | sbcr.word = read_aux_reg(ARC_BCR_SLC); |
| 262 | if (sbcr.fields.ver) { |
| 263 | slc_cfg.word = read_aux_reg(ARC_AUX_SLC_CONFIG); |
Eugeniy Paltsev | 570d551 | 2017-11-30 17:41:32 +0300 | [diff] [blame] | 264 | slc_exists = true; |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 265 | slc_line_sz = (slc_cfg.fields.lsz == 0) ? 128 : 64; |
| 266 | } |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 267 | |
| 268 | union { |
| 269 | struct bcr_clust_cfg { |
| 270 | #ifdef CONFIG_CPU_BIG_ENDIAN |
| 271 | unsigned int pad:7, c:1, num_entries:8, num_cores:8, ver:8; |
| 272 | #else |
| 273 | unsigned int ver:8, num_cores:8, num_entries:8, c:1, pad:7; |
| 274 | #endif |
| 275 | } fields; |
| 276 | unsigned int word; |
| 277 | } cbcr; |
| 278 | |
| 279 | cbcr.word = read_aux_reg(ARC_BCR_CLUSTER); |
Eugeniy Paltsev | 111161e | 2018-01-16 19:20:28 +0300 | [diff] [blame] | 280 | if (cbcr.fields.c && ioc_enable) |
Eugeniy Paltsev | 570d551 | 2017-11-30 17:41:32 +0300 | [diff] [blame] | 281 | ioc_exists = true; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 282 | } |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 283 | #endif |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 284 | |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 285 | void read_decode_cache_bcr(void) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 286 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 287 | int dc_line_sz = 0, ic_line_sz = 0; |
| 288 | |
| 289 | union { |
| 290 | struct { |
| 291 | #ifdef CONFIG_CPU_BIG_ENDIAN |
| 292 | unsigned int pad:12, line_len:4, sz:4, config:4, ver:8; |
| 293 | #else |
| 294 | unsigned int ver:8, config:4, sz:4, line_len:4, pad:12; |
| 295 | #endif |
| 296 | } fields; |
| 297 | unsigned int word; |
| 298 | } ibcr, dbcr; |
| 299 | |
| 300 | ibcr.word = read_aux_reg(ARC_BCR_IC_BUILD); |
| 301 | if (ibcr.fields.ver) { |
Eugeniy Paltsev | 570d551 | 2017-11-30 17:41:32 +0300 | [diff] [blame] | 302 | icache_exists = true; |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 303 | l1_line_sz = ic_line_sz = 8 << ibcr.fields.line_len; |
| 304 | if (!ic_line_sz) |
| 305 | panic("Instruction exists but line length is 0\n"); |
| 306 | } |
| 307 | |
| 308 | dbcr.word = read_aux_reg(ARC_BCR_DC_BUILD); |
Eugeniy Paltsev | 6e626f0 | 2018-01-16 19:20:29 +0300 | [diff] [blame] | 309 | if (dbcr.fields.ver) { |
Eugeniy Paltsev | 570d551 | 2017-11-30 17:41:32 +0300 | [diff] [blame] | 310 | dcache_exists = true; |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 311 | l1_line_sz = dc_line_sz = 16 << dbcr.fields.line_len; |
| 312 | if (!dc_line_sz) |
| 313 | panic("Data cache exists but line length is 0\n"); |
| 314 | } |
| 315 | |
| 316 | if (ic_line_sz && dc_line_sz && (ic_line_sz != dc_line_sz)) |
| 317 | panic("Instruction and data cache line lengths differ\n"); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | void cache_init(void) |
| 321 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 322 | read_decode_cache_bcr(); |
| 323 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 324 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 325 | read_decode_cache_bcr_arcv2(); |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 326 | |
| 327 | if (ioc_exists) { |
Alexey Brodkin | 982f6bf | 2017-06-26 11:46:47 +0300 | [diff] [blame] | 328 | /* IOC Aperture start is equal to DDR start */ |
| 329 | unsigned int ap_base = CONFIG_SYS_SDRAM_BASE; |
| 330 | /* IOC Aperture size is equal to DDR size */ |
| 331 | long ap_size = CONFIG_SYS_SDRAM_SIZE; |
| 332 | |
Eugeniy Paltsev | bcedf4d | 2018-03-21 15:58:50 +0300 | [diff] [blame^] | 333 | flush_n_invalidate_dcache_all(); |
Alexey Brodkin | 5accfc9 | 2016-06-08 08:04:03 +0300 | [diff] [blame] | 334 | |
Alexey Brodkin | 982f6bf | 2017-06-26 11:46:47 +0300 | [diff] [blame] | 335 | if (!is_power_of_2(ap_size) || ap_size < 4096) |
| 336 | panic("IOC Aperture size must be power of 2 and bigger 4Kib"); |
| 337 | |
| 338 | /* |
| 339 | * IOC Aperture size decoded as 2 ^ (SIZE + 2) KB, |
| 340 | * so setting 0x11 implies 512M, 0x12 implies 1G... |
| 341 | */ |
| 342 | write_aux_reg(ARC_AUX_IO_COH_AP0_SIZE, |
Eugeniy Paltsev | 6e626f0 | 2018-01-16 19:20:29 +0300 | [diff] [blame] | 343 | order_base_2(ap_size / 1024) - 2); |
Alexey Brodkin | 982f6bf | 2017-06-26 11:46:47 +0300 | [diff] [blame] | 344 | |
| 345 | /* IOC Aperture start must be aligned to the size of the aperture */ |
| 346 | if (ap_base % ap_size != 0) |
| 347 | panic("IOC Aperture start must be aligned to the size of the aperture"); |
| 348 | |
| 349 | write_aux_reg(ARC_AUX_IO_COH_AP0_BASE, ap_base >> 12); |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 350 | write_aux_reg(ARC_AUX_IO_COH_PARTIAL, 1); |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 351 | write_aux_reg(ARC_AUX_IO_COH_ENABLE, 1); |
| 352 | } |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 353 | |
| 354 | read_decode_mmu_bcr(); |
| 355 | |
| 356 | /* |
| 357 | * ARC_AUX_SLC_RGN_START1 and ARC_AUX_SLC_RGN_END1 register exist |
| 358 | * only if PAE exists in current HW. So we had to check pae_exist |
| 359 | * before using them. |
| 360 | */ |
| 361 | if (slc_exists && pae_exists) |
| 362 | slc_upper_region_init(); |
| 363 | #endif /* CONFIG_ISA_ARCV2 */ |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 364 | } |
| 365 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 366 | int icache_status(void) |
| 367 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 368 | if (!icache_exists) |
Igor Guryanov | bd889f9 | 2014-12-24 16:07:07 +0300 | [diff] [blame] | 369 | return 0; |
| 370 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 371 | if (read_aux_reg(ARC_AUX_IC_CTRL) & IC_CTRL_CACHE_DISABLE) |
| 372 | return 0; |
| 373 | else |
| 374 | return 1; |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | void icache_enable(void) |
| 378 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 379 | if (icache_exists) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 380 | write_aux_reg(ARC_AUX_IC_CTRL, read_aux_reg(ARC_AUX_IC_CTRL) & |
| 381 | ~IC_CTRL_CACHE_DISABLE); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | void icache_disable(void) |
| 385 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 386 | if (icache_exists) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 387 | write_aux_reg(ARC_AUX_IC_CTRL, read_aux_reg(ARC_AUX_IC_CTRL) | |
| 388 | IC_CTRL_CACHE_DISABLE); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 389 | } |
| 390 | |
Eugeniy Paltsev | ad8aef3 | 2018-03-21 15:58:46 +0300 | [diff] [blame] | 391 | /* IC supports only invalidation */ |
| 392 | static inline void __ic_entire_invalidate(void) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 393 | { |
Eugeniy Paltsev | ad8aef3 | 2018-03-21 15:58:46 +0300 | [diff] [blame] | 394 | if (!icache_status()) |
| 395 | return; |
| 396 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 397 | /* Any write to IC_IVIC register triggers invalidation of entire I$ */ |
Eugeniy Paltsev | ad8aef3 | 2018-03-21 15:58:46 +0300 | [diff] [blame] | 398 | write_aux_reg(ARC_AUX_IC_IVIC, 1); |
| 399 | /* |
| 400 | * As per ARC HS databook (see chapter 5.3.3.2) |
| 401 | * it is required to add 3 NOPs after each write to IC_IVIC. |
| 402 | */ |
| 403 | __builtin_arc_nop(); |
| 404 | __builtin_arc_nop(); |
| 405 | __builtin_arc_nop(); |
| 406 | read_aux_reg(ARC_AUX_IC_CTRL); /* blocks */ |
| 407 | } |
| 408 | |
| 409 | void invalidate_icache_all(void) |
| 410 | { |
| 411 | __ic_entire_invalidate(); |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 412 | |
| 413 | #ifdef CONFIG_ISA_ARCV2 |
| 414 | if (slc_exists) |
| 415 | __slc_entire_op(OP_INV); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 416 | #endif |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 417 | } |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 418 | |
| 419 | int dcache_status(void) |
| 420 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 421 | if (!dcache_exists) |
Igor Guryanov | bd889f9 | 2014-12-24 16:07:07 +0300 | [diff] [blame] | 422 | return 0; |
| 423 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 424 | if (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_CACHE_DISABLE) |
| 425 | return 0; |
| 426 | else |
| 427 | return 1; |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | void dcache_enable(void) |
| 431 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 432 | if (!dcache_exists) |
Igor Guryanov | bd889f9 | 2014-12-24 16:07:07 +0300 | [diff] [blame] | 433 | return; |
| 434 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 435 | write_aux_reg(ARC_AUX_DC_CTRL, read_aux_reg(ARC_AUX_DC_CTRL) & |
| 436 | ~(DC_CTRL_INV_MODE_FLUSH | DC_CTRL_CACHE_DISABLE)); |
| 437 | } |
| 438 | |
| 439 | void dcache_disable(void) |
| 440 | { |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 441 | if (!dcache_exists) |
Igor Guryanov | bd889f9 | 2014-12-24 16:07:07 +0300 | [diff] [blame] | 442 | return; |
| 443 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 444 | write_aux_reg(ARC_AUX_DC_CTRL, read_aux_reg(ARC_AUX_DC_CTRL) | |
| 445 | DC_CTRL_CACHE_DISABLE); |
| 446 | } |
| 447 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 448 | #ifndef CONFIG_SYS_DCACHE_OFF |
Eugeniy Paltsev | 988152c | 2018-03-21 15:58:47 +0300 | [diff] [blame] | 449 | /* Common Helper for Line Operations on D-cache */ |
| 450 | static inline void __dcache_line_loop(unsigned long paddr, unsigned long sz, |
| 451 | const int cacheop) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 452 | { |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 453 | unsigned int aux_cmd; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 454 | int num_lines; |
| 455 | |
Eugeniy Paltsev | 988152c | 2018-03-21 15:58:47 +0300 | [diff] [blame] | 456 | /* d$ cmd: INV (discard or wback-n-discard) OR FLUSH (wback) */ |
| 457 | aux_cmd = cacheop & OP_INV ? ARC_AUX_DC_IVDL : ARC_AUX_DC_FLDL; |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 458 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 459 | sz += paddr & ~CACHE_LINE_MASK; |
| 460 | paddr &= CACHE_LINE_MASK; |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 461 | |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 462 | num_lines = DIV_ROUND_UP(sz, l1_line_sz); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 463 | |
| 464 | while (num_lines-- > 0) { |
Alexey Brodkin | 6da8cfc | 2015-02-03 13:58:12 +0300 | [diff] [blame] | 465 | #if (CONFIG_ARC_MMU_VER == 3) |
Eugeniy Paltsev | 988152c | 2018-03-21 15:58:47 +0300 | [diff] [blame] | 466 | write_aux_reg(ARC_AUX_DC_PTAG, paddr); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 467 | #endif |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 468 | write_aux_reg(aux_cmd, paddr); |
Alexey Brodkin | dff5df2 | 2015-12-14 17:14:46 +0300 | [diff] [blame] | 469 | paddr += l1_line_sz; |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 470 | } |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 471 | } |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 472 | |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 473 | static void __before_dc_op(const int op) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 474 | { |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 475 | unsigned int ctrl; |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 476 | |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 477 | ctrl = read_aux_reg(ARC_AUX_DC_CTRL); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 478 | |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 479 | /* IM bit implies flush-n-inv, instead of vanilla inv */ |
| 480 | if (op == OP_INV) |
| 481 | ctrl &= ~DC_CTRL_INV_MODE_FLUSH; |
| 482 | else |
| 483 | ctrl |= DC_CTRL_INV_MODE_FLUSH; |
| 484 | |
| 485 | write_aux_reg(ARC_AUX_DC_CTRL, ctrl); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 486 | } |
| 487 | |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 488 | static void __after_dc_op(const int op) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 489 | { |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 490 | if (op & OP_FLUSH) /* flush / flush-n-inv both wait */ |
Eugeniy Paltsev | 6e626f0 | 2018-01-16 19:20:29 +0300 | [diff] [blame] | 491 | while (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_FLUSH_STATUS); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 492 | } |
| 493 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 494 | static inline void __dc_entire_op(const int cacheop) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 495 | { |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 496 | int aux; |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 497 | |
| 498 | __before_dc_op(cacheop); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 499 | |
| 500 | if (cacheop & OP_INV) /* Inv or flush-n-inv use same cmd reg */ |
| 501 | aux = ARC_AUX_DC_IVDC; |
| 502 | else |
| 503 | aux = ARC_AUX_DC_FLSH; |
Alexey Brodkin | 35221a6 | 2015-03-27 12:47:29 +0300 | [diff] [blame] | 504 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 505 | write_aux_reg(aux, 0x1); |
| 506 | |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 507 | __after_dc_op(cacheop); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 508 | } |
| 509 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 510 | static inline void __dc_line_op(unsigned long paddr, unsigned long sz, |
| 511 | const int cacheop) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 512 | { |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 513 | __before_dc_op(cacheop); |
Eugeniy Paltsev | 988152c | 2018-03-21 15:58:47 +0300 | [diff] [blame] | 514 | __dcache_line_loop(paddr, sz, cacheop); |
Eugeniy Paltsev | e256cb0 | 2018-03-21 15:58:48 +0300 | [diff] [blame] | 515 | __after_dc_op(cacheop); |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 516 | } |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 517 | #else |
| 518 | #define __dc_entire_op(cacheop) |
| 519 | #define __dc_line_op(paddr, sz, cacheop) |
| 520 | #endif /* !CONFIG_SYS_DCACHE_OFF */ |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 521 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 522 | void invalidate_dcache_range(unsigned long start, unsigned long end) |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 523 | { |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 524 | if (start >= end) |
| 525 | return; |
| 526 | |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 527 | #ifdef CONFIG_ISA_ARCV2 |
| 528 | if (!ioc_exists) |
| 529 | #endif |
| 530 | __dc_line_op(start, end - start, OP_INV); |
| 531 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 532 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 533 | if (slc_exists && !ioc_exists) |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 534 | __slc_rgn_op(start, end - start, OP_INV); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 535 | #endif |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 536 | } |
| 537 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 538 | void flush_dcache_range(unsigned long start, unsigned long end) |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 539 | { |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 540 | if (start >= end) |
| 541 | return; |
| 542 | |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 543 | #ifdef CONFIG_ISA_ARCV2 |
| 544 | if (!ioc_exists) |
| 545 | #endif |
| 546 | __dc_line_op(start, end - start, OP_FLUSH); |
| 547 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 548 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 549 | if (slc_exists && !ioc_exists) |
Eugeniy Paltsev | 1d0578e | 2018-01-16 19:20:26 +0300 | [diff] [blame] | 550 | __slc_rgn_op(start, end - start, OP_FLUSH); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 551 | #endif |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 552 | } |
| 553 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 554 | void flush_cache(unsigned long start, unsigned long size) |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 555 | { |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 556 | flush_dcache_range(start, start + size); |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 557 | } |
| 558 | |
Eugeniy Paltsev | bcedf4d | 2018-03-21 15:58:50 +0300 | [diff] [blame^] | 559 | /* |
| 560 | * As invalidate_dcache_all() is not used in generic U-Boot code and as we |
| 561 | * don't need it in arch/arc code alone (invalidate without flush) we implement |
| 562 | * flush_n_invalidate_dcache_all (flush and invalidate in 1 operation) because |
| 563 | * it's much safer. See [ NOTE 1 ] for more details. |
| 564 | */ |
| 565 | void flush_n_invalidate_dcache_all(void) |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 566 | { |
Eugeniy Paltsev | bcedf4d | 2018-03-21 15:58:50 +0300 | [diff] [blame^] | 567 | __dc_entire_op(OP_FLUSH_N_INV); |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 568 | |
| 569 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | e344c1f | 2016-06-08 07:57:19 +0300 | [diff] [blame] | 570 | if (slc_exists) |
Eugeniy Paltsev | bcedf4d | 2018-03-21 15:58:50 +0300 | [diff] [blame^] | 571 | __slc_entire_op(OP_FLUSH_N_INV); |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 572 | #endif |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 573 | } |
| 574 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 575 | void flush_dcache_all(void) |
| 576 | { |
Alexey Brodkin | 5f54169 | 2016-04-16 15:28:30 +0300 | [diff] [blame] | 577 | __dc_entire_op(OP_FLUSH); |
Alexey Brodkin | 4764d26 | 2015-12-14 17:15:13 +0300 | [diff] [blame] | 578 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 579 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | 5f54169 | 2016-04-16 15:28:30 +0300 | [diff] [blame] | 580 | if (slc_exists) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 581 | __slc_entire_op(OP_FLUSH); |
| 582 | #endif |
| 583 | } |