xref: /dragonfly/sys/dev/agp/agpreg.h (revision cfd1aba3)
1 /*-
2  * Copyright (c) 2000 Doug Rabson
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  *	$FreeBSD: src/sys/pci/agpreg.h,v 1.19 2007/07/13 16:28:12 anholt Exp $
27  *	$DragonFly: src/sys/dev/agp/agpreg.h,v 1.7 2008/10/03 08:56:58 hasso Exp $
28  */
29 
30 #ifndef _PCI_AGPREG_H_
31 #define _PCI_AGPREG_H_
32 
33 /*
34  * Offsets for various AGP configuration registers.
35  */
36 #define AGP_APBASE		0x10
37 #define AGP_CAPPTR		0x34
38 
39 /*
40  * Offsets from the AGP Capability pointer.
41  */
42 #define AGP_CAPID		0x0
43 #define AGP_CAPID_GET_MAJOR(x)		(((x) & 0x00f00000U) >> 20)
44 #define AGP_CAPID_GET_MINOR(x)		(((x) & 0x000f0000U) >> 16)
45 #define AGP_CAPID_GET_NEXT_PTR(x)	(((x) & 0x0000ff00U) >> 8)
46 #define AGP_CAPID_GET_CAP_ID(x)		(((x) & 0x000000ffU) >> 0)
47 
48 #define AGP_STATUS		0x4
49 #define AGP_COMMAND		0x8
50 #define AGP_STATUS_AGP3		0x0008
51 #define AGP_STATUS_RQ_MASK	0xff000000
52 #define AGP_COMMAND_RQ_MASK	0xff000000
53 #define AGP_STATUS_ARQSZ_MASK	0xe000
54 #define AGP_COMMAND_ARQSZ_MASK	0xe000
55 #define AGP_STATUS_CAL_MASK	0x1c00
56 #define AGP_COMMAND_CAL_MASK	0x1c00
57 #define AGP_STATUS_ISOCH	0x10000
58 #define AGP_STATUS_SBA		0x0200
59 #define AGP_STATUS_ITA_COH	0x0100
60 #define AGP_STATUS_GART64	0x0080
61 #define AGP_STATUS_HTRANS	0x0040
62 #define AGP_STATUS_64BIT	0x0020
63 #define AGP_STATUS_FW		0x0010
64 #define AGP_COMMAND_RQ_MASK 	0xff000000
65 #define AGP_COMMAND_ARQSZ_MASK	0xe000
66 #define AGP_COMMAND_CAL_MASK	0x1c00
67 #define AGP_COMMAND_SBA		0x0200
68 #define AGP_COMMAND_AGP		0x0100
69 #define AGP_COMMAND_GART64	0x0080
70 #define AGP_COMMAND_64BIT	0x0020
71 #define AGP_COMMAND_FW		0x0010
72 
73 /*
74  * Config offsets for Intel AGP chipsets.
75  */
76 #define AGP_INTEL_NBXCFG	0x50
77 #define AGP_INTEL_ERRSTS	0x91
78 #define AGP_INTEL_AGPCTRL	0xb0
79 #define AGP_INTEL_APSIZE	0xb4
80 #define AGP_INTEL_ATTBASE	0xb8
81 
82 /*
83  * Config offsets for Intel i8xx/E7xxx AGP chipsets.
84  */
85 #define AGP_INTEL_MCHCFG	0x50
86 #define AGP_INTEL_I820_RDCR	0x51
87 #define AGP_INTEL_I845_AGPM	0x51
88 #define AGP_INTEL_I8XX_ERRSTS	0xc8
89 
90 /*
91  * Config offsets for VIA AGP 2.x chipsets.
92  */
93 #define AGP_VIA_GARTCTRL	0x80
94 #define AGP_VIA_APSIZE		0x84
95 #define AGP_VIA_ATTBASE		0x88
96 
97 /*
98  * Config offsets for VIA AGP 3.0 chipsets.
99  */
100 #define AGP3_VIA_GARTCTRL        0x90
101 #define AGP3_VIA_APSIZE          0x94
102 #define AGP3_VIA_ATTBASE         0x98
103 #define AGP_VIA_AGPSEL		 0xfd
104 
105 /*
106  * Config offsets for SiS AGP chipsets.
107  */
108 #define AGP_SIS_ATTBASE		0x90
109 #define AGP_SIS_WINCTRL		0x94
110 #define AGP_SIS_TLBCTRL		0x97
111 #define AGP_SIS_TLBFLUSH	0x98
112 
113 /*
114  * Config offsets for Ali AGP chipsets.
115  */
116 #define AGP_ALI_AGPCTRL		0xb8
117 #define AGP_ALI_ATTBASE		0xbc
118 #define AGP_ALI_TLBCTRL		0xc0
119 
120 /*
121  * Config offsets for the AMD 751 chipset.
122  */
123 #define AGP_AMD751_APBASE	0x10
124 #define AGP_AMD751_REGISTERS	0x14
125 #define AGP_AMD751_APCTRL	0xac
126 #define AGP_AMD751_MODECTRL	0xb0
127 #define AGP_AMD751_MODECTRL_SYNEN	0x80
128 #define AGP_AMD751_MODECTRL2	0xb2
129 #define AGP_AMD751_MODECTRL2_G1LM	0x01
130 #define AGP_AMD751_MODECTRL2_GPDCE	0x02
131 #define AGP_AMD751_MODECTRL2_NGSE	0x08
132 
133 /*
134  * Memory mapped register offsets for AMD 751 chipset.
135  */
136 #define AGP_AMD751_CAPS		0x00
137 #define AGP_AMD751_CAPS_EHI		0x0800
138 #define AGP_AMD751_CAPS_P2P		0x0400
139 #define AGP_AMD751_CAPS_MPC		0x0200
140 #define AGP_AMD751_CAPS_VBE		0x0100
141 #define AGP_AMD751_CAPS_REV		0x00ff
142 #define AGP_AMD751_STATUS	0x02
143 #define AGP_AMD751_STATUS_P2PS		0x0800
144 #define AGP_AMD751_STATUS_GCS		0x0400
145 #define AGP_AMD751_STATUS_MPS		0x0200
146 #define AGP_AMD751_STATUS_VBES		0x0100
147 #define AGP_AMD751_STATUS_P2PE		0x0008
148 #define AGP_AMD751_STATUS_GCE		0x0004
149 #define AGP_AMD751_STATUS_VBEE		0x0001
150 #define AGP_AMD751_ATTBASE	0x04
151 #define AGP_AMD751_TLBCTRL	0x0c
152 
153 /*
154  * Config registers for i810 device 0
155  */
156 #define AGP_I810_SMRAM		0x70
157 #define AGP_I810_SMRAM_GMS		0xc0
158 #define AGP_I810_SMRAM_GMS_DISABLED	0x00
159 #define AGP_I810_SMRAM_GMS_ENABLED_0	0x40
160 #define AGP_I810_SMRAM_GMS_ENABLED_512	0x80
161 #define AGP_I810_SMRAM_GMS_ENABLED_1024	0xc0
162 #define AGP_I810_MISCC		0x72
163 #define	AGP_I810_MISCC_WINSIZE		0x0001
164 #define AGP_I810_MISCC_WINSIZE_64	0x0000
165 #define AGP_I810_MISCC_WINSIZE_32	0x0001
166 #define AGP_I810_MISCC_PLCK		0x0008
167 #define AGP_I810_MISCC_PLCK_UNLOCKED	0x0000
168 #define AGP_I810_MISCC_PLCK_LOCKED	0x0008
169 #define AGP_I810_MISCC_WPTC		0x0030
170 #define AGP_I810_MISCC_WPTC_NOLIMIT	0x0000
171 #define AGP_I810_MISCC_WPTC_62		0x0010
172 #define AGP_I810_MISCC_WPTC_50		0x0020
173 #define	AGP_I810_MISCC_WPTC_37		0x0030
174 #define AGP_I810_MISCC_RPTC		0x00c0
175 #define AGP_I810_MISCC_RPTC_NOLIMIT	0x0000
176 #define AGP_I810_MISCC_RPTC_62		0x0040
177 #define AGP_I810_MISCC_RPTC_50		0x0080
178 #define AGP_I810_MISCC_RPTC_37		0x00c0
179 
180 /*
181  * Config registers for i810 device 1
182  */
183 #define AGP_I810_GMADR		0x10
184 #define AGP_I810_MMADR		0x14
185 
186 #define	I810_PTE_VALID		0x00000001
187 
188 /*
189  * Cache control
190  *
191  * Pre-Sandybridge bits
192  */
193 #define	I810_PTE_MAIN_UNCACHED	0x00000000
194 #define	I810_PTE_LOCAL		0x00000002	/* Non-snooped main phys memory */
195 #define	I830_PTE_SYSTEM_CACHED  0x00000006	/* Snooped main phys memory */
196 
197 /*
198  * Sandybridge
199  * LLC - Last Level Cache
200  * MMC - Mid Level Cache
201  */
202 #define	GEN6_PTE_RESERVED	0x00000000
203 #define	GEN6_PTE_UNCACHED	0x00000002	/* Do not cache */
204 #define	GEN6_PTE_LLC		0x00000004	/* Cache in LLC */
205 #define	GEN6_PTE_LLC_MLC	0x00000006	/* Cache in LLC and MLC */
206 #define	GEN6_PTE_GFDT		0x00000008	/* Graphics Data Type */
207 
208 /*
209  * Memory mapped register offsets for i810 chipset.
210  */
211 #define AGP_I810_PGTBL_CTL	0x2020
212 #define	AGP_I810_PGTBL_ENABLED	0x00000001
213 /**
214  * This field determines the actual size of the global GTT on the 965
215  * and G33
216  */
217 #define AGP_I810_PGTBL_SIZE_MASK	0x0000000e
218 #define AGP_I810_PGTBL_SIZE_512KB	(0 << 1)
219 #define AGP_I810_PGTBL_SIZE_256KB	(1 << 1)
220 #define	AGP_I810_PGTBL_SIZE_128KB	(2 << 1)
221 #define	AGP_I810_PGTBL_SIZE_1MB		(3 << 1)
222 #define	AGP_I810_PGTBL_SIZE_2MB		(4 << 1)
223 #define	AGP_I810_PGTBL_SIZE_1_5MB	(5 << 1)
224 #define AGP_G33_GCC1_SIZE_MASK		(3 << 8)
225 #define AGP_G33_GCC1_SIZE_1M		(1 << 8)
226 #define AGP_G33_GCC1_SIZE_2M		(2 << 8)
227 #define AGP_G4x_GCC1_SIZE_MASK		(0xf << 8)
228 #define AGP_G4x_GCC1_SIZE_1M		(0x1 << 8)
229 #define AGP_G4x_GCC1_SIZE_2M		(0x3 << 8)
230 #define AGP_G4x_GCC1_SIZE_VT_EN		(0x8 << 8)
231 #define AGP_G4x_GCC1_SIZE_VT_1M \
232     (AGP_G4x_GCC1_SIZE_1M | AGP_G4x_GCC1_SIZE_VT_EN)
233 #define AGP_G4x_GCC1_SIZE_VT_1_5M	((0x2 << 8) | AGP_G4x_GCC1_SIZE_VT_EN)
234 #define AGP_G4x_GCC1_SIZE_VT_2M	\
235     (AGP_G4x_GCC1_SIZE_2M | AGP_G4x_GCC1_SIZE_VT_EN)
236 
237 #define AGP_I810_DRT		0x3000
238 #define AGP_I810_DRT_UNPOPULATED 0x00
239 #define AGP_I810_DRT_POPULATED	0x01
240 #define AGP_I810_GTT		0x10000
241 
242 /*
243  * Config registers for i830MG device 0
244  */
245 #define AGP_I830_GCC1			0x52
246 #define AGP_I830_GCC1_DEV2		0x08
247 #define AGP_I830_GCC1_DEV2_ENABLED	0x00
248 #define AGP_I830_GCC1_DEV2_DISABLED	0x08
249 #define AGP_I830_GCC1_GMS		0xf0 /* Top bit reserved pre-G33 */
250 #define AGP_I830_GCC1_GMS_STOLEN_512	0x20
251 #define AGP_I830_GCC1_GMS_STOLEN_1024	0x30
252 #define AGP_I830_GCC1_GMS_STOLEN_8192	0x40
253 #define AGP_I830_GCC1_GMASIZE		0x01
254 #define AGP_I830_GCC1_GMASIZE_64	0x01
255 #define AGP_I830_GCC1_GMASIZE_128	0x00
256 #define	AGP_I830_HIC			0x70
257 
258 /*
259  * Config registers for 852GM/855GM/865G device 0
260  */
261 #define AGP_I855_GCC1			0x52
262 #define AGP_I855_GCC1_DEV2		0x08
263 #define AGP_I855_GCC1_DEV2_ENABLED	0x00
264 #define AGP_I855_GCC1_DEV2_DISABLED	0x08
265 #define AGP_I855_GCC1_GMS		0xf0 /* Top bit reserved pre-G33 */
266 #define AGP_I855_GCC1_GMS_STOLEN_0M	0x00
267 #define AGP_I855_GCC1_GMS_STOLEN_1M	0x10
268 #define AGP_I855_GCC1_GMS_STOLEN_4M	0x20
269 #define AGP_I855_GCC1_GMS_STOLEN_8M	0x30
270 #define AGP_I855_GCC1_GMS_STOLEN_16M	0x40
271 #define AGP_I855_GCC1_GMS_STOLEN_32M	0x50
272 
273 /*
274  * 852GM/855GM variant identification
275  */
276 #define AGP_I85X_CAPID			0x44
277 #define AGP_I85X_VARIANT_MASK		0x7
278 #define AGP_I85X_VARIANT_SHIFT		5
279 #define AGP_I855_GME			0x0
280 #define AGP_I855_GM			0x4
281 #define AGP_I852_GME			0x2
282 #define AGP_I852_GM			0x5
283 
284 /*
285  * 915G registers
286  */
287 #define AGP_I915_GMADR			0x18
288 #define AGP_I915_MMADR			0x10
289 #define AGP_I915_GTTADR			0x1C
290 #define AGP_I915_GCC1_GMS_STOLEN_48M	0x60
291 #define AGP_I915_GCC1_GMS_STOLEN_64M	0x70
292 #define AGP_I915_DEVEN			0x54
293 #define	AGP_SB_DEVEN_D2EN		0x10	/* SB+ has IGD enabled bit */
294 #define	AGP_SB_DEVEN_D2EN_ENABLED	0x10	/* in different place */
295 #define	AGP_SB_DEVEN_D2EN_DISABLED	0x00
296 #define AGP_I915_DEVEN_D2F0		0x08
297 #define AGP_I915_DEVEN_D2F0_ENABLED	0x08
298 #define AGP_I915_DEVEN_D2F0_DISABLED	0x00
299 #define AGP_I915_MSAC			0x62
300 #define AGP_I915_MSAC_GMASIZE		0x02
301 #define AGP_I915_MSAC_GMASIZE_128	0x02
302 #define AGP_I915_MSAC_GMASIZE_256	0x00
303 #define	AGP_I915_IFPADDR		0x60
304 
305 /*
306  * G965 registers
307  */
308 #define AGP_I965_GTTMMADR		0x10
309 #define AGP_I965_MSAC			0x62
310 #define AGP_I965_MSAC_GMASIZE_128	0x00
311 #define AGP_I965_MSAC_GMASIZE_256	0x02
312 #define AGP_I965_MSAC_GMASIZE_512	0x06
313 #define AGP_I965_PGTBL_SIZE_1MB		(3 << 1)
314 #define AGP_I965_PGTBL_SIZE_2MB		(4 << 1)
315 #define AGP_I965_PGTBL_SIZE_1_5MB	(5 << 1)
316 #define AGP_I965_PGTBL_CTL2		0x20c4
317 #define	AGP_I965_IFPADDR		0x70
318 
319 /*
320  * G33 registers
321  */
322 #define AGP_G33_MGGC_GGMS_MASK		(3 << 8)
323 #define AGP_G33_MGGC_GGMS_SIZE_1M	(1 << 8)
324 #define AGP_G33_MGGC_GGMS_SIZE_2M	(2 << 8)
325 #define AGP_G33_GCC1_GMS_STOLEN_128M	0x80
326 #define AGP_G33_GCC1_GMS_STOLEN_256M	0x90
327 
328 /*
329  * G4X registers
330  */
331 #define AGP_G4X_GMADR			0x20
332 #define AGP_G4X_MMADR			0x10
333 #define AGP_G4X_GTTADR			0x18
334 #define AGP_G4X_GCC1_GMS_STOLEN_96M	0xa0
335 #define AGP_G4X_GCC1_GMS_STOLEN_160M	0xb0
336 #define AGP_G4X_GCC1_GMS_STOLEN_224M	0xc0
337 #define AGP_G4X_GCC1_GMS_STOLEN_352M	0xd0
338 
339 /*
340  * SandyBridge/IvyBridge registers
341  */
342 #define AGP_SNB_GCC1			0x50
343 #define AGP_SNB_GMCH_GMS_STOLEN_MASK	0xF8
344 #define AGP_SNB_GMCH_GMS_STOLEN_32M	(1 << 3)
345 #define AGP_SNB_GMCH_GMS_STOLEN_64M	(2 << 3)
346 #define AGP_SNB_GMCH_GMS_STOLEN_96M	(3 << 3)
347 #define AGP_SNB_GMCH_GMS_STOLEN_128M	(4 << 3)
348 #define AGP_SNB_GMCH_GMS_STOLEN_160M	(5 << 3)
349 #define AGP_SNB_GMCH_GMS_STOLEN_192M	(6 << 3)
350 #define AGP_SNB_GMCH_GMS_STOLEN_224M	(7 << 3)
351 #define AGP_SNB_GMCH_GMS_STOLEN_256M	(8 << 3)
352 #define AGP_SNB_GMCH_GMS_STOLEN_288M	(9 << 3)
353 #define AGP_SNB_GMCH_GMS_STOLEN_320M	(0xa << 3)
354 #define AGP_SNB_GMCH_GMS_STOLEN_352M	(0xb << 3)
355 #define AGP_SNB_GMCH_GMS_STOLEN_384M	(0xc << 3)
356 #define AGP_SNB_GMCH_GMS_STOLEN_416M	(0xd << 3)
357 #define AGP_SNB_GMCH_GMS_STOLEN_448M	(0xe << 3)
358 #define AGP_SNB_GMCH_GMS_STOLEN_480M	(0xf << 3)
359 #define AGP_SNB_GMCH_GMS_STOLEN_512M	(0x10 << 3)
360 #define AGP_SNB_GTT_SIZE_0M		(0 << 8)
361 #define AGP_SNB_GTT_SIZE_1M		(1 << 8)
362 #define AGP_SNB_GTT_SIZE_2M		(2 << 8)
363 #define AGP_SNB_GTT_SIZE_MASK		(3 << 8)
364 
365 #define AGP_SNB_GFX_MODE		0x02520
366 
367 /*
368  * NVIDIA nForce/nForce2 registers
369  */
370 #define	AGP_NVIDIA_0_APBASE		0x10
371 #define	AGP_NVIDIA_0_APSIZE		0x80
372 #define	AGP_NVIDIA_1_WBC		0xf0
373 #define	AGP_NVIDIA_2_GARTCTRL		0xd0
374 #define	AGP_NVIDIA_2_APBASE		0xd8
375 #define	AGP_NVIDIA_2_APLIMIT		0xdc
376 #define	AGP_NVIDIA_2_ATTBASE(i)		(0xe0 + (i) * 4)
377 #define	AGP_NVIDIA_3_APBASE		0x50
378 #define	AGP_NVIDIA_3_APLIMIT		0x54
379 
380 /*
381  * AMD64 GART registers
382  */
383 #define	AGP_AMD64_APCTRL		0x90
384 #define	AGP_AMD64_APBASE		0x94
385 #define	AGP_AMD64_ATTBASE		0x98
386 #define	AGP_AMD64_CACHECTRL		0x9c
387 #define	AGP_AMD64_APCTRL_GARTEN		0x00000001
388 #define	AGP_AMD64_APCTRL_SIZE_MASK	0x0000000e
389 #define	AGP_AMD64_APCTRL_DISGARTCPU	0x00000010
390 #define	AGP_AMD64_APCTRL_DISGARTIO	0x00000020
391 #define	AGP_AMD64_APCTRL_DISWLKPRB	0x00000040
392 #define	AGP_AMD64_APBASE_MASK		0x00007fff
393 #define	AGP_AMD64_ATTBASE_MASK		0xfffffff0
394 #define	AGP_AMD64_CACHECTRL_INVGART	0x00000001
395 #define	AGP_AMD64_CACHECTRL_PTEERR	0x00000002
396 
397 /*
398  * NVIDIA nForce3 registers
399  */
400 #define AGP_AMD64_NVIDIA_0_APBASE	0x10
401 #define AGP_AMD64_NVIDIA_1_APBASE1	0x50
402 #define AGP_AMD64_NVIDIA_1_APLIMIT1	0x54
403 #define AGP_AMD64_NVIDIA_1_APSIZE	0xa8
404 #define AGP_AMD64_NVIDIA_1_APBASE2	0xd8
405 #define AGP_AMD64_NVIDIA_1_APLIMIT2	0xdc
406 
407 /*
408  * ULi M1689 registers
409  */
410 #define AGP_AMD64_ULI_APBASE		0x10
411 #define AGP_AMD64_ULI_HTT_FEATURE	0x50
412 #define AGP_AMD64_ULI_ENU_SCR		0x54
413 
414 /*
415  * ATI IGP registers
416  */
417 #define ATI_GART_MMADDR		0x14
418 #define ATI_RS100_APSIZE	0xac
419 #define ATI_RS100_IG_AGPMODE	0xb0
420 #define ATI_RS300_APSIZE	0xf8
421 #define ATI_RS300_IG_AGPMODE	0xfc
422 #define ATI_GART_FEATURE_ID	0x00
423 #define ATI_GART_BASE		0x04
424 #define ATI_GART_CACHE_CNTRL	0x0c
425 
426 #endif /* !_PCI_AGPREG_H_ */
427