1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
5 #ifndef _ASM_CACHEFLUSH_H
6 #define _ASM_CACHEFLUSH_H
9 #include <asm/cpu-info.h>
10 #include <asm/cacheops.h>
12 static inline bool cache_present(struct cache_desc *cdesc)
14 return cdesc->flags & CACHE_PRESENT;
17 static inline bool cache_private(struct cache_desc *cdesc)
19 return cdesc->flags & CACHE_PRIVATE;
22 static inline bool cache_inclusive(struct cache_desc *cdesc)
24 return cdesc->flags & CACHE_INCLUSIVE;
27 static inline unsigned int cpu_last_level_cache_line_size(void)
29 int cache_present = boot_cpu_data.cache_leaves_present;
31 return boot_cpu_data.cache_leaves[cache_present - 1].linesz;
34 asmlinkage void __flush_cache_all(void);
35 void local_flush_icache_range(unsigned long start, unsigned long end);
37 #define flush_icache_range local_flush_icache_range
38 #define flush_icache_user_range local_flush_icache_range
40 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
42 #define flush_cache_all() do { } while (0)
43 #define flush_cache_mm(mm) do { } while (0)
44 #define flush_cache_dup_mm(mm) do { } while (0)
45 #define flush_cache_range(vma, start, end) do { } while (0)
46 #define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
47 #define flush_cache_vmap(start, end) do { } while (0)
48 #define flush_cache_vunmap(start, end) do { } while (0)
49 #define flush_icache_user_page(vma, page, addr, len) do { } while (0)
50 #define flush_dcache_page(page) do { } while (0)
51 #define flush_dcache_mmap_lock(mapping) do { } while (0)
52 #define flush_dcache_mmap_unlock(mapping) do { } while (0)
54 #define cache_op(op, addr) \
55 __asm__ __volatile__( \
58 : "i" (op), "ZC" (*(unsigned char *)(addr)))
60 static inline void flush_cache_line(int leaf, unsigned long addr)
64 cache_op(Index_Writeback_Inv_LEAF0, addr);
67 cache_op(Index_Writeback_Inv_LEAF1, addr);
70 cache_op(Index_Writeback_Inv_LEAF2, addr);
73 cache_op(Index_Writeback_Inv_LEAF3, addr);
76 cache_op(Index_Writeback_Inv_LEAF4, addr);
79 cache_op(Index_Writeback_Inv_LEAF5, addr);
86 #include <asm-generic/cacheflush.h>
88 #endif /* _ASM_CACHEFLUSH_H */