blob: 6ffab4d37448d56fd6789216bb7addbe3ac18e4c [file] [log] [blame]
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +09001#ifndef __ASM_SH_CACHE_H
2#define __ASM_SH_CACHE_H
3
4#if defined(CONFIG_SH4) || defined(CONFIG_SH4A)
5
Nobuhiro Iwamatsub5d10a12008-09-18 19:34:36 +09006int cache_control(unsigned int cmd);
7
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +09008#define L1_CACHE_BYTES 32
Anton Staaf2482e3c2011-10-17 16:46:07 -07009
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +090010struct __large_struct { unsigned long buf[100]; };
11#define __m(x) (*(struct __large_struct *)(x))
12
Nobuhiro Iwamatsub5d10a12008-09-18 19:34:36 +090013void dcache_wback_range(u32 start, u32 end)
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +090014{
Wolfgang Denk1aeed8d2008-04-13 09:59:26 -070015 u32 v;
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +090016
Wolfgang Denk1aeed8d2008-04-13 09:59:26 -070017 start &= ~(L1_CACHE_BYTES - 1);
18 for (v = start; v < end; v += L1_CACHE_BYTES) {
Nobuhiro Iwamatsub5d10a12008-09-18 19:34:36 +090019 asm volatile ("ocbwb %0" : /* no output */
20 : "m" (__m(v)));
Wolfgang Denk1aeed8d2008-04-13 09:59:26 -070021 }
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +090022}
23
Nobuhiro Iwamatsub5d10a12008-09-18 19:34:36 +090024void dcache_invalid_range(u32 start, u32 end)
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +090025{
Wolfgang Denk1aeed8d2008-04-13 09:59:26 -070026 u32 v;
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +090027
Wolfgang Denk1aeed8d2008-04-13 09:59:26 -070028 start &= ~(L1_CACHE_BYTES - 1);
29 for (v = start; v < end; v += L1_CACHE_BYTES) {
Nobuhiro Iwamatsub5d10a12008-09-18 19:34:36 +090030 asm volatile ("ocbi %0" : /* no output */
31 : "m" (__m(v)));
Wolfgang Denk1aeed8d2008-04-13 09:59:26 -070032 }
Nobuhiro Iwamatsue92c95182008-03-12 12:15:29 +090033}
Anton Staaf2482e3c2011-10-17 16:46:07 -070034#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 Iwamatsue92c95182008-03-12 12:15:29 +090042#endif /* CONFIG_SH4 || CONFIG_SH4A */
43
Anton Staaf2482e3c2011-10-17 16:46:07 -070044/*
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 Iwamatsue92c95182008-03-12 12:15:29 +090052#endif /* __ASM_SH_CACHE_H */