f55335970250714a4d4d637117e0f8cba00a67b9
[dragonfly.git] / sys / net / i4b / layer1 / isic / i4b_isic_isa.c
1 /*
2  * Copyright (c) 1997, 2001 Hellmuth Michaelis. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  *---------------------------------------------------------------------------
26  *
27  *      i4b_isic_isa.c - ISA bus interface
28  *      ==================================
29  *
30  * $FreeBSD: src/sys/i4b/layer1/isic/i4b_isic_isa.c,v 1.5.2.1 2001/08/10 14:08:38 obrien Exp $
31  * $DragonFly: src/sys/net/i4b/layer1/isic/i4b_isic_isa.c,v 1.3 2003/08/07 21:17:26 dillon Exp $
32  *
33  *      last edit-date: [Wed Jan 24 09:30:19 2001]
34  *
35  *---------------------------------------------------------------------------*/
36
37 #include "use_isic.h"
38 #include "opt_i4b.h"
39
40 #if NISIC > 0
41
42 #include <sys/param.h>
43 #include <sys/kernel.h>
44 #include <sys/systm.h>
45 #include <sys/socket.h>
46 #include <net/if.h>
47
48 #include <machine/i4b_ioctl.h>
49
50 #include "i4b_isic.h"
51
52 #include <sys/bus.h>
53 #include <bus/isa/isavar.h>
54
55 struct l1_softc l1_sc[ISIC_MAXUNIT];
56
57 static int isic_isa_probe(device_t dev);
58 static int isic_isa_attach(device_t dev);
59
60 static device_method_t isic_methods[] = {
61         DEVMETHOD(device_probe,         isic_isa_probe),
62         DEVMETHOD(device_attach,        isic_isa_attach),
63         { 0, 0 }
64 };
65
66 static driver_t isic_driver = {
67         "isic",
68         isic_methods,
69         0
70 };
71
72 static devclass_t isic_devclass;
73
74 DRIVER_MODULE(isic, isa, isic_driver, isic_devclass, 0, 0);
75
76 /*---------------------------------------------------------------------------*
77  *      probe for ISA non-PnP cards
78  *---------------------------------------------------------------------------*/
79 static int
80 isic_isa_probe(device_t dev)
81 {
82         int ret = ENXIO;
83
84         if(isa_get_vendorid(dev))       /* no PnP probes here */
85                 return ENXIO;
86
87         switch(device_get_flags(dev))
88         {
89 #ifdef TEL_S0_16
90                 case CARD_TYPEP_16:
91                         ret = isic_probe_s016(dev);
92                         break;
93 #endif
94
95 #ifdef TEL_S0_8
96                 case CARD_TYPEP_8:
97                         ret = isic_probe_s08(dev);
98                         break;
99 #endif
100
101 #ifdef ELSA_PCC16
102                 case CARD_TYPEP_PCC16:
103                         ret = isic_probe_Epcc16(dev);
104                         break;
105 #endif
106
107 #ifdef TEL_S0_16_3
108                 case CARD_TYPEP_16_3:
109                         ret = isic_probe_s0163(dev);            
110                         break;
111 #endif
112
113 #ifdef AVM_A1
114                 case CARD_TYPEP_AVMA1:
115                         ret = isic_probe_avma1(dev);
116                         break;
117 #endif
118
119 #ifdef USR_STI
120                 case CARD_TYPEP_USRTA:
121                         ret = isic_probe_usrtai(dev);           
122                         break;
123 #endif
124
125 #ifdef ITKIX1
126                 case CARD_TYPEP_ITKIX1:
127                         ret = isic_probe_itkix1(dev);
128                         break;
129 #endif
130
131                 default:
132                         printf("isic%d: probe, unknown flag: %d\n",
133                                 device_get_unit(dev), device_get_flags(dev));
134                         break;
135         }
136         return(ret);
137 }
138
139 /*---------------------------------------------------------------------------*
140  *      attach for ISA non-PnP cards
141  *---------------------------------------------------------------------------*/
142 static int
143 isic_isa_attach(device_t dev)
144 {
145         int ret = ENXIO;
146
147         struct l1_softc *sc = &l1_sc[device_get_unit(dev)];
148
149         sc->sc_unit = device_get_unit(dev);
150         
151         /* card dependent setup */
152
153         switch(sc->sc_cardtyp)
154         {
155 #ifdef TEL_S0_16
156                 case CARD_TYPEP_16:
157                         ret = isic_attach_s016(dev);
158                         break;
159 #endif
160
161 #ifdef TEL_S0_8
162                 case CARD_TYPEP_8:
163                         ret = isic_attach_s08(dev);
164                         break;
165 #endif
166
167 #ifdef ELSA_PCC16
168                 case CARD_TYPEP_PCC16:
169                         ret = isic_attach_Epcc16(dev);
170                         break;
171 #endif
172
173 #ifdef TEL_S0_16_3
174                 case CARD_TYPEP_16_3:
175                         ret = isic_attach_s0163(dev);
176                         break;
177 #endif
178
179 #ifdef AVM_A1
180                 case CARD_TYPEP_AVMA1:
181                         ret = isic_attach_avma1(dev);
182                         break;
183 #endif
184
185 #ifdef USR_STI
186                 case CARD_TYPEP_USRTA:
187                         ret = isic_attach_usrtai(dev);          
188                         break;
189 #endif
190
191 #ifdef ITKIX1
192                 case CARD_TYPEP_ITKIX1:
193                         ret = isic_attach_itkix1(dev);
194                         break;
195 #endif
196
197                 default:
198                         printf("isic%d: attach, unknown flag: %d\n",
199                                 device_get_unit(dev), device_get_flags(dev));
200                         break;
201         }
202
203         if(ret)
204                 return(ret);
205                 
206         ret = isic_attach_common(dev);
207
208         return(ret);
209 }
210 #endif /* NISIC > 0 */