cache_v8.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013
  4. * David Feng <fenghua@phytium.com.cn>
  5. *
  6. * (C) Copyright 2016
  7. * Alexander Graf <agraf@suse.de>
  8. */
  9. #include <common.h>
  10. #include <asm/system.h>
  11. #include <asm/armv8/mmu.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. #ifndef CONFIG_SYS_DCACHE_OFF
  14. /*
  15. * With 4k page granule, a virtual address is split into 4 lookup parts
  16. * spanning 9 bits each:
  17. *
  18. * _______________________________________________
  19. * | | | | | | |
  20. * | 0 | Lv0 | Lv1 | Lv2 | Lv3 | off |
  21. * |_______|_______|_______|_______|_______|_______|
  22. * 63-48 47-39 38-30 29-21 20-12 11-00
  23. *
  24. * mask page size
  25. *
  26. * Lv0: FF8000000000 --
  27. * Lv1: 7FC0000000 1G
  28. * Lv2: 3FE00000 2M
  29. * Lv3: 1FF000 4K
  30. * off: FFF
  31. */
  32. u64 get_tcr(int el, u64 *pips, u64 *pva_bits)
  33. {
  34. u64 max_addr = 0;
  35. u64 ips, va_bits;
  36. u64 tcr;
  37. int i;
  38. /* Find the largest address we need to support */
  39. for (i = 0; mem_map[i].size || mem_map[i].attrs; i++)
  40. max_addr = max(max_addr, mem_map[i].virt + mem_map[i].size);
  41. /* Calculate the maximum physical (and thus virtual) address */
  42. if (max_addr > (1ULL << 44)) {
  43. ips = 5;
  44. va_bits = 48;
  45. } else if (max_addr > (1ULL << 42)) {
  46. ips = 4;
  47. va_bits = 44;
  48. } else if (max_addr > (1ULL << 40)) {
  49. ips = 3;
  50. va_bits = 42;
  51. } else if (max_addr > (1ULL << 36)) {
  52. ips = 2;
  53. va_bits = 40;
  54. } else if (max_addr > (1ULL << 32)) {
  55. ips = 1;
  56. va_bits = 36;
  57. } else {
  58. ips = 0;
  59. va_bits = 32;
  60. }
  61. if (el == 1) {
  62. tcr = TCR_EL1_RSVD | (ips << 32) | TCR_EPD1_DISABLE;
  63. } else if (el == 2) {
  64. tcr = TCR_EL2_RSVD | (ips << 16);
  65. } else {
  66. tcr = TCR_EL3_RSVD | (ips << 16);
  67. }
  68. /* PTWs cacheable, inner/outer WBWA and inner shareable */
  69. tcr |= TCR_TG0_4K | TCR_SHARED_INNER | TCR_ORGN_WBWA | TCR_IRGN_WBWA;
  70. tcr |= TCR_T0SZ(va_bits);
  71. if (pips)
  72. *pips = ips;
  73. if (pva_bits)
  74. *pva_bits = va_bits;
  75. return tcr;
  76. }
  77. #define MAX_PTE_ENTRIES 512
  78. static int pte_type(u64 *pte)
  79. {
  80. return *pte & PTE_TYPE_MASK;
  81. }
  82. /* Returns the LSB number for a PTE on level <level> */
  83. static int level2shift(int level)
  84. {
  85. /* Page is 12 bits wide, every level translates 9 bits */
  86. return (12 + 9 * (3 - level));
  87. }
  88. static u64 *find_pte(u64 addr, int level)
  89. {
  90. int start_level = 0;
  91. u64 *pte;
  92. u64 idx;
  93. u64 va_bits;
  94. int i;
  95. debug("addr=%llx level=%d\n", addr, level);
  96. get_tcr(0, NULL, &va_bits);
  97. if (va_bits < 39)
  98. start_level = 1;
  99. if (level < start_level)
  100. return NULL;
  101. /* Walk through all page table levels to find our PTE */
  102. pte = (u64*)gd->arch.tlb_addr;
  103. for (i = start_level; i < 4; i++) {
  104. idx = (addr >> level2shift(i)) & 0x1FF;
  105. pte += idx;
  106. debug("idx=%llx PTE %p at level %d: %llx\n", idx, pte, i, *pte);
  107. /* Found it */
  108. if (i == level)
  109. return pte;
  110. /* PTE is no table (either invalid or block), can't traverse */
  111. if (pte_type(pte) != PTE_TYPE_TABLE)
  112. return NULL;
  113. /* Off to the next level */
  114. pte = (u64*)(*pte & 0x0000fffffffff000ULL);
  115. }
  116. /* Should never reach here */
  117. return NULL;
  118. }
  119. /* Returns and creates a new full table (512 entries) */
  120. static u64 *create_table(void)
  121. {
  122. u64 *new_table = (u64*)gd->arch.tlb_fillptr;
  123. u64 pt_len = MAX_PTE_ENTRIES * sizeof(u64);
  124. /* Allocate MAX_PTE_ENTRIES pte entries */
  125. gd->arch.tlb_fillptr += pt_len;
  126. if (gd->arch.tlb_fillptr - gd->arch.tlb_addr > gd->arch.tlb_size)
  127. panic("Insufficient RAM for page table: 0x%lx > 0x%lx. "
  128. "Please increase the size in get_page_table_size()",
  129. gd->arch.tlb_fillptr - gd->arch.tlb_addr,
  130. gd->arch.tlb_size);
  131. /* Mark all entries as invalid */
  132. memset(new_table, 0, pt_len);
  133. return new_table;
  134. }
  135. static void set_pte_table(u64 *pte, u64 *table)
  136. {
  137. /* Point *pte to the new table */
  138. debug("Setting %p to addr=%p\n", pte, table);
  139. *pte = PTE_TYPE_TABLE | (ulong)table;
  140. }
  141. /* Splits a block PTE into table with subpages spanning the old block */
  142. static void split_block(u64 *pte, int level)
  143. {
  144. u64 old_pte = *pte;
  145. u64 *new_table;
  146. u64 i = 0;
  147. /* level describes the parent level, we need the child ones */
  148. int levelshift = level2shift(level + 1);
  149. if (pte_type(pte) != PTE_TYPE_BLOCK)
  150. panic("PTE %p (%llx) is not a block. Some driver code wants to "
  151. "modify dcache settings for an range not covered in "
  152. "mem_map.", pte, old_pte);
  153. new_table = create_table();
  154. debug("Splitting pte %p (%llx) into %p\n", pte, old_pte, new_table);
  155. for (i = 0; i < MAX_PTE_ENTRIES; i++) {
  156. new_table[i] = old_pte | (i << levelshift);
  157. /* Level 3 block PTEs have the table type */
  158. if ((level + 1) == 3)
  159. new_table[i] |= PTE_TYPE_TABLE;
  160. debug("Setting new_table[%lld] = %llx\n", i, new_table[i]);
  161. }
  162. /* Set the new table into effect */
  163. set_pte_table(pte, new_table);
  164. }
  165. /* Add one mm_region map entry to the page tables */
  166. static void add_map(struct mm_region *map)
  167. {
  168. u64 *pte;
  169. u64 virt = map->virt;
  170. u64 phys = map->phys;
  171. u64 size = map->size;
  172. u64 attrs = map->attrs | PTE_TYPE_BLOCK | PTE_BLOCK_AF;
  173. u64 blocksize;
  174. int level;
  175. u64 *new_table;
  176. while (size) {
  177. pte = find_pte(virt, 0);
  178. if (pte && (pte_type(pte) == PTE_TYPE_FAULT)) {
  179. debug("Creating table for virt 0x%llx\n", virt);
  180. new_table = create_table();
  181. set_pte_table(pte, new_table);
  182. }
  183. for (level = 1; level < 4; level++) {
  184. pte = find_pte(virt, level);
  185. if (!pte)
  186. panic("pte not found\n");
  187. blocksize = 1ULL << level2shift(level);
  188. debug("Checking if pte fits for virt=%llx size=%llx blocksize=%llx\n",
  189. virt, size, blocksize);
  190. if (size >= blocksize && !(virt & (blocksize - 1))) {
  191. /* Page fits, create block PTE */
  192. debug("Setting PTE %p to block virt=%llx\n",
  193. pte, virt);
  194. if (level == 3)
  195. *pte = phys | attrs | PTE_TYPE_PAGE;
  196. else
  197. *pte = phys | attrs;
  198. virt += blocksize;
  199. phys += blocksize;
  200. size -= blocksize;
  201. break;
  202. } else if (pte_type(pte) == PTE_TYPE_FAULT) {
  203. /* Page doesn't fit, create subpages */
  204. debug("Creating subtable for virt 0x%llx blksize=%llx\n",
  205. virt, blocksize);
  206. new_table = create_table();
  207. set_pte_table(pte, new_table);
  208. } else if (pte_type(pte) == PTE_TYPE_BLOCK) {
  209. debug("Split block into subtable for virt 0x%llx blksize=0x%llx\n",
  210. virt, blocksize);
  211. split_block(pte, level);
  212. }
  213. }
  214. }
  215. }
  216. enum pte_type {
  217. PTE_INVAL,
  218. PTE_BLOCK,
  219. PTE_LEVEL,
  220. };
  221. /*
  222. * This is a recursively called function to count the number of
  223. * page tables we need to cover a particular PTE range. If you
  224. * call this with level = -1 you basically get the full 48 bit
  225. * coverage.
  226. */
  227. static int count_required_pts(u64 addr, int level, u64 maxaddr)
  228. {
  229. int levelshift = level2shift(level);
  230. u64 levelsize = 1ULL << levelshift;
  231. u64 levelmask = levelsize - 1;
  232. u64 levelend = addr + levelsize;
  233. int r = 0;
  234. int i;
  235. enum pte_type pte_type = PTE_INVAL;
  236. for (i = 0; mem_map[i].size || mem_map[i].attrs; i++) {
  237. struct mm_region *map = &mem_map[i];
  238. u64 start = map->virt;
  239. u64 end = start + map->size;
  240. /* Check if the PTE would overlap with the map */
  241. if (max(addr, start) <= min(levelend, end)) {
  242. start = max(addr, start);
  243. end = min(levelend, end);
  244. /* We need a sub-pt for this level */
  245. if ((start & levelmask) || (end & levelmask)) {
  246. pte_type = PTE_LEVEL;
  247. break;
  248. }
  249. /* Lv0 can not do block PTEs, so do levels here too */
  250. if (level <= 0) {
  251. pte_type = PTE_LEVEL;
  252. break;
  253. }
  254. /* PTE is active, but fits into a block */
  255. pte_type = PTE_BLOCK;
  256. }
  257. }
  258. /*
  259. * Block PTEs at this level are already covered by the parent page
  260. * table, so we only need to count sub page tables.
  261. */
  262. if (pte_type == PTE_LEVEL) {
  263. int sublevel = level + 1;
  264. u64 sublevelsize = 1ULL << level2shift(sublevel);
  265. /* Account for the new sub page table ... */
  266. r = 1;
  267. /* ... and for all child page tables that one might have */
  268. for (i = 0; i < MAX_PTE_ENTRIES; i++) {
  269. r += count_required_pts(addr, sublevel, maxaddr);
  270. addr += sublevelsize;
  271. if (addr >= maxaddr) {
  272. /*
  273. * We reached the end of address space, no need
  274. * to look any further.
  275. */
  276. break;
  277. }
  278. }
  279. }
  280. return r;
  281. }
  282. /* Returns the estimated required size of all page tables */
  283. __weak u64 get_page_table_size(void)
  284. {
  285. u64 one_pt = MAX_PTE_ENTRIES * sizeof(u64);
  286. u64 size = 0;
  287. u64 va_bits;
  288. int start_level = 0;
  289. get_tcr(0, NULL, &va_bits);
  290. if (va_bits < 39)
  291. start_level = 1;
  292. /* Account for all page tables we would need to cover our memory map */
  293. size = one_pt * count_required_pts(0, start_level - 1, 1ULL << va_bits);
  294. /*
  295. * We need to duplicate our page table once to have an emergency pt to
  296. * resort to when splitting page tables later on
  297. */
  298. size *= 2;
  299. /*
  300. * We may need to split page tables later on if dcache settings change,
  301. * so reserve up to 4 (random pick) page tables for that.
  302. */
  303. size += one_pt * 4;
  304. return size;
  305. }
  306. void setup_pgtables(void)
  307. {
  308. int i;
  309. if (!gd->arch.tlb_fillptr || !gd->arch.tlb_addr)
  310. panic("Page table pointer not setup.");
  311. /*
  312. * Allocate the first level we're on with invalidate entries.
  313. * If the starting level is 0 (va_bits >= 39), then this is our
  314. * Lv0 page table, otherwise it's the entry Lv1 page table.
  315. */
  316. create_table();
  317. /* Now add all MMU table entries one after another to the table */
  318. for (i = 0; mem_map[i].size || mem_map[i].attrs; i++)
  319. add_map(&mem_map[i]);
  320. }
  321. static void setup_all_pgtables(void)
  322. {
  323. u64 tlb_addr = gd->arch.tlb_addr;
  324. u64 tlb_size = gd->arch.tlb_size;
  325. /* Reset the fill ptr */
  326. gd->arch.tlb_fillptr = tlb_addr;
  327. /* Create normal system page tables */
  328. setup_pgtables();
  329. /* Create emergency page tables */
  330. gd->arch.tlb_size -= (uintptr_t)gd->arch.tlb_fillptr -
  331. (uintptr_t)gd->arch.tlb_addr;
  332. gd->arch.tlb_addr = gd->arch.tlb_fillptr;
  333. setup_pgtables();
  334. gd->arch.tlb_emerg = gd->arch.tlb_addr;
  335. gd->arch.tlb_addr = tlb_addr;
  336. gd->arch.tlb_size = tlb_size;
  337. }
  338. /* to activate the MMU we need to set up virtual memory */
  339. __weak void mmu_setup(void)
  340. {
  341. int el;
  342. /* Set up page tables only once */
  343. if (!gd->arch.tlb_fillptr)
  344. setup_all_pgtables();
  345. el = current_el();
  346. set_ttbr_tcr_mair(el, gd->arch.tlb_addr, get_tcr(el, NULL, NULL),
  347. MEMORY_ATTRIBUTES);
  348. /* enable the mmu */
  349. set_sctlr(get_sctlr() | CR_M);
  350. }
  351. /*
  352. * Performs a invalidation of the entire data cache at all levels
  353. */
  354. void invalidate_dcache_all(void)
  355. {
  356. __asm_invalidate_dcache_all();
  357. __asm_invalidate_l3_dcache();
  358. }
  359. /*
  360. * Performs a clean & invalidation of the entire data cache at all levels.
  361. * This function needs to be inline to avoid using stack.
  362. * __asm_flush_l3_dcache return status of timeout
  363. */
  364. inline void flush_dcache_all(void)
  365. {
  366. int ret;
  367. __asm_flush_dcache_all();
  368. ret = __asm_flush_l3_dcache();
  369. if (ret)
  370. debug("flushing dcache returns 0x%x\n", ret);
  371. else
  372. debug("flushing dcache successfully.\n");
  373. }
  374. /*
  375. * Invalidates range in all levels of D-cache/unified cache
  376. */
  377. void invalidate_dcache_range(unsigned long start, unsigned long stop)
  378. {
  379. __asm_invalidate_dcache_range(start, stop);
  380. }
  381. /*
  382. * Flush range(clean & invalidate) from all levels of D-cache/unified cache
  383. */
  384. void flush_dcache_range(unsigned long start, unsigned long stop)
  385. {
  386. __asm_flush_dcache_range(start, stop);
  387. }
  388. void dcache_enable(void)
  389. {
  390. /* The data cache is not active unless the mmu is enabled */
  391. if (!(get_sctlr() & CR_M)) {
  392. invalidate_dcache_all();
  393. __asm_invalidate_tlb_all();
  394. mmu_setup();
  395. }
  396. set_sctlr(get_sctlr() | CR_C);
  397. }
  398. void dcache_disable(void)
  399. {
  400. uint32_t sctlr;
  401. sctlr = get_sctlr();
  402. /* if cache isn't enabled no need to disable */
  403. if (!(sctlr & CR_C))
  404. return;
  405. set_sctlr(sctlr & ~(CR_C|CR_M));
  406. flush_dcache_all();
  407. __asm_invalidate_tlb_all();
  408. }
  409. int dcache_status(void)
  410. {
  411. return (get_sctlr() & CR_C) != 0;
  412. }
  413. u64 *__weak arch_get_page_table(void) {
  414. puts("No page table offset defined\n");
  415. return NULL;
  416. }
  417. static bool is_aligned(u64 addr, u64 size, u64 align)
  418. {
  419. return !(addr & (align - 1)) && !(size & (align - 1));
  420. }
  421. /* Use flag to indicate if attrs has more than d-cache attributes */
  422. static u64 set_one_region(u64 start, u64 size, u64 attrs, bool flag, int level)
  423. {
  424. int levelshift = level2shift(level);
  425. u64 levelsize = 1ULL << levelshift;
  426. u64 *pte = find_pte(start, level);
  427. /* Can we can just modify the current level block PTE? */
  428. if (is_aligned(start, size, levelsize)) {
  429. if (flag) {
  430. *pte &= ~PMD_ATTRMASK;
  431. *pte |= attrs & PMD_ATTRMASK;
  432. } else {
  433. *pte &= ~PMD_ATTRINDX_MASK;
  434. *pte |= attrs & PMD_ATTRINDX_MASK;
  435. }
  436. debug("Set attrs=%llx pte=%p level=%d\n", attrs, pte, level);
  437. return levelsize;
  438. }
  439. /* Unaligned or doesn't fit, maybe split block into table */
  440. debug("addr=%llx level=%d pte=%p (%llx)\n", start, level, pte, *pte);
  441. /* Maybe we need to split the block into a table */
  442. if (pte_type(pte) == PTE_TYPE_BLOCK)
  443. split_block(pte, level);
  444. /* And then double-check it became a table or already is one */
  445. if (pte_type(pte) != PTE_TYPE_TABLE)
  446. panic("PTE %p (%llx) for addr=%llx should be a table",
  447. pte, *pte, start);
  448. /* Roll on to the next page table level */
  449. return 0;
  450. }
  451. void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
  452. enum dcache_option option)
  453. {
  454. u64 attrs = PMD_ATTRINDX(option);
  455. u64 real_start = start;
  456. u64 real_size = size;
  457. debug("start=%lx size=%lx\n", (ulong)start, (ulong)size);
  458. if (!gd->arch.tlb_emerg)
  459. panic("Emergency page table not setup.");
  460. /*
  461. * We can not modify page tables that we're currently running on,
  462. * so we first need to switch to the "emergency" page tables where
  463. * we can safely modify our primary page tables and then switch back
  464. */
  465. __asm_switch_ttbr(gd->arch.tlb_emerg);
  466. /*
  467. * Loop through the address range until we find a page granule that fits
  468. * our alignment constraints, then set it to the new cache attributes
  469. */
  470. while (size > 0) {
  471. int level;
  472. u64 r;
  473. for (level = 1; level < 4; level++) {
  474. /* Set d-cache attributes only */
  475. r = set_one_region(start, size, attrs, false, level);
  476. if (r) {
  477. /* PTE successfully replaced */
  478. size -= r;
  479. start += r;
  480. break;
  481. }
  482. }
  483. }
  484. /* We're done modifying page tables, switch back to our primary ones */
  485. __asm_switch_ttbr(gd->arch.tlb_addr);
  486. /*
  487. * Make sure there's nothing stale in dcache for a region that might
  488. * have caches off now
  489. */
  490. flush_dcache_range(real_start, real_start + real_size);
  491. }
  492. /*
  493. * Modify MMU table for a region with updated PXN/UXN/Memory type/valid bits.
  494. * The procecess is break-before-make. The target region will be marked as
  495. * invalid during the process of changing.
  496. */
  497. void mmu_change_region_attr(phys_addr_t addr, size_t siz, u64 attrs)
  498. {
  499. int level;
  500. u64 r, size, start;
  501. start = addr;
  502. size = siz;
  503. /*
  504. * Loop through the address range until we find a page granule that fits
  505. * our alignment constraints, then set it to "invalid".
  506. */
  507. while (size > 0) {
  508. for (level = 1; level < 4; level++) {
  509. /* Set PTE to fault */
  510. r = set_one_region(start, size, PTE_TYPE_FAULT, true,
  511. level);
  512. if (r) {
  513. /* PTE successfully invalidated */
  514. size -= r;
  515. start += r;
  516. break;
  517. }
  518. }
  519. }
  520. flush_dcache_range(gd->arch.tlb_addr,
  521. gd->arch.tlb_addr + gd->arch.tlb_size);
  522. __asm_invalidate_tlb_all();
  523. /*
  524. * Loop through the address range until we find a page granule that fits
  525. * our alignment constraints, then set it to the new cache attributes
  526. */
  527. start = addr;
  528. size = siz;
  529. while (size > 0) {
  530. for (level = 1; level < 4; level++) {
  531. /* Set PTE to new attributes */
  532. r = set_one_region(start, size, attrs, true, level);
  533. if (r) {
  534. /* PTE successfully updated */
  535. size -= r;
  536. start += r;
  537. break;
  538. }
  539. }
  540. }
  541. flush_dcache_range(gd->arch.tlb_addr,
  542. gd->arch.tlb_addr + gd->arch.tlb_size);
  543. __asm_invalidate_tlb_all();
  544. }
  545. #else /* CONFIG_SYS_DCACHE_OFF */
  546. /*
  547. * For SPL builds, we may want to not have dcache enabled. Any real U-Boot
  548. * running however really wants to have dcache and the MMU active. Check that
  549. * everything is sane and give the developer a hint if it isn't.
  550. */
  551. #ifndef CONFIG_SPL_BUILD
  552. #error Please describe your MMU layout in CONFIG_SYS_MEM_MAP and enable dcache.
  553. #endif
  554. void invalidate_dcache_all(void)
  555. {
  556. }
  557. void flush_dcache_all(void)
  558. {
  559. }
  560. void dcache_enable(void)
  561. {
  562. }
  563. void dcache_disable(void)
  564. {
  565. }
  566. int dcache_status(void)
  567. {
  568. return 0;
  569. }
  570. void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
  571. enum dcache_option option)
  572. {
  573. }
  574. #endif /* CONFIG_SYS_DCACHE_OFF */
  575. #ifndef CONFIG_SYS_ICACHE_OFF
  576. void icache_enable(void)
  577. {
  578. invalidate_icache_all();
  579. set_sctlr(get_sctlr() | CR_I);
  580. }
  581. void icache_disable(void)
  582. {
  583. set_sctlr(get_sctlr() & ~CR_I);
  584. }
  585. int icache_status(void)
  586. {
  587. return (get_sctlr() & CR_I) != 0;
  588. }
  589. void invalidate_icache_all(void)
  590. {
  591. __asm_invalidate_icache_all();
  592. __asm_invalidate_l3_icache();
  593. }
  594. #else /* CONFIG_SYS_ICACHE_OFF */
  595. void icache_enable(void)
  596. {
  597. }
  598. void icache_disable(void)
  599. {
  600. }
  601. int icache_status(void)
  602. {
  603. return 0;
  604. }
  605. void invalidate_icache_all(void)
  606. {
  607. }
  608. #endif /* CONFIG_SYS_ICACHE_OFF */
  609. /*
  610. * Enable dCache & iCache, whether cache is actually enabled
  611. * depend on CONFIG_SYS_DCACHE_OFF and CONFIG_SYS_ICACHE_OFF
  612. */
  613. void __weak enable_caches(void)
  614. {
  615. icache_enable();
  616. dcache_enable();
  617. }