cache.c revision 2b4315185a06414c4ab40fb0db50dce1b534a1d9
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
20dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt * arch/sh/mm/pg-mmu.c
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 1999, 2000, 2002  Niibe Yutaka
5dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt * Copyright (C) 2002 - 2009  Paul Mundt
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Released under the terms of the GNU GPL v2.0.
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/mm.h>
10acca4f4d9bd657e8bc7e1665ba5077465138f133Paul Mundt#include <linux/init.h>
1152e27782e1c4afa1feca0fdf194d279595e0431cPaul Mundt#include <linux/mutex.h>
12e06c4e5775b1efc4e476f2430439e45867775f5fPaul Mundt#include <linux/fs.h>
137747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt#include <linux/highmem.h>
147747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt#include <linux/module.h>
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/mmu_context.h>
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/cacheflush.h>
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1837443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_cache_all)(void);
1937443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_cache_mm)(struct mm_struct *mm);
2037443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_cache_dup_mm)(struct mm_struct *mm);
2137443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_cache_page)(struct vm_area_struct *vma,
2237443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt				unsigned long addr, unsigned long pfn);
2337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_cache_range)(struct vm_area_struct *vma,
2437443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt				 unsigned long start, unsigned long end);
2537443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_dcache_page)(struct page *page);
2637443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_icache_range)(unsigned long start, unsigned long end);
2737443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_icache_page)(struct vm_area_struct *vma,
2837443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt				 struct page *page);
2937443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*flush_cache_sigtramp)(unsigned long address);
3037443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*__flush_wback_region)(void *start, int size);
3137443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*__flush_purge_region)(void *start, int size);
3237443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtvoid (*__flush_invalidate_region)(void *start, int size);
3337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
3437443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_cache_all(void)
3537443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
3637443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
3737443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
3837443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_cache_mm(struct mm_struct *mm)
3937443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
4037443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
4137443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
4237443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_cache_page(struct vm_area_struct *vma,
4337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt				unsigned long addr, unsigned long pfn)
4437443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
4537443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
4637443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
4737443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_cache_range(struct vm_area_struct *vma,
4837443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt				 unsigned long start, unsigned long end)
4937443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
5037443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
5137443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
5237443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_dcache_page(struct page *page)
5337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
5437443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
5537443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
5637443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_icache_range(unsigned long start,
5737443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt					   unsigned long end)
5837443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
5937443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
6037443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
6137443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_icache_page(struct vm_area_struct *vma,
6237443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt					  struct page *page)
6337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
6437443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
6537443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
6637443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop_flush_cache_sigtramp(unsigned long address)
6737443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
6837443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
6937443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
7037443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundtstatic inline void noop__flush_region(void *start, int size)
7137443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt{
7237443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt}
7337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
74ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundtvoid copy_to_user_page(struct vm_area_struct *vma, struct page *page,
75ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt		       unsigned long vaddr, void *dst, const void *src,
76ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt		       unsigned long len)
771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
780dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt	if (boot_cpu_data.dcache.n_aliases && page_mapped(page) &&
790dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt	    !test_bit(PG_dcache_dirty, &page->flags)) {
802277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
812277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		memcpy(vto, src, len);
82b5eb10ae901fa797c19accb684825f0e36ecbe0fPaul Mundt		kunmap_coherent();
832277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt	} else {
842277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		memcpy(dst, src, len);
850dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt		if (boot_cpu_data.dcache.n_aliases)
860dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt			set_bit(PG_dcache_dirty, &page->flags);
872277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt	}
88ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt
89ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt	if (vma->vm_flags & VM_EXEC)
90ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt		flush_cache_page(vma, vaddr, page_to_pfn(page));
91ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt}
92ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt
93ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundtvoid copy_from_user_page(struct vm_area_struct *vma, struct page *page,
94ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt			 unsigned long vaddr, void *dst, const void *src,
95ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt			 unsigned long len)
96ba1789efea81acc6633f427bfeb871fd608965b5Paul Mundt{
970dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt	if (boot_cpu_data.dcache.n_aliases && page_mapped(page) &&
980dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt	    !test_bit(PG_dcache_dirty, &page->flags)) {
992277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
1002277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		memcpy(dst, vfrom, len);
101b5eb10ae901fa797c19accb684825f0e36ecbe0fPaul Mundt		kunmap_coherent();
1022277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt	} else {
1032277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		memcpy(dst, src, len);
1040dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt		if (boot_cpu_data.dcache.n_aliases)
1050dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt			set_bit(PG_dcache_dirty, &page->flags);
1062277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt	}
1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
10839e688a94b94eaba768b1494e19e96f828fc2688Paul Mundt
1097747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundtvoid copy_user_highpage(struct page *to, struct page *from,
1107747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt			unsigned long vaddr, struct vm_area_struct *vma)
1117747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt{
1127747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt	void *vfrom, *vto;
1137747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt
1147747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt	vto = kmap_atomic(to, KM_USER1);
1157747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt
1160dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt	if (boot_cpu_data.dcache.n_aliases && page_mapped(from) &&
1170dfae7d5a21901b28ec0452d71be64adf5ea323ePaul Mundt	    !test_bit(PG_dcache_dirty, &from->flags)) {
1182277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		vfrom = kmap_coherent(from, vaddr);
1192277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		copy_page(vto, vfrom);
120b5eb10ae901fa797c19accb684825f0e36ecbe0fPaul Mundt		kunmap_coherent();
1212277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt	} else {
1222277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		vfrom = kmap_atomic(from, KM_USER0);
1232277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		copy_page(vto, vfrom);
1242277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt		kunmap_atomic(vfrom, KM_USER0);
1252277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt	}
1262277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt
1272277ab4a1df50e05bc732fe9488d4e902bb8399aPaul Mundt	if (pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK))
1287747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt		__flush_wback_region(vto, PAGE_SIZE);
1297747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt
1307747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt	kunmap_atomic(vto, KM_USER1);
1317747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt	/* Make sure this page is cleared on other CPU's too before using it */
1327747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt	smp_wmb();
1337747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul Mundt}
1347747b9a493a197cb4db44c98d25ce6d3d9f586d1Paul MundtEXPORT_SYMBOL(copy_user_highpage);
135dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt
136dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundtvoid clear_user_highpage(struct page *page, unsigned long vaddr)
137dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt{
138dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt	void *kaddr = kmap_atomic(page, KM_USER0);
139dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt
140dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt	clear_page(kaddr);
141dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt
142dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt	if (pages_do_alias((unsigned long)kaddr, vaddr & PAGE_MASK))
143dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt		__flush_wback_region(kaddr, PAGE_SIZE);
144dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt
145dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt	kunmap_atomic(kaddr, KM_USER0);
146dfff0fa65ab15db45acd64b3189787d37ab163cdPaul Mundt}
147dfff0fa65ab15db45acd64b3189787d37ab163cdPaul MundtEXPORT_SYMBOL(clear_user_highpage);
1489cef7492696a416663b4edb953a4eade8517ebebPaul Mundt
1499cef7492696a416663b4edb953a4eade8517ebebPaul Mundtvoid __update_cache(struct vm_area_struct *vma,
1509cef7492696a416663b4edb953a4eade8517ebebPaul Mundt		    unsigned long address, pte_t pte)
1519cef7492696a416663b4edb953a4eade8517ebebPaul Mundt{
1529cef7492696a416663b4edb953a4eade8517ebebPaul Mundt	struct page *page;
1539cef7492696a416663b4edb953a4eade8517ebebPaul Mundt	unsigned long pfn = pte_pfn(pte);
1549cef7492696a416663b4edb953a4eade8517ebebPaul Mundt
1559cef7492696a416663b4edb953a4eade8517ebebPaul Mundt	if (!boot_cpu_data.dcache.n_aliases)
1569cef7492696a416663b4edb953a4eade8517ebebPaul Mundt		return;
1579cef7492696a416663b4edb953a4eade8517ebebPaul Mundt
1589cef7492696a416663b4edb953a4eade8517ebebPaul Mundt	page = pfn_to_page(pfn);
1599cef7492696a416663b4edb953a4eade8517ebebPaul Mundt	if (pfn_valid(pfn) && page_mapping(page)) {
1609cef7492696a416663b4edb953a4eade8517ebebPaul Mundt		int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags);
1619cef7492696a416663b4edb953a4eade8517ebebPaul Mundt		if (dirty) {
1629cef7492696a416663b4edb953a4eade8517ebebPaul Mundt			unsigned long addr = (unsigned long)page_address(page);
1639cef7492696a416663b4edb953a4eade8517ebebPaul Mundt
1649cef7492696a416663b4edb953a4eade8517ebebPaul Mundt			if (pages_do_alias(addr, address & PAGE_MASK))
1659cef7492696a416663b4edb953a4eade8517ebebPaul Mundt				__flush_wback_region((void *)addr, PAGE_SIZE);
1669cef7492696a416663b4edb953a4eade8517ebebPaul Mundt		}
1679cef7492696a416663b4edb953a4eade8517ebebPaul Mundt	}
1689cef7492696a416663b4edb953a4eade8517ebebPaul Mundt}
169c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt
170c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundtvoid __flush_anon_page(struct page *page, unsigned long vmaddr)
171c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt{
172c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt	unsigned long addr = (unsigned long) page_address(page);
173c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt
174c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt	if (pages_do_alias(addr, vmaddr)) {
175c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt		if (boot_cpu_data.dcache.n_aliases && page_mapped(page) &&
176c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt		    !test_bit(PG_dcache_dirty, &page->flags)) {
177c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt			void *kaddr;
178c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt
179c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt			kaddr = kmap_coherent(page, vmaddr);
180c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt			__flush_wback_region((void *)kaddr, PAGE_SIZE);
181c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt			kunmap_coherent();
182c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt		} else
183c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt			__flush_wback_region((void *)addr, PAGE_SIZE);
184c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt	}
185c0fe478dbb14fd32e71d1383dbe302b54ce94134Paul Mundt}
186ecba1060583635ab55092072441ff903b5e9a659Paul Mundt
18727d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundtstatic void compute_alias(struct cache_info *c)
18827d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt{
18927d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	c->alias_mask = ((c->sets - 1) << c->entry_shift) & ~(PAGE_SIZE - 1);
19027d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	c->n_aliases = c->alias_mask ? (c->alias_mask >> PAGE_SHIFT) + 1 : 0;
19127d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt}
19227d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt
19327d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundtstatic void __init emit_cache_params(void)
19427d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt{
19527d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	printk(KERN_NOTICE "I-cache : n_ways=%d n_sets=%d way_incr=%d\n",
19627d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.icache.ways,
19727d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.icache.sets,
19827d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.icache.way_incr);
19927d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	printk(KERN_NOTICE "I-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
20027d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.icache.entry_mask,
20127d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.icache.alias_mask,
20227d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.icache.n_aliases);
20327d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	printk(KERN_NOTICE "D-cache : n_ways=%d n_sets=%d way_incr=%d\n",
20427d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.dcache.ways,
20527d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.dcache.sets,
20627d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.dcache.way_incr);
20727d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	printk(KERN_NOTICE "D-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
20827d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.dcache.entry_mask,
20927d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.dcache.alias_mask,
21027d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		boot_cpu_data.dcache.n_aliases);
21127d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt
21227d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	/*
21327d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	 * Emit Secondary Cache parameters if the CPU has a probed L2.
21427d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	 */
21527d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	if (boot_cpu_data.flags & CPU_HAS_L2_CACHE) {
21627d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		printk(KERN_NOTICE "S-cache : n_ways=%d n_sets=%d way_incr=%d\n",
21727d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt			boot_cpu_data.scache.ways,
21827d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt			boot_cpu_data.scache.sets,
21927d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt			boot_cpu_data.scache.way_incr);
22027d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt		printk(KERN_NOTICE "S-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
22127d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt			boot_cpu_data.scache.entry_mask,
22227d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt			boot_cpu_data.scache.alias_mask,
22327d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt			boot_cpu_data.scache.n_aliases);
22427d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	}
22527d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt}
22627d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt
227ecba1060583635ab55092072441ff903b5e9a659Paul Mundtvoid __init cpu_cache_init(void)
228ecba1060583635ab55092072441ff903b5e9a659Paul Mundt{
22927d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	compute_alias(&boot_cpu_data.icache);
23027d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	compute_alias(&boot_cpu_data.dcache);
23127d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	compute_alias(&boot_cpu_data.scache);
23227d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt
23337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_cache_all		= noop_flush_cache_all;
23437443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_cache_mm		= noop_flush_cache_mm;
23537443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_cache_dup_mm	= noop_flush_cache_mm;
23637443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_cache_page	= noop_flush_cache_page;
23737443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_cache_range	= noop_flush_cache_range;
23837443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_dcache_page	= noop_flush_dcache_page;
23937443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_icache_range	= noop_flush_icache_range;
24037443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_icache_page	= noop_flush_icache_page;
24137443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	flush_cache_sigtramp	= noop_flush_cache_sigtramp;
24237443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
24337443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	__flush_wback_region		= noop__flush_region;
24437443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	__flush_purge_region		= noop__flush_region;
24537443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt	__flush_invalidate_region	= noop__flush_region;
24637443ef3f0406e855e169c87ae3f4ffb4b6ff635Paul Mundt
247109b44a82a7a8ae32d7fb257480f92f2d96f0dafPaul Mundt	if (boot_cpu_data.family == CPU_FAMILY_SH2) {
248109b44a82a7a8ae32d7fb257480f92f2d96f0dafPaul Mundt		extern void __weak sh2_cache_init(void);
249109b44a82a7a8ae32d7fb257480f92f2d96f0dafPaul Mundt
250109b44a82a7a8ae32d7fb257480f92f2d96f0dafPaul Mundt		sh2_cache_init();
251109b44a82a7a8ae32d7fb257480f92f2d96f0dafPaul Mundt	}
252109b44a82a7a8ae32d7fb257480f92f2d96f0dafPaul Mundt
253a58e1a2ab4f6334c50dfbda83d3a5c6e0b2b4beePaul Mundt	if (boot_cpu_data.family == CPU_FAMILY_SH2A) {
254a58e1a2ab4f6334c50dfbda83d3a5c6e0b2b4beePaul Mundt		extern void __weak sh2a_cache_init(void);
255a58e1a2ab4f6334c50dfbda83d3a5c6e0b2b4beePaul Mundt
256a58e1a2ab4f6334c50dfbda83d3a5c6e0b2b4beePaul Mundt		sh2a_cache_init();
257a58e1a2ab4f6334c50dfbda83d3a5c6e0b2b4beePaul Mundt	}
258a58e1a2ab4f6334c50dfbda83d3a5c6e0b2b4beePaul Mundt
25979f1c9da5e5fc5f4705836d8c1cee2213fc80640Paul Mundt	if (boot_cpu_data.family == CPU_FAMILY_SH3) {
26079f1c9da5e5fc5f4705836d8c1cee2213fc80640Paul Mundt		extern void __weak sh3_cache_init(void);
26179f1c9da5e5fc5f4705836d8c1cee2213fc80640Paul Mundt
26279f1c9da5e5fc5f4705836d8c1cee2213fc80640Paul Mundt		sh3_cache_init();
2630d051d90bb08b516b9d6c30d25f83d3c6b5b1c1dPaul Mundt
2640d051d90bb08b516b9d6c30d25f83d3c6b5b1c1dPaul Mundt		if ((boot_cpu_data.type == CPU_SH7705) &&
2650d051d90bb08b516b9d6c30d25f83d3c6b5b1c1dPaul Mundt		    (boot_cpu_data.dcache.sets == 512)) {
2660d051d90bb08b516b9d6c30d25f83d3c6b5b1c1dPaul Mundt			extern void __weak sh7705_cache_init(void);
2670d051d90bb08b516b9d6c30d25f83d3c6b5b1c1dPaul Mundt
2680d051d90bb08b516b9d6c30d25f83d3c6b5b1c1dPaul Mundt			sh7705_cache_init();
2690d051d90bb08b516b9d6c30d25f83d3c6b5b1c1dPaul Mundt		}
27079f1c9da5e5fc5f4705836d8c1cee2213fc80640Paul Mundt	}
27179f1c9da5e5fc5f4705836d8c1cee2213fc80640Paul Mundt
272ecba1060583635ab55092072441ff903b5e9a659Paul Mundt	if ((boot_cpu_data.family == CPU_FAMILY_SH4) ||
273ecba1060583635ab55092072441ff903b5e9a659Paul Mundt	    (boot_cpu_data.family == CPU_FAMILY_SH4A) ||
274ecba1060583635ab55092072441ff903b5e9a659Paul Mundt	    (boot_cpu_data.family == CPU_FAMILY_SH4AL_DSP)) {
275ecba1060583635ab55092072441ff903b5e9a659Paul Mundt		extern void __weak sh4_cache_init(void);
276ecba1060583635ab55092072441ff903b5e9a659Paul Mundt
277ecba1060583635ab55092072441ff903b5e9a659Paul Mundt		sh4_cache_init();
278ecba1060583635ab55092072441ff903b5e9a659Paul Mundt	}
27927d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt
2802b4315185a06414c4ab40fb0db50dce1b534a1d9Paul Mundt	if (boot_cpu_data.family == CPU_FAMILY_SH5) {
2812b4315185a06414c4ab40fb0db50dce1b534a1d9Paul Mundt		extern void __weak sh5_cache_init(void);
2822b4315185a06414c4ab40fb0db50dce1b534a1d9Paul Mundt
2832b4315185a06414c4ab40fb0db50dce1b534a1d9Paul Mundt		sh5_cache_init();
2842b4315185a06414c4ab40fb0db50dce1b534a1d9Paul Mundt	}
2852b4315185a06414c4ab40fb0db50dce1b534a1d9Paul Mundt
28627d59ec1709817a90aa3ab7169f60994a89ad2f5Paul Mundt	emit_cache_params();
287ecba1060583635ab55092072441ff903b5e9a659Paul Mundt}
288