xref: /netbsd/sys/arch/amiga/dev/gvpbus.c (revision 6550d01e)
1 /*	$NetBSD: gvpbus.c,v 1.24 2009/10/26 19:16:54 cegger 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 
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: gvpbus.c,v 1.24 2009/10/26 19:16:54 cegger Exp $");
35 
36 #include <sys/param.h>
37 #include <sys/device.h>
38 #include <sys/systm.h>
39 #include <amiga/amiga/device.h>
40 #include <amiga/dev/zbusvar.h>
41 #include <amiga/dev/gvpbusvar.h>
42 
43 void gvpbusattach(struct device *, struct device *, void *);
44 int gvpbusmatch(struct device *, struct cfdata *, void *);
45 int gvpbusprint(void *auxp, const char *);
46 
47 extern int sbic_no_dma;		/* Kludge for A1291 - mlh */
48 
49 CFATTACH_DECL(gvpbus, sizeof(struct device),
50     gvpbusmatch, gvpbusattach, NULL, NULL);
51 
52 int
53 gvpbusmatch(struct device *pdp, struct cfdata *cfp, 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(struct device *pdp, struct device *dp, void *auxp)
73 {
74 	struct zbus_args *zap;
75 	struct gvpbus_args ga;
76 	int flags0, flags;
77 
78 	zap = auxp;
79 	memcpy(&ga.zargs, zap, sizeof(struct zbus_args));
80 	flags = 0;
81 
82 	/*
83 	 * grab secondary type (or fake it if we have a series I)
84 	 */
85 	if (zap->prodid != 9) {
86 		ga.prod = *((u_char *)zap->va + 0x8001) & 0xf8;
87 		if (*((u_char *)zap->va + 0x8001) & 0x01)
88 			flags |= GVP_14MHZ;
89 	printf(": subprod %02x flags %02x", *((u_char *)zap->va + 0x8001), flags);
90 #if 0
91 	} else {
92 		ga.prod = GVP_SERIESII;		/* really a series I */
93 		flags |= GVP_NOBANK;
94 #endif
95 	}
96 
97 
98 	switch (ga.prod) {
99 	/* no scsi */
100 	case GVP_GFORCE_040:
101 	case GVP_GFORCE_030:
102 		flags = GVP_IO;
103 		/*FALLTHROUGH*/
104 	case GVP_COMBO_R4:
105 	case GVP_COMBO_R3:
106 		flags |= GVP_ACCEL;
107 		break;
108 	/* scsi */
109 	case GVP_A1291_SCSI:
110 		flags |= GVP_SCSI | GVP_ACCEL;
111 		sbic_no_dma = 1;	/* Kludge !!!!!!! mlh */
112 		break;
113 	case GVP_GFORCE_040_SCSI:
114 		flags |= GVP_SCSI | GVP_IO | GVP_ACCEL;
115 		break;
116 	case GVP_GFORCE_030_SCSI:
117 		flags |= GVP_SCSI | GVP_IO | GVP_ACCEL | GVP_25BITDMA;
118 		break;
119 	case GVP_A530_SCSI:
120 	case GVP_COMBO_R4_SCSI:
121 		flags |= GVP_SCSI | GVP_ACCEL | GVP_25BITDMA;
122 		if (ga.prod == GVP_COMBO_R4_SCSI)
123 			flags ^= GVP_14MHZ;
124 		break;
125 	case GVP_COMBO_R3_SCSI:
126 		flags |= GVP_SCSI | GVP_ACCEL | GVP_24BITDMA;
127 		flags ^= GVP_14MHZ;
128 		break;
129 	case GVP_SERIESII:
130 		flags |= GVP_SCSI | GVP_24BITDMA;
131 		break;
132 	/* misc */
133 	case GVP_IOEXTEND:
134 		flags |= GVP_IO;
135 		break;
136 	default:
137 		printf(": unknown Series II %x", ga.prod);
138 	}
139 	printf("\n");
140 	/*
141 	 * attempt to configure the board.
142 	 */
143 
144 	flags0 = flags & ~(GVP_IO|GVP_SCSI);
145 
146 	if (flags & GVP_SCSI) {
147 		ga.flags = flags0 | GVP_SCSI;
148 		config_found(dp, &ga, gvpbusprint);
149 	}
150 	if (flags & GVP_IO) {
151 		ga.flags = flags0 | GVP_IO;
152 		config_found(dp, &ga, gvpbusprint);
153 	}
154 }
155 
156 int
157 gvpbusprint(void *auxp, const char *pnp)
158 {
159 	struct gvpbus_args *gap;
160 
161 	gap = auxp;
162 	if (pnp == NULL)
163 		return(QUIET);
164 	/*
165 	 * doesn't support io yet.
166 	 */
167 	if (gap->prod == GVP_IOEXTEND)
168 		aprint_normal("gio at %s", pnp);
169 	else
170 		aprint_normal("gtsc at %s", pnp);
171 	return(UNCONF);
172 }
173 
174