1 /* spitfire.h: SpitFire/BlackBird/Cheetah inline MMU operations.
6 #ifndef _SPARC64_SPITFIRE_H
7 #define _SPARC64_SPITFIRE_H
13 /* The following register addresses are accessible via ASI_DMMU
14 * and ASI_IMMU, that is there is a distinct and unique copy of
15 * each these registers for each TLB.
17 #define TSB_TAG_TARGET 0x0000000000000000 /* All chips */
18 #define TLB_SFSR 0x0000000000000018 /* All chips */
19 #define TSB_REG 0x0000000000000028 /* All chips */
20 #define TLB_TAG_ACCESS 0x0000000000000030 /* All chips */
21 #define VIRT_WATCHPOINT 0x0000000000000038 /* All chips */
22 #define PHYS_WATCHPOINT 0x0000000000000040 /* All chips */
23 #define TSB_EXTENSION_P 0x0000000000000048 /* Ultra-III and later */
24 #define TSB_EXTENSION_S 0x0000000000000050 /* Ultra-III and later, D-TLB only */
25 #define TSB_EXTENSION_N 0x0000000000000058 /* Ultra-III and later */
26 #define TLB_TAG_ACCESS_EXT 0x0000000000000060 /* Ultra-III+ and later */
28 /* These registers only exist as one entity, and are accessed
31 #define PRIMARY_CONTEXT 0x0000000000000008
32 #define SECONDARY_CONTEXT 0x0000000000000010
33 #define DMMU_SFAR 0x0000000000000020
34 #define VIRT_WATCHPOINT 0x0000000000000038
35 #define PHYS_WATCHPOINT 0x0000000000000040
37 #define SPITFIRE_HIGHEST_LOCKED_TLBENT (64 - 1)
38 #define CHEETAH_HIGHEST_LOCKED_TLBENT (16 - 1)
40 #define L1DCACHE_SIZE 0x4000
42 #define SUN4V_CHIP_INVALID 0x00
43 #define SUN4V_CHIP_NIAGARA1 0x01
44 #define SUN4V_CHIP_NIAGARA2 0x02
45 #define SUN4V_CHIP_NIAGARA3 0x03
46 #define SUN4V_CHIP_NIAGARA4 0x04
47 #define SUN4V_CHIP_NIAGARA5 0x05
48 #define SUN4V_CHIP_SPARC_M6 0x06
49 #define SUN4V_CHIP_SPARC_M7 0x07
50 #define SUN4V_CHIP_SPARC64X 0x8a
51 #define SUN4V_CHIP_UNKNOWN 0xff
55 enum ultra_tlb_layout {
62 extern enum ultra_tlb_layout tlb_type;
64 extern int sun4v_chip_type;
66 extern int cheetah_pcache_forced_on;
67 void cheetah_enable_pcache(void);
69 #define sparc64_highest_locked_tlbent() \
70 (tlb_type == spitfire ? \
71 SPITFIRE_HIGHEST_LOCKED_TLBENT : \
72 CHEETAH_HIGHEST_LOCKED_TLBENT)
74 extern int num_kernel_image_mappings;
76 /* The data cache is write through, so this just invalidates the
79 static inline void spitfire_put_dcache_tag(unsigned long addr, unsigned long tag)
81 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
84 : "r" (tag), "r" (addr), "i" (ASI_DCACHE_TAG));
87 /* The instruction cache lines are flushed with this, but note that
88 * this does not flush the pipeline. It is possible for a line to
89 * get flushed but stale instructions to still be in the pipeline,
90 * a flush instruction (to any address) is sufficient to handle
91 * this issue after the line is invalidated.
93 static inline void spitfire_put_icache_tag(unsigned long addr, unsigned long tag)
95 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
98 : "r" (tag), "r" (addr), "i" (ASI_IC_TAG));
101 static inline unsigned long spitfire_get_dtlb_data(int entry)
105 __asm__ __volatile__("ldxa [%1] %2, %0"
107 : "r" (entry << 3), "i" (ASI_DTLB_DATA_ACCESS));
109 /* Clear TTE diag bits. */
110 data &= ~0x0003fe0000000000UL;
115 static inline unsigned long spitfire_get_dtlb_tag(int entry)
119 __asm__ __volatile__("ldxa [%1] %2, %0"
121 : "r" (entry << 3), "i" (ASI_DTLB_TAG_READ));
125 static inline void spitfire_put_dtlb_data(int entry, unsigned long data)
127 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
130 : "r" (data), "r" (entry << 3),
131 "i" (ASI_DTLB_DATA_ACCESS));
134 static inline unsigned long spitfire_get_itlb_data(int entry)
138 __asm__ __volatile__("ldxa [%1] %2, %0"
140 : "r" (entry << 3), "i" (ASI_ITLB_DATA_ACCESS));
142 /* Clear TTE diag bits. */
143 data &= ~0x0003fe0000000000UL;
148 static inline unsigned long spitfire_get_itlb_tag(int entry)
152 __asm__ __volatile__("ldxa [%1] %2, %0"
154 : "r" (entry << 3), "i" (ASI_ITLB_TAG_READ));
158 static inline void spitfire_put_itlb_data(int entry, unsigned long data)
160 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
163 : "r" (data), "r" (entry << 3),
164 "i" (ASI_ITLB_DATA_ACCESS));
167 static inline void spitfire_flush_dtlb_nucleus_page(unsigned long page)
169 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
172 : "r" (page | 0x20), "i" (ASI_DMMU_DEMAP));
175 static inline void spitfire_flush_itlb_nucleus_page(unsigned long page)
177 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
180 : "r" (page | 0x20), "i" (ASI_IMMU_DEMAP));
183 /* Cheetah has "all non-locked" tlb flushes. */
184 static inline void cheetah_flush_dtlb_all(void)
186 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
189 : "r" (0x80), "i" (ASI_DMMU_DEMAP));
192 static inline void cheetah_flush_itlb_all(void)
194 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
197 : "r" (0x80), "i" (ASI_IMMU_DEMAP));
200 /* Cheetah has a 4-tlb layout so direct access is a bit different.
201 * The first two TLBs are fully assosciative, hold 16 entries, and are
202 * used only for locked and >8K sized translations. One exists for
203 * data accesses and one for instruction accesses.
205 * The third TLB is for data accesses to 8K non-locked translations, is
206 * 2 way assosciative, and holds 512 entries. The fourth TLB is for
207 * instruction accesses to 8K non-locked translations, is 2 way
208 * assosciative, and holds 128 entries.
210 * Cheetah has some bug where bogus data can be returned from
211 * ASI_{D,I}TLB_DATA_ACCESS loads, doing the load twice fixes
212 * the problem for me. -DaveM
214 static inline unsigned long cheetah_get_ldtlb_data(int entry)
218 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
221 : "r" ((0 << 16) | (entry << 3)),
222 "i" (ASI_DTLB_DATA_ACCESS));
227 static inline unsigned long cheetah_get_litlb_data(int entry)
231 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
234 : "r" ((0 << 16) | (entry << 3)),
235 "i" (ASI_ITLB_DATA_ACCESS));
240 static inline unsigned long cheetah_get_ldtlb_tag(int entry)
244 __asm__ __volatile__("ldxa [%1] %2, %0"
246 : "r" ((0 << 16) | (entry << 3)),
247 "i" (ASI_DTLB_TAG_READ));
252 static inline unsigned long cheetah_get_litlb_tag(int entry)
256 __asm__ __volatile__("ldxa [%1] %2, %0"
258 : "r" ((0 << 16) | (entry << 3)),
259 "i" (ASI_ITLB_TAG_READ));
264 static inline void cheetah_put_ldtlb_data(int entry, unsigned long data)
266 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
270 "r" ((0 << 16) | (entry << 3)),
271 "i" (ASI_DTLB_DATA_ACCESS));
274 static inline void cheetah_put_litlb_data(int entry, unsigned long data)
276 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
280 "r" ((0 << 16) | (entry << 3)),
281 "i" (ASI_ITLB_DATA_ACCESS));
284 static inline unsigned long cheetah_get_dtlb_data(int entry, int tlb)
288 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
291 : "r" ((tlb << 16) | (entry << 3)), "i" (ASI_DTLB_DATA_ACCESS));
296 static inline unsigned long cheetah_get_dtlb_tag(int entry, int tlb)
300 __asm__ __volatile__("ldxa [%1] %2, %0"
302 : "r" ((tlb << 16) | (entry << 3)), "i" (ASI_DTLB_TAG_READ));
306 static inline void cheetah_put_dtlb_data(int entry, unsigned long data, int tlb)
308 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
312 "r" ((tlb << 16) | (entry << 3)),
313 "i" (ASI_DTLB_DATA_ACCESS));
316 static inline unsigned long cheetah_get_itlb_data(int entry)
320 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
323 : "r" ((2 << 16) | (entry << 3)),
324 "i" (ASI_ITLB_DATA_ACCESS));
329 static inline unsigned long cheetah_get_itlb_tag(int entry)
333 __asm__ __volatile__("ldxa [%1] %2, %0"
335 : "r" ((2 << 16) | (entry << 3)), "i" (ASI_ITLB_TAG_READ));
339 static inline void cheetah_put_itlb_data(int entry, unsigned long data)
341 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
344 : "r" (data), "r" ((2 << 16) | (entry << 3)),
345 "i" (ASI_ITLB_DATA_ACCESS));
348 #endif /* !(__ASSEMBLY__) */
349 #endif /* CONFIG_SPARC64 */
350 #endif /* !(_SPARC64_SPITFIRE_H) */