blob: 6614033f6be93133a419f262d9091536cc05492e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/sh/mm/cache-sh2.c
3 *
4 * Copyright (C) 2002 Paul Mundt
5 *
6 * Released under the terms of the GNU GPL v2.0.
7 */
Yoshinori Sato9d4436a2006-11-05 15:40:13 +09008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/init.h>
10#include <linux/mm.h>
11
12#include <asm/cache.h>
13#include <asm/addrspace.h>
14#include <asm/processor.h>
15#include <asm/cacheflush.h>
16#include <asm/io.h>
17
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090018void __flush_wback_region(void *start, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090020 unsigned long v;
21 unsigned long begin, end;
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090023 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
24 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
25 & ~(L1_CACHE_BYTES-1);
26 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
27 /* FIXME cache purge */
28 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
29 }
30}
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090032void __flush_purge_region(void *start, int size)
33{
34 unsigned long v;
35 unsigned long begin, end;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090037 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
38 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
39 & ~(L1_CACHE_BYTES-1);
40 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
41 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
42 }
43}
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090045void __flush_invalidate_region(void *start, int size)
46{
47 unsigned long v;
48 unsigned long begin, end;
49
50 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
51 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
52 & ~(L1_CACHE_BYTES-1);
53 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
54 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
55 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070056}
57