]>
Commit | Line | Data |
---|---|---|
1394f032 | 1 | /* |
96f1050d | 2 | * Blackfin low-level cache routines |
1394f032 | 3 | * |
96f1050d | 4 | * Copyright 2004-2009 Analog Devices Inc. |
1394f032 | 5 | * |
96f1050d | 6 | * Licensed under the GPL-2 or later. |
1394f032 BW |
7 | */ |
8 | ||
9 | #ifndef _BLACKFIN_CACHEFLUSH_H | |
10 | #define _BLACKFIN_CACHEFLUSH_H | |
11 | ||
5d89137a | 12 | #include <asm/blackfin.h> /* for SSYNC() */ |
bbc51e97 | 13 | #include <asm/sections.h> /* for _ramend */ |
5d89137a | 14 | |
8fb4f8f0 MF |
15 | extern void blackfin_icache_flush_range(unsigned long start_address, unsigned long end_address); |
16 | extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned long end_address); | |
17 | extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address); | |
18 | extern void blackfin_dflush_page(void *page); | |
6b3087c6 | 19 | extern void blackfin_invalidate_entire_dcache(void); |
47e9dedb | 20 | extern void blackfin_invalidate_entire_icache(void); |
1394f032 BW |
21 | |
22 | #define flush_dcache_mmap_lock(mapping) do { } while (0) | |
23 | #define flush_dcache_mmap_unlock(mapping) do { } while (0) | |
24 | #define flush_cache_mm(mm) do { } while (0) | |
25 | #define flush_cache_range(vma, start, end) do { } while (0) | |
26 | #define flush_cache_page(vma, vmaddr) do { } while (0) | |
27 | #define flush_cache_vmap(start, end) do { } while (0) | |
28 | #define flush_cache_vunmap(start, end) do { } while (0) | |
29 | ||
6b3087c6 GY |
30 | #ifdef CONFIG_SMP |
31 | #define flush_icache_range_others(start, end) \ | |
32 | smp_icache_flush_range_others((start), (end)) | |
33 | #else | |
34 | #define flush_icache_range_others(start, end) do { } while (0) | |
35 | #endif | |
36 | ||
1394f032 BW |
37 | static inline void flush_icache_range(unsigned start, unsigned end) |
38 | { | |
41ba653f | 39 | #if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK) |
5d89137a MF |
40 | blackfin_dcache_flush_range(start, end); |
41 | #endif | |
1394f032 | 42 | |
5d89137a MF |
43 | /* Make sure all write buffers in the data side of the core |
44 | * are flushed before trying to invalidate the icache. This | |
45 | * needs to be after the data flush and before the icache | |
46 | * flush so that the SSYNC does the right thing in preventing | |
47 | * the instruction prefetcher from hitting things in cached | |
48 | * memory at the wrong time -- it runs much further ahead than | |
49 | * the pipeline. | |
50 | */ | |
51 | SSYNC(); | |
52 | #if defined(CONFIG_BFIN_ICACHE) | |
53 | blackfin_icache_flush_range(start, end); | |
6b3087c6 | 54 | flush_icache_range_others(start, end); |
1394f032 BW |
55 | #endif |
56 | } | |
57 | ||
6b3087c6 GY |
58 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ |
59 | do { memcpy(dst, src, len); \ | |
60 | flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \ | |
1394f032 | 61 | } while (0) |
6b3087c6 | 62 | |
1394f032 BW |
63 | #define copy_from_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len) |
64 | ||
3bebca2d | 65 | #if defined(CONFIG_BFIN_DCACHE) |
1394f032 BW |
66 | # define invalidate_dcache_range(start,end) blackfin_dcache_invalidate_range((start), (end)) |
67 | #else | |
68 | # define invalidate_dcache_range(start,end) do { } while (0) | |
69 | #endif | |
41ba653f | 70 | #if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK) |
1394f032 | 71 | # define flush_dcache_range(start,end) blackfin_dcache_flush_range((start), (end)) |
2d4dc890 | 72 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 |
41ba653f | 73 | # define flush_dcache_page(page) blackfin_dflush_page(page_address(page)) |
1394f032 BW |
74 | #else |
75 | # define flush_dcache_range(start,end) do { } while (0) | |
2d4dc890 | 76 | #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 |
6b3087c6 | 77 | # define flush_dcache_page(page) do { } while (0) |
1394f032 BW |
78 | #endif |
79 | ||
04be80ef MF |
80 | extern unsigned long reserved_mem_dcache_on; |
81 | extern unsigned long reserved_mem_icache_on; | |
82 | ||
67834fa9 | 83 | static inline int bfin_addr_dcacheable(unsigned long addr) |
04be80ef | 84 | { |
41ba653f | 85 | #ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE |
04be80ef MF |
86 | if (addr < (_ramend - DMA_UNCACHED_REGION)) |
87 | return 1; | |
88 | #endif | |
89 | ||
90 | if (reserved_mem_dcache_on && | |
91 | addr >= _ramend && addr < physical_mem_end) | |
92 | return 1; | |
93 | ||
41ba653f | 94 | #ifdef CONFIG_BFIN_L2_DCACHEABLE |
f339f46b MF |
95 | if (addr >= L2_START && addr < L2_START + L2_LENGTH) |
96 | return 1; | |
97 | #endif | |
98 | ||
04be80ef MF |
99 | return 0; |
100 | } | |
101 | ||
3bebca2d | 102 | #endif /* _BLACKFIN_ICACHEFLUSH_H */ |