2 * Copyright (C) 2006 Atmel Corporation
4 * SPDX-License-Identifier: GPL-2.0+
6 #ifndef __ASM_AVR32_CACHEFLUSH_H
7 #define __ASM_AVR32_CACHEFLUSH_H
10 * Invalidate any cacheline containing virtual address vaddr without
11 * writing anything back to memory.
13 * Note that this function may corrupt unrelated data structures when
14 * applied on buffers that are not cacheline aligned in both ends.
16 static inline void dcache_invalidate_line(volatile void *vaddr)
18 asm volatile("cache %0[0], 0x0b" : : "r"(vaddr) : "memory");
22 * Make sure any cacheline containing virtual address vaddr is written
25 static inline void dcache_clean_line(volatile void *vaddr)
27 asm volatile("cache %0[0], 0x0c" : : "r"(vaddr) : "memory");
31 * Make sure any cacheline containing virtual address vaddr is written
32 * to memory and then invalidate it.
34 static inline void dcache_flush_line(volatile void *vaddr)
36 asm volatile("cache %0[0], 0x0d" : : "r"(vaddr) : "memory");
40 * Invalidate any instruction cacheline containing virtual address
43 static inline void icache_invalidate_line(volatile void *vaddr)
45 asm volatile("cache %0[0], 0x01" : : "r"(vaddr) : "memory");
49 * Applies the above functions on all lines that are touched by the
50 * specified virtual address range.
52 void dcache_invalidate_range(volatile void *start, size_t len);
53 void dcache_clean_range(volatile void *start, size_t len);
54 void dcache_flush_range(volatile void *start, size_t len);
55 void icache_invalidate_range(volatile void *start, size_t len);
57 static inline void dcache_flush_unlocked(void)
59 asm volatile("cache %0[5], 0x08" : : "r"(0) : "memory");
63 * Make sure any pending writes are completed before continuing.
65 #define sync_write_buffer() asm volatile("sync 0" : : : "memory")
67 #endif /* __ASM_AVR32_CACHEFLUSH_H */