cacheflush.h 4.3 KB
Newer Older
B
Bryan Wu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 * File:         include/asm-blackfin/cacheflush.h
 * Based on:	 include/asm-m68knommu/cacheflush.h
 * Author:       LG Soft India
 *               Copyright (C) 2004 Analog Devices Inc.
 * Created:      Tue Sep 21 2004
 * Description:  Blackfin low-level cache routines adapted from the i386
 * 		 and PPC versions by Greg Ungerer (gerg@snapgear.com)
 *
 * Modified:
 *
 * Bugs:         Enter bugs at http://blackfin.uclinux.org/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file COPYING.
 * If not, write to the Free Software Foundation,
 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _BLACKFIN_CACHEFLUSH_H
#define _BLACKFIN_CACHEFLUSH_H

33 34
#include <asm/blackfin.h>	/* for SSYNC() */

35 36 37 38
extern void blackfin_icache_flush_range(unsigned long start_address, unsigned long end_address);
extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned long end_address);
extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address);
extern void blackfin_dflush_page(void *page);
39
extern void blackfin_invalidate_entire_dcache(void);
40
extern void blackfin_invalidate_entire_icache(void);
B
Bryan Wu 已提交
41 42 43 44 45 46 47 48 49

#define flush_dcache_mmap_lock(mapping)		do { } while (0)
#define flush_dcache_mmap_unlock(mapping)	do { } while (0)
#define flush_cache_mm(mm)			do { } while (0)
#define flush_cache_range(vma, start, end)	do { } while (0)
#define flush_cache_page(vma, vmaddr)		do { } while (0)
#define flush_cache_vmap(start, end)		do { } while (0)
#define flush_cache_vunmap(start, end)		do { } while (0)

50 51 52 53 54 55 56
#ifdef CONFIG_SMP
#define flush_icache_range_others(start, end)	\
	smp_icache_flush_range_others((start), (end))
#else
#define flush_icache_range_others(start, end)	do { } while (0)
#endif

B
Bryan Wu 已提交
57 58
static inline void flush_icache_range(unsigned start, unsigned end)
{
59
#if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK)
60 61
	blackfin_dcache_flush_range(start, end);
#endif
B
Bryan Wu 已提交
62

63 64 65 66 67 68 69 70 71 72 73
	/* Make sure all write buffers in the data side of the core
	 * are flushed before trying to invalidate the icache.  This
	 * needs to be after the data flush and before the icache
	 * flush so that the SSYNC does the right thing in preventing
	 * the instruction prefetcher from hitting things in cached
	 * memory at the wrong time -- it runs much further ahead than
	 * the pipeline.
	 */
	SSYNC();
#if defined(CONFIG_BFIN_ICACHE)
	blackfin_icache_flush_range(start, end);
74
	flush_icache_range_others(start, end);
B
Bryan Wu 已提交
75 76 77
#endif
}

78 79 80
#define copy_to_user_page(vma, page, vaddr, dst, src, len)		\
do { memcpy(dst, src, len);						\
     flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len));	\
B
Bryan Wu 已提交
81
} while (0)
82

B
Bryan Wu 已提交
83 84
#define copy_from_user_page(vma, page, vaddr, dst, src, len)	memcpy(dst, src, len)

85
#if defined(CONFIG_BFIN_DCACHE)
B
Bryan Wu 已提交
86 87 88 89
# define invalidate_dcache_range(start,end)	blackfin_dcache_invalidate_range((start), (end))
#else
# define invalidate_dcache_range(start,end)	do { } while (0)
#endif
90
#if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK)
B
Bryan Wu 已提交
91
# define flush_dcache_range(start,end)		blackfin_dcache_flush_range((start), (end))
92
# define flush_dcache_page(page)		blackfin_dflush_page(page_address(page))
B
Bryan Wu 已提交
93 94
#else
# define flush_dcache_range(start,end)		do { } while (0)
95
# define flush_dcache_page(page)		do { } while (0)
B
Bryan Wu 已提交
96 97
#endif

98 99 100
extern unsigned long reserved_mem_dcache_on;
extern unsigned long reserved_mem_icache_on;

101
static inline int bfin_addr_dcacheable(unsigned long addr)
102
{
103
#ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
104 105 106 107 108 109 110 111
	if (addr < (_ramend - DMA_UNCACHED_REGION))
		return 1;
#endif

	if (reserved_mem_dcache_on &&
		addr >= _ramend && addr < physical_mem_end)
		return 1;

112
#ifdef CONFIG_BFIN_L2_DCACHEABLE
113 114 115 116
	if (addr >= L2_START && addr < L2_START + L2_LENGTH)
		return 1;
#endif

117 118 119
	return 0;
}

120
#endif				/* _BLACKFIN_ICACHEFLUSH_H */