]> Pileus Git - ~andy/linux/blob - arch/arc/include/asm/cache.h
2fe8e41a551c1d01fcbe2f3791bb5e4b608f09bb
[~andy/linux] / arch / arc / include / asm / cache.h
1 /*
2  * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8
9 #ifndef __ARC_ASM_CACHE_H
10 #define __ARC_ASM_CACHE_H
11
12 #include <asm/mmu.h>    /* some of cache registers depend on MMU ver */
13
14 /* In case $$ not config, setup a dummy number for rest of kernel */
15 #ifndef CONFIG_ARC_CACHE_LINE_SHIFT
16 #define L1_CACHE_SHIFT          6
17 #else
18 #define L1_CACHE_SHIFT          CONFIG_ARC_CACHE_LINE_SHIFT
19 #endif
20
21 #define L1_CACHE_BYTES          (1 << L1_CACHE_SHIFT)
22
23 #define ARC_ICACHE_WAYS 2
24 #define ARC_DCACHE_WAYS 4
25
26 /* Helpers */
27 #define ARC_ICACHE_LINE_LEN     L1_CACHE_BYTES
28 #define ARC_DCACHE_LINE_LEN     L1_CACHE_BYTES
29
30 #define ICACHE_LINE_MASK        (~(ARC_ICACHE_LINE_LEN - 1))
31 #define DCACHE_LINE_MASK        (~(ARC_DCACHE_LINE_LEN - 1))
32
33 #if ARC_ICACHE_LINE_LEN != ARC_DCACHE_LINE_LEN
34 #error "Need to fix some code as I/D cache lines not same"
35 #else
36 #define is_not_cache_aligned(p) ((unsigned long)p & (~DCACHE_LINE_MASK))
37 #endif
38
39 #ifndef __ASSEMBLY__
40
41 /* Uncached access macros */
42 #define arc_read_uncached_32(ptr)       \
43 ({                                      \
44         unsigned int __ret;             \
45         __asm__ __volatile__(           \
46         "       ld.di %0, [%1]  \n"     \
47         : "=r"(__ret)                   \
48         : "r"(ptr));                    \
49         __ret;                          \
50 })
51
52 #define arc_write_uncached_32(ptr, data)\
53 ({                                      \
54         __asm__ __volatile__(           \
55         "       st.di %0, [%1]  \n"     \
56         :                               \
57         : "r"(data), "r"(ptr));         \
58 })
59
60 #define ARCH_DMA_MINALIGN      L1_CACHE_BYTES
61
62 /*
63  * ARC700 doesn't cache any access in top 256M.
64  * Ideal for wiring memory mapped peripherals as we don't need to do
65  * explicit uncached accesses (LD.di/ST.di) hence more portable drivers
66  */
67 #define ARC_UNCACHED_ADDR_SPACE 0xc0000000
68
69 extern void arc_cache_init(void);
70 extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
71 extern void __init read_decode_cache_bcr(void);
72 #endif
73
74 #endif /* _ASM_CACHE_H */