xref: /titanic_50/usr/src/uts/common/sys/agpgart.h (revision 0a0e9771ca0211c15f3ac4466b661c145feeb9e4)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2000 Doug Rabson
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  */
32 
33 #ifndef	_SYS_AGPGART_H
34 #define	_SYS_AGPGART_H
35 
36 #pragma ident	"%Z%%M%	%I%	%E% SMI"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define	AGP_NORMAL	0	/* mapped to user land, no cache */
43 
44 typedef struct _agp_version {
45 	uint16_t	agpv_major;
46 	uint16_t	agpv_minor;
47 } agp_version_t;
48 
49 
50 typedef struct	_agp_info {
51 	agp_version_t	agpi_version;
52 	uint32_t	agpi_devid;	/* bridge vendor + device */
53 	uint32_t	agpi_mode;	/* mode of brdige */
54 	ulong_t		agpi_aperbase;	/* base of aperture */
55 	size_t		agpi_apersize;	/* aperture range size */
56 	uint32_t	agpi_pgtotal;	/* max number of pages in aperture */
57 	uint32_t	agpi_pgsystem;	/* same as pg_total */
58 	uint32_t	agpi_pgused;	/* NUMBER of currently used pages */
59 } agp_info_t;
60 
61 typedef struct _agp_setup {
62 	uint32_t	agps_mode;
63 } agp_setup_t;
64 
65 typedef struct _agp_allocate {
66 	int32_t		agpa_key;
67 	uint32_t	agpa_pgcount;
68 	uint32_t	agpa_type;
69 	uint32_t	agpa_physical;	/* for i810 only, private */
70 } agp_allocate_t;
71 
72 typedef struct _agp_bind {
73 	int32_t		agpb_key;
74 	uint32_t	agpb_pgstart;
75 } agp_bind_t;
76 
77 typedef struct _agp_unbind {
78 	int32_t		agpu_key;
79 	uint32_t	agpu_pri;	/* no use in solaris */
80 } agp_unbind_t;
81 
82 #define	AGPIOC_BASE		'G'
83 #define	AGPIOC_INFO		_IOR(AGPIOC_BASE, 0, 100)
84 #define	AGPIOC_ACQUIRE		_IO(AGPIOC_BASE, 1)
85 #define	AGPIOC_RELEASE		_IO(AGPIOC_BASE, 2)
86 #define	AGPIOC_SETUP		_IOW(AGPIOC_BASE, 3, agp_setup_t)
87 #define	AGPIOC_ALLOCATE		_IOWR(AGPIOC_BASE, 4, agp_allocate_t)
88 #define	AGPIOC_DEALLOCATE	_IOW(AGPIOC_BASE, 5, int)
89 #define	AGPIOC_BIND		_IOW(AGPIOC_BASE, 6, agp_bind_t)
90 #define	AGPIOC_UNBIND		_IOW(AGPIOC_BASE, 7, agp_unbind_t)
91 #define	AGPIOC_IOREMAP		_IO(AGPIOC_BASE, 8)
92 #define	AGPIOC_IOREMAP_FREE	_IO(AGPIOC_BASE, 9)
93 #define	AGPIOC_READ		_IO(AGPIOC_BASE, 10)
94 #define	AGPIOC_WRITE		_IO(AGPIOC_BASE, 11)
95 
96 /* AGP status register bits definition */
97 #define	AGPSTAT_RQ_MASK		0xff000000	/* target only */
98 #define	AGPSTAT_SBA		(0x1 << 9)	/* always 1 for 3.0 */
99 #define	AGPSTAT_OVER4G		(0x1 << 5)
100 #define	AGPSTAT_FW		(0x1 << 4)
101 #define	AGPSTAT_RATE_MASK	0x7
102 /* rate for 2.0 mode */
103 #define	AGP2_RATE_1X		0x1
104 #define	AGP2_RATE_2X		0x2
105 #define	AGP2_RATE_4X		0x4
106 /* AGP 3.0 only bits */
107 #define	AGPSTAT_ARQSZ_MASK	(0x7 << 13)	/* target only */
108 #define	AGPSTAT_CAL_MASK	(0x7 << 10)
109 #define	AGPSTAT_GART64B		(0x1 << 7)	/* target only */
110 #define	AGPSTAT_MODE3		(0x1 << 3)
111 /* Rate for 3.0 mode */
112 #define	AGP3_RATE_4X		0x1
113 #define	AGP3_RATE_8X		0x2
114 
115 /* AGP command register bits definition */
116 #define	AGPCMD_RQ_MASK		0xff000000	/* master only */
117 #define	AGPCMD_SBAEN		(0x1 << 9)	/* must be 1 for 3.0 */
118 #define	AGPCMD_AGPEN		(0x1 << 8)
119 #define	AGPCMD_OVER4GEN		(0x1 << 5)
120 #define	AGPCMD_FWEN		(0x1 << 4)
121 #define	AGPCMD_RATE_MASK	0x7
122 /* AGP 3.0 only bits */
123 #define	AGP3_CMD_ARQSZ_MASK	(0x7 << 13)	/* master only */
124 #define	AGP3_CMD_CAL_MASK	(0x7 << 10)	/* target only */
125 #define	AGP3_CMD_GART64BEN	(0x1 << 7)	/* target only */
126 
127 #define	AGP_DEVICE	"/dev/agpgart"
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* _SYS_AGPGART_H */
134