]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i4b/layer1/i4b_isic_pnp.c
This commit was generated by cvs2svn to compensate for changes in r63516,
[FreeBSD/FreeBSD.git] / sys / i4b / layer1 / i4b_isic_pnp.c
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, 1999 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  *      $Id: i4b_isic_pnp.c,v 1.5 1999/12/13 21:25:26 hm Exp $
41  *
42  * $FreeBSD$
43  *
44  *      last edit-date: [Mon Dec 13 22:01:48 1999]
45  *
46  *---------------------------------------------------------------------------*/
47
48 #include "isic.h"
49 #include "opt_i4b.h"
50
51 #if (NISIC > 0)
52
53 #include <sys/param.h>
54 #include <sys/systm.h>
55 #include <sys/kernel.h>
56 #include <sys/socket.h>
57 #include <net/if.h>
58
59 #include <machine/clock.h>
60
61 #include <i4b/include/i4b_global.h>
62 #include <machine/i4b_ioctl.h>
63 #include <i4b/layer1/i4b_l1.h>
64
65 #include <isa/isavar.h>
66
67 #define VID_TEL163PNP           0x10212750      /* Teles 16.3 PnP       */
68 #define VID_CREATIXPP           0x0000980e      /* Creatix S0/16 P+P    */
69 #define VID_DYNALINK            0x88167506      /* Dynalink             */
70 #define VID_SEDLBAUER           0x0100274c      /* Sedlbauer WinSpeed   */
71 #define VID_NICCYGO             0x5001814c      /* Neuhaus Niccy GO@    */
72 #define VID_ELSAQS1P            0x33019315      /* ELSA Quickstep1000pro*/
73 #define VID_ITK0025             0x25008b26      /* ITK Ix1 Micro V3     */
74 #define VID_AVMPNP              0x0009cd06      /* AVM Fritz! PnP       */
75 #define VID_SIESURF2            0x2000254d      /* Siemens I-Surf 2.0 PnP*/
76 #define VID_ASUSCOM_IPAC        0x90167506      /* Asuscom (with IPAC)  */      
77
78 static struct isic_pnp_ids {
79         u_long vend_id;
80         char *id_str;
81 } isic_pnp_ids[] = {
82 #if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P)
83         { VID_TEL163PNP,        "Teles S0/16.3 PnP"             },
84         { VID_CREATIXPP,        "Creatix S0/16 PnP"             },
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         { 0, 0 }
111 };
112
113 static int isic_pnp_probe(device_t dev);
114 static int isic_pnp_attach(device_t dev);
115
116 static device_method_t isic_pnp_methods[] = {
117         DEVMETHOD(device_probe,         isic_pnp_probe),
118         DEVMETHOD(device_attach,        isic_pnp_attach),
119         { 0, 0 }
120 };
121                                 
122 static driver_t isic_pnp_driver = {
123         "isic",
124         isic_pnp_methods,
125         0,
126 };
127
128 static devclass_t isic_devclass;
129
130 DRIVER_MODULE(isicpnp, isa, isic_pnp_driver, isic_devclass, 0, 0);
131
132 /*---------------------------------------------------------------------------*
133  *      probe for ISA PnP cards
134  *---------------------------------------------------------------------------*/
135 int
136 isic_pnp_probe(device_t dev)
137 {
138         struct isic_pnp_ids *ids;                       /* pnp id's */
139         char *string = NULL;                            /* the name */
140         u_int32_t vend_id = isa_get_vendorid(dev);      /* vendor id */
141
142         /* search table of knowd id's */
143         
144         for(ids = isic_pnp_ids; ids->vend_id != 0; ids++)
145         {
146                 if(vend_id == ids->vend_id)
147                 {
148                         string = ids->id_str;
149                         break;
150                 }
151         }
152         
153         if(string)              /* set name if we have one */
154         {
155                 device_set_desc(dev, string);   /* set description */
156                 return 0;
157         }
158         else
159         {
160                 return ENXIO;
161         }
162 }
163
164 /*---------------------------------------------------------------------------*
165  *      attach for ISA PnP cards
166  *---------------------------------------------------------------------------*/
167 int
168 isic_pnp_attach(device_t dev)
169 {
170         u_int32_t vend_id = isa_get_vendorid(dev);      /* vendor id */
171         unsigned int unit = device_get_unit(dev);       /* get unit */
172         const char *name = device_get_desc(dev);        /* get description */
173         struct l1_softc *sc = 0;                        /* softc */
174         void *ih = 0;                                   /* a dummy */
175         int ret;
176  
177         /* see if we are out of bounds */
178         
179         if(unit >= ISIC_MAXUNIT)
180         {
181                 printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for %s\n", unit, unit, name);
182                 return ENXIO;
183         }
184
185         /* get information structure for this unit */
186
187         sc = &l1_sc[unit];
188
189         /* get io_base */
190         if(!(sc->sc_resources.io_base[0] =
191                         bus_alloc_resource(dev, SYS_RES_IOPORT,
192                                                 &sc->sc_resources.io_rid[0],
193                                                 0UL, ~0UL, 1, RF_ACTIVE ) ))
194         {
195                 printf("isic_pnp_attach: Couldn't get my io_base.\n");
196                 return ENXIO;                                       
197         }
198         
199         /* will not be used for pnp devices */
200
201         sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
202
203         /* get irq, release io_base if we don't get it */
204
205         if(!(sc->sc_resources.irq =
206                         bus_alloc_resource(dev, SYS_RES_IRQ,
207                                            &sc->sc_resources.irq_rid,
208                                            0UL, ~0UL, 1, RF_ACTIVE)))
209         {
210                 printf("isic%d: Could not get irq.\n",unit);
211                 isic_detach_common(dev);
212                 return ENXIO;                                       
213         }
214         
215         /* not needed */
216         sc->sc_irq = rman_get_start(sc->sc_resources.irq);
217
218
219         /* set flag so we know what this card is */
220
221         ret = ENXIO;
222         
223         switch(vend_id)
224         {
225 #if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P)
226                 case VID_TEL163PNP:
227                         sc->sc_flags = FLAG_TELES_S0_163_PnP;
228                         ret = isic_attach_Cs0P(dev);
229                         break;
230
231                 case VID_CREATIXPP:
232                         sc->sc_flags = FLAG_CREATIX_S0_PnP;
233                         ret = isic_attach_Cs0P(dev);
234                         break;
235 #endif
236 #ifdef DYNALINK
237                 case VID_DYNALINK:
238                         sc->sc_flags = FLAG_DYNALINK;
239                         ret = isic_attach_Dyn(dev);
240                         break;
241 #endif
242 #ifdef SEDLBAUER
243                 case VID_SEDLBAUER:
244                         sc->sc_flags = FLAG_SWS;
245                         ret = isic_attach_sws(dev);
246                         break;
247 #endif
248 #ifdef DRN_NGO
249                 case VID_NICCYGO:
250                         sc->sc_flags = FLAG_DRN_NGO;
251                         ret = isic_attach_drnngo(dev);
252                         break;
253 #endif
254 #ifdef ELSA_QS1ISA
255                 case VID_ELSAQS1P:
256                         sc->sc_flags = FLAG_ELSA_QS1P_ISA;
257                         ret = isic_attach_Eqs1pi(dev);
258                         break;
259 #endif
260 #ifdef ITKIX1
261                 case VID_ITK0025:
262                         sc->sc_flags = FLAG_ITK_IX1;
263                         ret = isic_attach_itkix1(dev);
264                         break;
265 #endif                  
266 #ifdef AVM_PNP
267                 case VID_AVMPNP:
268                         sc->sc_flags = FLAG_AVM_PNP;
269                         ret = isic_attach_avm_pnp(dev);
270                         break;
271 #endif
272 #ifdef SIEMENS_ISURF2
273                 case VID_SIESURF2:
274                         sc->sc_flags = FLAG_SIEMENS_ISURF2;
275                         ret = isic_attach_siemens_isurf(dev);
276                         break;
277 #endif
278 #ifdef ASUSCOM_IPAC
279                 case VID_ASUSCOM_IPAC:
280                         sc->sc_flags = FLAG_ASUSCOM_IPAC;
281                         ret = isic_attach_asi(dev);
282                         break;
283 #endif
284                 default:
285                         printf("isic%d: Error, no driver for %s\n", unit, name);
286                         ret = ENXIO;
287                         break;          
288         }
289
290         if(ret)
291         {
292                 isic_detach_common(dev);
293                 return ENXIO;                                       
294         }               
295                 
296         if(isic_attach_common(dev))
297         {
298                 /* unset flag */
299                 sc->sc_flags = 0;
300
301                 /* free irq here, it hasn't been attached yet */
302                 bus_release_resource(dev,SYS_RES_IRQ,sc->sc_resources.irq_rid,
303                                         sc->sc_resources.irq);
304                 sc->sc_resources.irq = 0;
305                 isic_detach_common(dev);
306                 return ENXIO;
307         }
308         else
309         {
310                 /* setup intr routine */
311                 bus_setup_intr(dev,sc->sc_resources.irq,INTR_TYPE_NET,
312                                 (void(*)(void*))isicintr,
313                                 sc,&ih);
314                 return 0;
315         }
316 }
317 #endif /* (NISIC > 0) */