2 * arch/sh/mm/cache-sh2.c
4 * Copyright (C) 2002 Paul Mundt
5 * Copyright (C) 2008 Yoshinori Sato
7 * Released under the terms of the GNU GPL v2.0.
10 #include <linux/init.h>
13 #include <asm/cache.h>
14 #include <asm/addrspace.h>
15 #include <asm/processor.h>
16 #include <asm/cacheflush.h>
19 void __flush_wback_region(void *start
, int size
)
22 unsigned long begin
, end
;
24 begin
= (unsigned long)start
& ~(L1_CACHE_BYTES
-1);
25 end
= ((unsigned long)start
+ size
+ L1_CACHE_BYTES
-1)
26 & ~(L1_CACHE_BYTES
-1);
27 for (v
= begin
; v
< end
; v
+=L1_CACHE_BYTES
) {
28 unsigned long addr
= CACHE_OC_ADDRESS_ARRAY
| (v
& 0x00000ff0);
30 for (way
= 0; way
< 4; way
++) {
31 unsigned long data
= ctrl_inl(addr
| (way
<< 12));
32 if ((data
& CACHE_PHYSADDR_MASK
) == (v
& CACHE_PHYSADDR_MASK
)) {
33 data
&= ~SH_CACHE_UPDATED
;
34 ctrl_outl(data
, addr
| (way
<< 12));
40 void __flush_purge_region(void *start
, int size
)
43 unsigned long begin
, end
;
45 begin
= (unsigned long)start
& ~(L1_CACHE_BYTES
-1);
46 end
= ((unsigned long)start
+ size
+ L1_CACHE_BYTES
-1)
47 & ~(L1_CACHE_BYTES
-1);
49 for (v
= begin
; v
< end
; v
+=L1_CACHE_BYTES
)
50 ctrl_outl((v
& CACHE_PHYSADDR_MASK
),
51 CACHE_OC_ADDRESS_ARRAY
| (v
& 0x00000ff0) | 0x00000008);
54 void __flush_invalidate_region(void *start
, int size
)
56 #ifdef CONFIG_CACHE_WRITEBACK
58 * SH-2 does not support individual line invalidation, only a
63 local_irq_save(flags
);
67 ccr
|= CCR_CACHE_INVALIDATE
;
71 local_irq_restore(flags
);
74 unsigned long begin
, end
;
76 begin
= (unsigned long)start
& ~(L1_CACHE_BYTES
-1);
77 end
= ((unsigned long)start
+ size
+ L1_CACHE_BYTES
-1)
78 & ~(L1_CACHE_BYTES
-1);
80 for (v
= begin
; v
< end
; v
+=L1_CACHE_BYTES
)
81 ctrl_outl((v
& CACHE_PHYSADDR_MASK
),
82 CACHE_OC_ADDRESS_ARRAY
| (v
& 0x00000ff0) | 0x00000008);