Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 1 | #ifndef __ASM_SH_CACHE_H |
| 2 | #define __ASM_SH_CACHE_H |
| 3 | |
| 4 | #if defined(CONFIG_SH4) || defined(CONFIG_SH4A) |
| 5 | |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 6 | int cache_control(unsigned int cmd); |
| 7 | |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 8 | #define L1_CACHE_BYTES 32 |
| 9 | struct __large_struct { unsigned long buf[100]; }; |
| 10 | #define __m(x) (*(struct __large_struct *)(x)) |
| 11 | |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 12 | void dcache_wback_range(u32 start, u32 end) |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 13 | { |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 14 | u32 v; |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 15 | |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 16 | start &= ~(L1_CACHE_BYTES - 1); |
| 17 | for (v = start; v < end; v += L1_CACHE_BYTES) { |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 18 | asm volatile ("ocbwb %0" : /* no output */ |
| 19 | : "m" (__m(v))); |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 20 | } |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 21 | } |
| 22 | |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 23 | void dcache_invalid_range(u32 start, u32 end) |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 24 | { |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 25 | u32 v; |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 26 | |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 27 | start &= ~(L1_CACHE_BYTES - 1); |
| 28 | for (v = start; v < end; v += L1_CACHE_BYTES) { |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 29 | asm volatile ("ocbi %0" : /* no output */ |
| 30 | : "m" (__m(v))); |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 31 | } |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 32 | } |
| 33 | #endif /* CONFIG_SH4 || CONFIG_SH4A */ |
| 34 | |
| 35 | #endif /* __ASM_SH_CACHE_H */ |