Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #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 Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 18 | void __flush_wback_region(void *start, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | { |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 20 | unsigned long v; |
| 21 | unsigned long begin, end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 23 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 32 | void __flush_purge_region(void *start, int size) |
| 33 | { |
| 34 | unsigned long v; |
| 35 | unsigned long begin, end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 37 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 45 | void __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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | } |
| 57 | |