1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_CACHE_H
3 #define _ASM_POWERPC_CACHE_H
8 /* bytes per L1 cache line */
9 #if defined(CONFIG_PPC_8xx)
10 #define L1_CACHE_SHIFT 4
11 #define MAX_COPY_PREFETCH 1
12 #define IFETCH_ALIGN_SHIFT 2
13 #elif defined(CONFIG_PPC_E500MC)
14 #define L1_CACHE_SHIFT 6
15 #define MAX_COPY_PREFETCH 4
16 #define IFETCH_ALIGN_SHIFT 3
17 #elif defined(CONFIG_PPC32)
18 #define MAX_COPY_PREFETCH 4
19 #define IFETCH_ALIGN_SHIFT 3 /* 603 fetches 2 insn at a time */
20 #if defined(CONFIG_PPC_47x)
21 #define L1_CACHE_SHIFT 7
23 #define L1_CACHE_SHIFT 5
25 #else /* CONFIG_PPC64 */
26 #define L1_CACHE_SHIFT 7
27 #define IFETCH_ALIGN_SHIFT 4 /* POWER8,9 */
30 #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
32 #define SMP_CACHE_BYTES L1_CACHE_BYTES
34 #define IFETCH_ALIGN_BYTES (1 << IFETCH_ALIGN_SHIFT)
36 #if !defined(__ASSEMBLY__)
39 struct ppc_cache_info
{
42 u32 block_size
; /* L1 only */
50 struct ppc_cache_info l1d
;
51 struct ppc_cache_info l1i
;
52 struct ppc_cache_info l2
;
53 struct ppc_cache_info l3
;
56 extern struct ppc64_caches ppc64_caches
;
58 static inline u32
l1_dcache_shift(void)
60 return ppc64_caches
.l1d
.log_block_size
;
63 static inline u32
l1_dcache_bytes(void)
65 return ppc64_caches
.l1d
.block_size
;
68 static inline u32
l1_icache_shift(void)
70 return ppc64_caches
.l1i
.log_block_size
;
73 static inline u32
l1_icache_bytes(void)
75 return ppc64_caches
.l1i
.block_size
;
78 static inline u32
l1_dcache_shift(void)
80 return L1_CACHE_SHIFT
;
83 static inline u32
l1_dcache_bytes(void)
85 return L1_CACHE_BYTES
;
88 static inline u32
l1_icache_shift(void)
90 return L1_CACHE_SHIFT
;
93 static inline u32
l1_icache_bytes(void)
95 return L1_CACHE_BYTES
;
100 #define __read_mostly __section(".data..read_mostly")
102 #ifdef CONFIG_PPC_BOOK3S_32
103 extern long _get_L2CR(void);
104 extern long _get_L3CR(void);
105 extern void _set_L2CR(unsigned long);
106 extern void _set_L3CR(unsigned long);
108 #define _get_L2CR() 0L
109 #define _get_L3CR() 0L
110 #define _set_L2CR(val) do { } while(0)
111 #define _set_L3CR(val) do { } while(0)
114 static inline void dcbz(void *addr
)
116 __asm__
__volatile__ ("dcbz 0, %0" : : "r"(addr
) : "memory");
119 static inline void dcbi(void *addr
)
121 __asm__
__volatile__ ("dcbi 0, %0" : : "r"(addr
) : "memory");
124 static inline void dcbf(void *addr
)
126 __asm__
__volatile__ ("dcbf 0, %0" : : "r"(addr
) : "memory");
129 static inline void dcbst(void *addr
)
131 __asm__
__volatile__ ("dcbst 0, %0" : : "r"(addr
) : "memory");
134 static inline void icbi(void *addr
)
136 asm volatile ("icbi 0, %0" : : "r"(addr
) : "memory");
139 static inline void iccci(void *addr
)
141 asm volatile ("iccci 0, %0" : : "r"(addr
) : "memory");
144 #endif /* !__ASSEMBLY__ */
145 #endif /* __KERNEL__ */
146 #endif /* _ASM_POWERPC_CACHE_H */