kernel tree reorganization stage 1: Major cvs repository work (not logged as
[dragonfly.git] / sys / net / i4b / layer1 / isic / i4b_isic_pnp.c
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1998 Eivind Eklund. All rights reserved.
3 *
4 * Copyright (c) 1998, 1999 German Tischler. All rights reserved.
5 *
6 * Copyright (c) 1998, 2001 Hellmuth Michaelis. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the author nor the names of any co-contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 * 4. Altered versions must be plainly marked as such, and must not be
21 * misrepresented as being the original software and/or documentation.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 *---------------------------------------------------------------------------
36 *
37 * i4b_isic_pnp.c - i4b pnp support
38 * --------------------------------
39 *
40 * $FreeBSD: src/sys/i4b/layer1/isic/i4b_isic_pnp.c,v 1.5.2.2 2001/12/10 12:18:11 hm Exp $
d2438d69 41 * $DragonFly: src/sys/net/i4b/layer1/isic/i4b_isic_pnp.c,v 1.4 2003/08/07 21:54:31 dillon Exp $
984263bc
MD
42 *
43 * last edit-date: [Fri Jan 26 14:01:04 2001]
44 *
45 *---------------------------------------------------------------------------*/
46
1f2de5d4 47#include "use_isic.h"
984263bc
MD
48#include "opt_i4b.h"
49
50#if (NISIC > 0)
51
52#include <sys/param.h>
53#include <sys/systm.h>
54#include <sys/kernel.h>
55#include <sys/socket.h>
56#include <net/if.h>
57
d2438d69 58#include <net/i4b/include/machine/i4b_ioctl.h>
1f2de5d4 59#include "i4b_isic.h"
984263bc 60
1f2de5d4 61#include <bus/isa/isavar.h>
984263bc
MD
62
63#define VID_TEL163PNP 0x10212750 /* Teles 16.3 PnP */
64#define VID_CREATIXPP 0x0000980e /* Creatix S0/16 P+P */
65#define VID_DYNALINK 0x88167506 /* Dynalink */
66#define VID_SEDLBAUER 0x0100274c /* Sedlbauer WinSpeed */
67#define VID_NICCYGO 0x5001814c /* Neuhaus Niccy GO@ */
68#define VID_ELSAQS1P 0x33019315 /* ELSA Quickstep1000pro*/
69#define VID_ITK0025 0x25008b26 /* ITK Ix1 Micro V3 */
70#define VID_AVMPNP 0x0009cd06 /* AVM Fritz! PnP */
71#define VID_SIESURF2 0x2000254d /* Siemens I-Surf 2.0 PnP*/
72#define VID_ASUSCOM_IPAC 0x90167506 /* Asuscom (with IPAC) */
73#define VID_EICON_DIVA_20 0x7100891c /* Eicon DIVA 2.0 ISAC/HSCX */
74#define VID_EICON_DIVA_202 0xa100891c /* Eicon DIVA 2.02 IPAC */
75#define VID_COMPAQ_M610 0x0210110e /* Compaq Microcom 610 */
76
77static struct isic_pnp_ids {
78 u_long vend_id;
79 char *id_str;
80} isic_pnp_ids[] = {
81#if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P) || defined(COMPAQ_M610)
82 { VID_TEL163PNP, "Teles S0/16.3 PnP" },
83 { VID_CREATIXPP, "Creatix S0/16 PnP" },
84 { VID_COMPAQ_M610, "Compaq Microcom 610" },
85#endif
86#ifdef DYNALINK
87 { VID_DYNALINK, "Dynalink IS64PH" },
88#endif
89#ifdef SEDLBAUER
90 { VID_SEDLBAUER, "Sedlbauer WinSpeed" },
91#endif
92#ifdef DRN_NGO
93 { VID_NICCYGO, "Dr.Neuhaus Niccy Go@" },
94#endif
95#ifdef ELSA_QS1ISA
96 { VID_ELSAQS1P, "ELSA QuickStep 1000pro" },
97#endif
98#ifdef ITKIX1
99 { VID_ITK0025, "ITK ix1 Micro V3.0" },
100#endif
101#ifdef AVM_PNP
102 { VID_AVMPNP, "AVM Fritz!Card PnP" },
103#endif
104#ifdef SIEMENS_ISURF2
105 { VID_SIESURF2, "Siemens I-Surf 2.0 PnP" },
106#endif
107#ifdef ASUSCOM_IPAC
108 { VID_ASUSCOM_IPAC, "Asuscom ISDNLink 128 PnP" },
109#endif
110#ifdef EICON_DIVA
111 { VID_EICON_DIVA_20, "Eicon.Diehl DIVA 2.0 ISA PnP" },
112 { VID_EICON_DIVA_202, "Eicon.Diehl DIVA 2.02 ISA PnP" },
113#endif
114 { 0, 0 }
115};
116
117static int isic_pnp_probe(device_t dev);
118static int isic_pnp_attach(device_t dev);
119
120static device_method_t isic_pnp_methods[] = {
121 DEVMETHOD(device_probe, isic_pnp_probe),
122 DEVMETHOD(device_attach, isic_pnp_attach),
123 { 0, 0 }
124};
125
126static driver_t isic_pnp_driver = {
127 "isic",
128 isic_pnp_methods,
129 0,
130};
131
132static devclass_t isic_devclass;
133
134DRIVER_MODULE(isicpnp, isa, isic_pnp_driver, isic_devclass, 0, 0);
135
136/*---------------------------------------------------------------------------*
137 * probe for ISA PnP cards
138 *---------------------------------------------------------------------------*/
139int
140isic_pnp_probe(device_t dev)
141{
142 struct isic_pnp_ids *ids; /* pnp id's */
143 char *string = NULL; /* the name */
144 u_int32_t vend_id = isa_get_vendorid(dev); /* vendor id */
145
146 /* search table of knowd id's */
147
148 for(ids = isic_pnp_ids; ids->vend_id != 0; ids++)
149 {
150 if(vend_id == ids->vend_id)
151 {
152 string = ids->id_str;
153 break;
154 }
155 }
156
157 if(string) /* set name if we have one */
158 {
159 device_set_desc(dev, string); /* set description */
160 return 0;
161 }
162 else
163 {
164 return ENXIO;
165 }
166}
167
168/*---------------------------------------------------------------------------*
169 * attach for ISA PnP cards
170 *---------------------------------------------------------------------------*/
171int
172isic_pnp_attach(device_t dev)
173{
174 u_int32_t vend_id = isa_get_vendorid(dev); /* vendor id */
175 unsigned int unit = device_get_unit(dev); /* get unit */
176 const char *name = device_get_desc(dev); /* get description */
177 struct l1_softc *sc = 0; /* softc */
178 void *ih = 0; /* a dummy */
179 int ret;
180
181 /* see if we are out of bounds */
182
183 if(unit >= ISIC_MAXUNIT)
184 {
185 printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for %s\n", unit, unit, name);
186 return ENXIO;
187 }
188
189 /* get information structure for this unit */
190
191 sc = &l1_sc[unit];
192
193 /* get io_base */
194 if(!(sc->sc_resources.io_base[0] =
195 bus_alloc_resource(dev, SYS_RES_IOPORT,
196 &sc->sc_resources.io_rid[0],
197 0UL, ~0UL, 1, RF_ACTIVE ) ))
198 {
199 printf("isic_pnp_attach: Couldn't get my io_base.\n");
200 return ENXIO;
201 }
202
203 /* will not be used for pnp devices */
204
205 sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
206
207 /* get irq, release io_base if we don't get it */
208
209 if(!(sc->sc_resources.irq =
210 bus_alloc_resource(dev, SYS_RES_IRQ,
211 &sc->sc_resources.irq_rid,
212 0UL, ~0UL, 1, RF_ACTIVE)))
213 {
214 printf("isic%d: Could not get irq.\n",unit);
215 isic_detach_common(dev);
216 return ENXIO;
217 }
218
219 /* not needed */
220 sc->sc_irq = rman_get_start(sc->sc_resources.irq);
221
222
223 /* set flag so we know what this card is */
224
225 ret = ENXIO;
226
227 switch(vend_id)
228 {
229#if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P) || defined(COMPAQ_M610)
230 case VID_TEL163PNP:
231 sc->sc_cardtyp = CARD_TYPEP_163P;
232 ret = isic_attach_Cs0P(dev);
233 break;
234
235 case VID_CREATIXPP:
236 sc->sc_cardtyp = CARD_TYPEP_CS0P;
237 ret = isic_attach_Cs0P(dev);
238 break;
239
240 case VID_COMPAQ_M610:
241 sc->sc_cardtyp = CARD_TYPEP_COMPAQ_M610;
242 ret = isic_attach_Cs0P(dev);
243 break;
244#endif
245#ifdef DYNALINK
246 case VID_DYNALINK:
247 sc->sc_cardtyp = CARD_TYPEP_DYNALINK;
248 ret = isic_attach_Dyn(dev);
249 break;
250#endif
251#ifdef SEDLBAUER
252 case VID_SEDLBAUER:
253 sc->sc_cardtyp = CARD_TYPEP_SWS;
254 ret = isic_attach_sws(dev);
255 break;
256#endif
257#ifdef DRN_NGO
258 case VID_NICCYGO:
259 sc->sc_cardtyp = CARD_TYPEP_DRNNGO;
260 ret = isic_attach_drnngo(dev);
261 break;
262#endif
263#ifdef ELSA_QS1ISA
264 case VID_ELSAQS1P:
265 sc->sc_cardtyp = CARD_TYPEP_ELSAQS1ISA;
266 ret = isic_attach_Eqs1pi(dev);
267 break;
268#endif
269#ifdef ITKIX1
270 case VID_ITK0025:
271 sc->sc_cardtyp = CARD_TYPEP_ITKIX1;
272 ret = isic_attach_itkix1(dev);
273 break;
274#endif
275#ifdef SIEMENS_ISURF2
276 case VID_SIESURF2:
277 sc->sc_cardtyp = CARD_TYPEP_SIE_ISURF2;
278 ret = isic_attach_siemens_isurf(dev);
279 break;
280#endif
281#ifdef ASUSCOM_IPAC
282 case VID_ASUSCOM_IPAC:
283 sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC;
284 ret = isic_attach_asi(dev);
285 break;
286#endif
287#ifdef EICON_DIVA
288 case VID_EICON_DIVA_20:
289 sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA;
290 ret = isic_attach_diva(dev);
291 break;
292
293 case VID_EICON_DIVA_202:
294 sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA;
295 ret = isic_attach_diva_ipac(dev);
296 break;
297#endif
298 default:
299 printf("isic%d: Error, no driver for %s\n", unit, name);
300 ret = ENXIO;
301 break;
302 }
303
304 if(ret)
305 {
306 isic_detach_common(dev);
307 return ENXIO;
308 }
309
310 if(isic_attach_common(dev))
311 {
312 /* unset flag */
313 sc->sc_cardtyp = CARD_TYPEP_UNK;
314
315 /* free irq here, it hasn't been attached yet */
316 bus_release_resource(dev,SYS_RES_IRQ,sc->sc_resources.irq_rid,
317 sc->sc_resources.irq);
318 sc->sc_resources.irq = 0;
319 isic_detach_common(dev);
320 return ENXIO;
321 }
322 else
323 {
324 /* setup intr routine */
325 bus_setup_intr(dev,sc->sc_resources.irq,INTR_TYPE_NET,
326 (void(*)(void*))isicintr,
327 sc,&ih);
328 return 0;
329 }
330}
331#endif /* (NISIC > 0) */