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 |
Anton Staaf | 2482e3c | 2011-10-17 16:46:07 -0700 | [diff] [blame^] | 9 | |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 10 | struct __large_struct { unsigned long buf[100]; }; |
| 11 | #define __m(x) (*(struct __large_struct *)(x)) |
| 12 | |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 13 | void dcache_wback_range(u32 start, u32 end) |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 14 | { |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 15 | u32 v; |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 16 | |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 17 | start &= ~(L1_CACHE_BYTES - 1); |
| 18 | for (v = start; v < end; v += L1_CACHE_BYTES) { |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 19 | asm volatile ("ocbwb %0" : /* no output */ |
| 20 | : "m" (__m(v))); |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 21 | } |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 22 | } |
| 23 | |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 24 | void dcache_invalid_range(u32 start, u32 end) |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 25 | { |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 26 | u32 v; |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 27 | |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 28 | start &= ~(L1_CACHE_BYTES - 1); |
| 29 | for (v = start; v < end; v += L1_CACHE_BYTES) { |
Nobuhiro Iwamatsu | b5d10a1 | 2008-09-18 19:34:36 +0900 | [diff] [blame] | 30 | asm volatile ("ocbi %0" : /* no output */ |
| 31 | : "m" (__m(v))); |
Wolfgang Denk | 1aeed8d | 2008-04-13 09:59:26 -0700 | [diff] [blame] | 32 | } |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 33 | } |
Anton Staaf | 2482e3c | 2011-10-17 16:46:07 -0700 | [diff] [blame^] | 34 | #else |
| 35 | |
| 36 | /* |
| 37 | * 32-bytes is the largest L1 data cache line size for SH the architecture. So |
| 38 | * it is a safe default for DMA alignment. |
| 39 | */ |
| 40 | #define ARCH_DMA_MINALIGN 32 |
| 41 | |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 42 | #endif /* CONFIG_SH4 || CONFIG_SH4A */ |
| 43 | |
Anton Staaf | 2482e3c | 2011-10-17 16:46:07 -0700 | [diff] [blame^] | 44 | /* |
| 45 | * Use the L1 data cache line size value for the minimum DMA buffer alignment |
| 46 | * on SH. |
| 47 | */ |
| 48 | #ifndef ARCH_DMA_MINALIGN |
| 49 | #define ARCH_DMA_MINALIGN L1_CACHE_BYTES |
| 50 | #endif |
| 51 | |
Nobuhiro Iwamatsu | e92c9518 | 2008-03-12 12:15:29 +0900 | [diff] [blame] | 52 | #endif /* __ASM_SH_CACHE_H */ |