xref: /netbsd-src/sys/arch/amiga/dev/gvpbus.c (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1 /*	$NetBSD: gvpbus.c,v 1.16 1998/01/12 10:39:43 thorpej Exp $	*/
2 
3 /*
4  * Copyright (c) 1994 Christian E. Hopps
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Christian E. Hopps.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 #include <sys/param.h>
33 #include <sys/device.h>
34 #include <sys/systm.h>
35 #include <amiga/amiga/device.h>
36 #include <amiga/dev/zbusvar.h>
37 #include <amiga/dev/gvpbusvar.h>
38 
39 void gvpbusattach __P((struct device *, struct device *, void *));
40 int gvpbusmatch __P((struct device *, struct cfdata *, void *));
41 int gvpbusprint __P((void *auxp, const char *));
42 
43 extern int sbic_no_dma;		/* Kludge for A1291 - mlh */
44 
45 struct cfattach gvpbus_ca = {
46 	sizeof(struct device), gvpbusmatch, gvpbusattach
47 };
48 
49 int
50 gvpbusmatch(pdp, cfp, auxp)
51 	struct device *pdp;
52 	struct cfdata *cfp;
53 	void *auxp;
54 {
55 	struct zbus_args *zap;
56 
57 	zap = auxp;
58 
59 	/*
60 	 * Check manufacturer and product id.
61 	 */
62 #if 0
63 	if (zap->manid == 2017 && (zap->prodid == 11 || zap->prodid == 2))
64 #else
65 	if (zap->manid == 2017 && zap->prodid == 11)
66 #endif
67 		return(1);
68 	return(0);
69 }
70 
71 void
72 gvpbusattach(pdp, dp, auxp)
73 	struct device *pdp, *dp;
74 	void *auxp;
75 {
76 	struct zbus_args *zap;
77 	struct gvpbus_args ga;
78 
79 	zap = auxp;
80 	bcopy(zap, &ga.zargs, sizeof(struct zbus_args));
81 	ga.flags = 0;
82 
83 	/*
84 	 * grab secondary type (or fake it if we have a series I)
85 	 */
86 	if (zap->prodid != 9) {
87 		ga.prod = *((u_char *)zap->va + 0x8001) & 0xf8;
88 		if (*((u_char *)zap->va + 0x8001) & 0x01)
89 			ga.flags |= GVP_14MHZ;
90 	printf(": subprod %02x flags %02x", *((u_char *)zap->va + 0x8001), ga.flags);
91 #if 0
92 	} else {
93 		ga.prod = GVP_SERIESII;		/* really a series I */
94 		ga.flags |= GVP_NOBANK;
95 #endif
96 	}
97 
98 
99 	switch (ga.prod) {
100 	/* no scsi */
101 	case GVP_GFORCE_040:
102 	case GVP_GFORCE_030:
103 		ga.flags = GVP_IO;
104 		/*FALLTHROUGH*/
105 	case GVP_COMBO_R4:
106 	case GVP_COMBO_R3:
107 		ga.flags |= GVP_ACCEL;
108 		break;
109 	/* scsi */
110 	case GVP_A1291_SCSI:
111 		ga.flags |= GVP_SCSI | GVP_ACCEL;
112 		sbic_no_dma = 1;	/* Kludge !!!!!!! mlh */
113 		break;
114 	case GVP_GFORCE_040_SCSI:
115 		ga.flags |= GVP_SCSI | GVP_IO | GVP_ACCEL;
116 		break;
117 	case GVP_GFORCE_030_SCSI:
118 		ga.flags |= GVP_SCSI | GVP_IO | GVP_ACCEL | GVP_25BITDMA;
119 		break;
120 	case GVP_A530_SCSI:
121 	case GVP_COMBO_R4_SCSI:
122 		ga.flags |= GVP_SCSI | GVP_ACCEL | GVP_25BITDMA;
123 		if (ga.prod == GVP_COMBO_R4_SCSI)
124 			ga.flags ^= GVP_14MHZ;
125 		break;
126 	case GVP_COMBO_R3_SCSI:
127 		ga.flags |= GVP_SCSI | GVP_ACCEL | GVP_24BITDMA;
128 		ga.flags ^= GVP_14MHZ;
129 		break;
130 	case GVP_SERIESII:
131 		ga.flags |= GVP_SCSI | GVP_24BITDMA;
132 		break;
133 	/* misc */
134 	case GVP_IOEXTEND:
135 		ga.flags |= GVP_IO;
136 		break;
137 	default:
138 		printf(": unknown Series II %x", ga.prod);
139 	}
140 	printf("\n");
141 	/*
142 	 * attempt to configure the board.
143 	 */
144 	config_found(dp, &ga, gvpbusprint);
145 	/*
146 	 * eventually when io support is added we need to
147 	 * configure that too.
148 	 */
149 }
150 
151 int
152 gvpbusprint(auxp, pnp)
153 	void *auxp;
154 	const char *pnp;
155 {
156 	struct gvpbus_args *gap;
157 
158 	gap = auxp;
159 	if (pnp == NULL)
160 		return(QUIET);
161 	/*
162 	 * doesn't support io yet.
163 	 */
164 	if (gap->prod == GVP_IOEXTEND)
165 		printf("gio at %s", pnp);
166 	else
167 		printf("gtsc at %s", pnp);
168 	return(UNCONF);
169 }
170 
171