blob: e08cd9de6d22687d22d1cde3872efb74f3f07271 [file] [log] [blame]
Wolfgang Denk83c15852006-10-24 14:21:16 +02001/*
2 * Copyright (C) 2006 Atmel Corporation
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denk83c15852006-10-24 14:21:16 +02005 */
6#ifndef __ASM_AVR32_CACHEFLUSH_H
7#define __ASM_AVR32_CACHEFLUSH_H
8
9/*
10 * Invalidate any cacheline containing virtual address vaddr without
11 * writing anything back to memory.
12 *
13 * Note that this function may corrupt unrelated data structures when
14 * applied on buffers that are not cacheline aligned in both ends.
15 */
16static inline void dcache_invalidate_line(volatile void *vaddr)
17{
18 asm volatile("cache %0[0], 0x0b" : : "r"(vaddr) : "memory");
19}
20
21/*
22 * Make sure any cacheline containing virtual address vaddr is written
23 * to memory.
24 */
25static inline void dcache_clean_line(volatile void *vaddr)
26{
27 asm volatile("cache %0[0], 0x0c" : : "r"(vaddr) : "memory");
28}
29
30/*
31 * Make sure any cacheline containing virtual address vaddr is written
32 * to memory and then invalidate it.
33 */
34static inline void dcache_flush_line(volatile void *vaddr)
35{
36 asm volatile("cache %0[0], 0x0d" : : "r"(vaddr) : "memory");
37}
38
39/*
40 * Invalidate any instruction cacheline containing virtual address
41 * vaddr.
42 */
43static inline void icache_invalidate_line(volatile void *vaddr)
44{
45 asm volatile("cache %0[0], 0x01" : : "r"(vaddr) : "memory");
46}
47
48/*
49 * Applies the above functions on all lines that are touched by the
50 * specified virtual address range.
51 */
Wolfgang Denk83c15852006-10-24 14:21:16 +020052void dcache_clean_range(volatile void *start, size_t len);
Wolfgang Denk83c15852006-10-24 14:21:16 +020053void icache_invalidate_range(volatile void *start, size_t len);
54
55static inline void dcache_flush_unlocked(void)
56{
57 asm volatile("cache %0[5], 0x08" : : "r"(0) : "memory");
58}
59
60/*
61 * Make sure any pending writes are completed before continuing.
62 */
63#define sync_write_buffer() asm volatile("sync 0" : : : "memory")
64
65#endif /* __ASM_AVR32_CACHEFLUSH_H */