xref: /netbsd/sys/dev/pci/tga_conf.c (revision 454af1c0)
1*454af1c0Sdsl /* $NetBSD: tga_conf.c,v 1.7 2009/03/14 15:36:19 dsl Exp $ */
2eda73f20Sdrochner 
3eda73f20Sdrochner /*
4eda73f20Sdrochner  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5eda73f20Sdrochner  * All rights reserved.
6eda73f20Sdrochner  *
7eda73f20Sdrochner  * Author: Chris G. Demetriou
8eda73f20Sdrochner  *
9eda73f20Sdrochner  * Permission to use, copy, modify and distribute this software and
10eda73f20Sdrochner  * its documentation is hereby granted, provided that both the copyright
11eda73f20Sdrochner  * notice and this permission notice appear in all copies of the
12eda73f20Sdrochner  * software, derivative works or modified versions, and any portions
13eda73f20Sdrochner  * thereof, and that both notices appear in supporting documentation.
14eda73f20Sdrochner  *
15eda73f20Sdrochner  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16eda73f20Sdrochner  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17eda73f20Sdrochner  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18eda73f20Sdrochner  *
19eda73f20Sdrochner  * Carnegie Mellon requests users of this software to return to
20eda73f20Sdrochner  *
21eda73f20Sdrochner  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22eda73f20Sdrochner  *  School of Computer Science
23eda73f20Sdrochner  *  Carnegie Mellon University
24eda73f20Sdrochner  *  Pittsburgh PA 15213-3890
25eda73f20Sdrochner  *
26eda73f20Sdrochner  * any improvements or extensions that they make and grant Carnegie the
27eda73f20Sdrochner  * rights to redistribute these changes.
28eda73f20Sdrochner  */
29eda73f20Sdrochner 
309048aaaeSlukem #include <sys/cdefs.h>
31*454af1c0Sdsl __KERNEL_RCSID(0, "$NetBSD: tga_conf.c,v 1.7 2009/03/14 15:36:19 dsl Exp $");
329048aaaeSlukem 
33eda73f20Sdrochner #include <sys/param.h>
3451b292eaSelric #include <sys/systm.h>
35eda73f20Sdrochner #include <sys/device.h>
36eda73f20Sdrochner 
37eda73f20Sdrochner #include <dev/pci/pcivar.h>
38eda73f20Sdrochner #include <dev/pci/tgareg.h>
39eda73f20Sdrochner #include <dev/pci/tgavar.h>
40eda73f20Sdrochner 
41bc3260fcSnathanw #include <dev/ic/bt485var.h>
42bc3260fcSnathanw #include <dev/ic/bt463var.h>
4351b292eaSelric #include <dev/ic/ibm561var.h>
44bc3260fcSnathanw 
45eda73f20Sdrochner #undef KB
46eda73f20Sdrochner #define KB		* 1024
47eda73f20Sdrochner #undef MB
48eda73f20Sdrochner #define	MB		* 1024 * 1024
49eda73f20Sdrochner 
50eda73f20Sdrochner static const struct tga_conf tga_configs[TGA_TYPE_UNKNOWN] = {
51eda73f20Sdrochner 	/* TGA_TYPE_T8_01 */
52eda73f20Sdrochner 	{
53eda73f20Sdrochner 		"T8-01",
54bc3260fcSnathanw 		bt485_funcs,
55eda73f20Sdrochner 		8,
56eda73f20Sdrochner 		4 MB,
57eda73f20Sdrochner 		2 KB,
58eda73f20Sdrochner 		1,	{  2 MB,     0 },	{ 1 MB,    0 },
59eda73f20Sdrochner 		0,	{     0,     0 },	{    0,    0 },
60eda73f20Sdrochner 	},
61eda73f20Sdrochner 	/* TGA_TYPE_T8_02 */
62eda73f20Sdrochner 	{
63eda73f20Sdrochner 		"T8-02",
64bc3260fcSnathanw 		bt485_funcs,
65eda73f20Sdrochner 		8,
66eda73f20Sdrochner 		4 MB,
67eda73f20Sdrochner 		4 KB,
68eda73f20Sdrochner 		1,	{  2 MB,     0 },	{ 2 MB,    0 },
69eda73f20Sdrochner 		0,	{     0,     0 },	{    0,    0 },
70eda73f20Sdrochner 	},
71eda73f20Sdrochner 	/* TGA_TYPE_T8_22 */
72eda73f20Sdrochner 	{
73eda73f20Sdrochner 		"T8-22",
74bc3260fcSnathanw 		bt485_funcs,
75eda73f20Sdrochner 		8,
76eda73f20Sdrochner 		8 MB,
77eda73f20Sdrochner 		4 KB,
78eda73f20Sdrochner 		1,	{  4 MB,     0 },	{ 2 MB,    0 },
79eda73f20Sdrochner 		1,	{  6 MB,     0 },	{ 2 MB,    0 },
80eda73f20Sdrochner 	},
81eda73f20Sdrochner 	/* TGA_TYPE_T8_44 */
82eda73f20Sdrochner 	{
83eda73f20Sdrochner 		"T8-44",
84bc3260fcSnathanw 		bt485_funcs,
85eda73f20Sdrochner 		8,
86eda73f20Sdrochner 		16 MB,
87eda73f20Sdrochner 		4 KB,
88eda73f20Sdrochner 		2,	{  8 MB, 12 MB },	{ 2 MB, 2 MB },
89eda73f20Sdrochner 		2,	{ 10 MB, 14 MB },	{ 2 MB, 2 MB },
90eda73f20Sdrochner 	},
91eda73f20Sdrochner 	/* TGA_TYPE_T32_04 */
92eda73f20Sdrochner 	{
93eda73f20Sdrochner 		"T32-04",
94bc3260fcSnathanw 		bt463_funcs,
95eda73f20Sdrochner 		32,
96eda73f20Sdrochner 		16 MB,
97eda73f20Sdrochner 		8 KB,
98eda73f20Sdrochner 		1,	{  8 MB,     0 },	{ 4 MB,    0 },
99eda73f20Sdrochner 		0,	{     0,     0 },	{    0,    0 },
100eda73f20Sdrochner 	},
101eda73f20Sdrochner 	/* TGA_TYPE_T32_08 */
102eda73f20Sdrochner 	{
103eda73f20Sdrochner 		"T32-08",
104bc3260fcSnathanw 		bt463_funcs,
105eda73f20Sdrochner 		32,
106eda73f20Sdrochner 		16 MB,
107eda73f20Sdrochner 		16 KB,
108eda73f20Sdrochner 		1,	{  8 MB,    0 },	{ 8 MB,    0 },
109eda73f20Sdrochner 		0,	{     0,    0 },	{    0,    0 },
110eda73f20Sdrochner 	},
111eda73f20Sdrochner 	/* TGA_TYPE_T32_88 */
112eda73f20Sdrochner 	{
113eda73f20Sdrochner 		"T32-88",
114bc3260fcSnathanw 		bt463_funcs,
115eda73f20Sdrochner 		32,
116eda73f20Sdrochner 		32 MB,
117eda73f20Sdrochner 		16 KB,
118eda73f20Sdrochner 		1,	{ 16 MB,    0 },	{ 8 MB,    0 },
119eda73f20Sdrochner 		1,	{ 24 MB,    0 },	{ 8 MB,    0 },
120eda73f20Sdrochner 	},
12151b292eaSelric 	/* TGA_TYPE_POWERSTORM_4D20 */
12251b292eaSelric 	/* XXX: These numbers may be incorrect */
12351b292eaSelric 	{
12451b292eaSelric 		"PS4d20",
12551b292eaSelric 		ibm561_funcs,
12651b292eaSelric 		32,
12751b292eaSelric 		32 MB,
12851b292eaSelric 		16 KB,
12951b292eaSelric 		1,	{ 16 MB,    0 },	{ 8 MB,    0 },
13051b292eaSelric 		1,	{ 24 MB,    0 },	{ 8 MB,    0 },
13151b292eaSelric 	}
132eda73f20Sdrochner };
133eda73f20Sdrochner 
134eda73f20Sdrochner #undef KB
135eda73f20Sdrochner #undef MB
136eda73f20Sdrochner 
137eda73f20Sdrochner int
tga_identify(struct tga_devconfig * dc)138*454af1c0Sdsl tga_identify(struct tga_devconfig *dc)
139eda73f20Sdrochner {
140eda73f20Sdrochner 	int type;
1411203bdcbSnathanw 	int gder;
14251b292eaSelric 	int grev;
143eda73f20Sdrochner 	int deep, addrmask, wide;
14451b292eaSelric 	int tga2;
145eda73f20Sdrochner 
1461203bdcbSnathanw 	gder = TGARREG(dc, TGA_REG_GDER);
14751b292eaSelric 	grev = TGARREG(dc, TGA_REG_GREV);
1481203bdcbSnathanw 
1491203bdcbSnathanw 	deep = (gder & 0x1) != 0; /* XXX */
1501203bdcbSnathanw 	addrmask = (gder >> 2) & 0x7; /* XXX */
1511203bdcbSnathanw 	wide = (gder & 0x200) == 0; /* XXX */
15251b292eaSelric 	tga2 = (grev & 0x20) != 0;
153eda73f20Sdrochner 
154eda73f20Sdrochner 	type = TGA_TYPE_UNKNOWN;
155eda73f20Sdrochner 
156eda73f20Sdrochner 	if (!deep) {
157eda73f20Sdrochner 		/* 8bpp frame buffer */
158eda73f20Sdrochner 
159eda73f20Sdrochner 		if (addrmask == 0x0) {
160eda73f20Sdrochner 			/* 4MB core map; T8-01 or T8-02 */
161eda73f20Sdrochner 
162eda73f20Sdrochner 			if (!wide)
163eda73f20Sdrochner 				type = TGA_TYPE_T8_01;
164eda73f20Sdrochner 			else
165eda73f20Sdrochner 				type = TGA_TYPE_T8_02;
166eda73f20Sdrochner 		} else if (addrmask == 0x1) {
167eda73f20Sdrochner 			/* 8MB core map; T8-22 */
168eda73f20Sdrochner 
169eda73f20Sdrochner 			if (wide)			/* sanity */
170eda73f20Sdrochner 				type = TGA_TYPE_T8_22;
171eda73f20Sdrochner 		} else if (addrmask == 0x3) {
172eda73f20Sdrochner 			/* 16MB core map; T8-44 */
173eda73f20Sdrochner 
174eda73f20Sdrochner 			if (wide)			/* sanity */
175eda73f20Sdrochner 				type = TGA_TYPE_T8_44;
176eda73f20Sdrochner 		}
177eda73f20Sdrochner 	} else {
178eda73f20Sdrochner 		/* 32bpp frame buffer */
17951b292eaSelric 		if (addrmask == 0x00 && tga2 && wide) {
18051b292eaSelric 			/* My PowerStorm 4d20 shows up this way? */
18151b292eaSelric 			type = TGA_TYPE_POWERSTORM_4D20;
18251b292eaSelric 		}
183eda73f20Sdrochner 
184eda73f20Sdrochner 		if (addrmask == 0x3) {
185eda73f20Sdrochner 			/* 16MB core map; T32-04 or T32-08 */
186eda73f20Sdrochner 
187eda73f20Sdrochner 			if (!wide)
188eda73f20Sdrochner 				type = TGA_TYPE_T32_04;
189eda73f20Sdrochner 			else
190eda73f20Sdrochner 				type = TGA_TYPE_T32_08;
191eda73f20Sdrochner 		} else if (addrmask == 0x7) {
192eda73f20Sdrochner 			/* 32MB core map; T32-88 */
193eda73f20Sdrochner 
19451b292eaSelric 			if (wide && !tga2)			/* sanity */
195eda73f20Sdrochner 				type = TGA_TYPE_T32_88;
196eda73f20Sdrochner 		}
197eda73f20Sdrochner 	}
198eda73f20Sdrochner 
199eda73f20Sdrochner 	return (type);
200eda73f20Sdrochner }
201eda73f20Sdrochner 
202eda73f20Sdrochner const struct tga_conf *
tga_getconf(int type)203*454af1c0Sdsl tga_getconf(int type)
204eda73f20Sdrochner {
205eda73f20Sdrochner 
206eda73f20Sdrochner 	if (type >= 0 && type < TGA_TYPE_UNKNOWN)
207eda73f20Sdrochner 		return &tga_configs[type];
208eda73f20Sdrochner 
209eda73f20Sdrochner 	return (NULL);
210eda73f20Sdrochner }
211