Initial import from FreeBSD RELENG_4:
[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  *
32  *      last edit-date: [Wed Jan 24 09:30:19 2001]
33  *
34  *---------------------------------------------------------------------------*/
35
36 #include "isic.h"
37 #include "opt_i4b.h"
38
39 #if NISIC > 0
40
41 #include <sys/param.h>
42 #include <sys/kernel.h>
43 #include <sys/systm.h>
44 #include <sys/socket.h>
45 #include <net/if.h>
46
47 #include <machine/i4b_ioctl.h>
48
49 #include <i4b/layer1/isic/i4b_isic.h>
50
51 #include <sys/bus.h>
52 #include <isa/isavar.h>
53
54 struct l1_softc l1_sc[ISIC_MAXUNIT];
55
56 static int isic_isa_probe(device_t dev);
57 static int isic_isa_attach(device_t dev);
58
59 static device_method_t isic_methods[] = {
60         DEVMETHOD(device_probe,         isic_isa_probe),
61         DEVMETHOD(device_attach,        isic_isa_attach),
62         { 0, 0 }
63 };
64
65 static driver_t isic_driver = {
66         "isic",
67         isic_methods,
68         0
69 };
70
71 static devclass_t isic_devclass;
72
73 DRIVER_MODULE(isic, isa, isic_driver, isic_devclass, 0, 0);
74
75 /*---------------------------------------------------------------------------*
76  *      probe for ISA non-PnP cards
77  *---------------------------------------------------------------------------*/
78 static int
79 isic_isa_probe(device_t dev)
80 {
81         int ret = ENXIO;
82
83         if(isa_get_vendorid(dev))       /* no PnP probes here */
84                 return ENXIO;
85
86         switch(device_get_flags(dev))
87         {
88 #ifdef TEL_S0_16
89                 case CARD_TYPEP_16:
90                         ret = isic_probe_s016(dev);
91                         break;
92 #endif
93
94 #ifdef TEL_S0_8
95                 case CARD_TYPEP_8:
96                         ret = isic_probe_s08(dev);
97                         break;
98 #endif
99
100 #ifdef ELSA_PCC16
101                 case CARD_TYPEP_PCC16:
102                         ret = isic_probe_Epcc16(dev);
103                         break;
104 #endif
105
106 #ifdef TEL_S0_16_3
107                 case CARD_TYPEP_16_3:
108                         ret = isic_probe_s0163(dev);            
109                         break;
110 #endif
111
112 #ifdef AVM_A1
113                 case CARD_TYPEP_AVMA1:
114                         ret = isic_probe_avma1(dev);
115                         break;
116 #endif
117
118 #ifdef USR_STI
119                 case CARD_TYPEP_USRTA:
120                         ret = isic_probe_usrtai(dev);           
121                         break;
122 #endif
123
124 #ifdef ITKIX1
125                 case CARD_TYPEP_ITKIX1:
126                         ret = isic_probe_itkix1(dev);
127                         break;
128 #endif
129
130                 default:
131                         printf("isic%d: probe, unknown flag: %d\n",
132                                 device_get_unit(dev), device_get_flags(dev));
133                         break;
134         }
135         return(ret);
136 }
137
138 /*---------------------------------------------------------------------------*
139  *      attach for ISA non-PnP cards
140  *---------------------------------------------------------------------------*/
141 static int
142 isic_isa_attach(device_t dev)
143 {
144         int ret = ENXIO;
145
146         struct l1_softc *sc = &l1_sc[device_get_unit(dev)];
147
148         sc->sc_unit = device_get_unit(dev);
149         
150         /* card dependent setup */
151
152         switch(sc->sc_cardtyp)
153         {
154 #ifdef TEL_S0_16
155                 case CARD_TYPEP_16:
156                         ret = isic_attach_s016(dev);
157                         break;
158 #endif
159
160 #ifdef TEL_S0_8
161                 case CARD_TYPEP_8:
162                         ret = isic_attach_s08(dev);
163                         break;
164 #endif
165
166 #ifdef ELSA_PCC16
167                 case CARD_TYPEP_PCC16:
168                         ret = isic_attach_Epcc16(dev);
169                         break;
170 #endif
171
172 #ifdef TEL_S0_16_3
173                 case CARD_TYPEP_16_3:
174                         ret = isic_attach_s0163(dev);
175                         break;
176 #endif
177
178 #ifdef AVM_A1
179                 case CARD_TYPEP_AVMA1:
180                         ret = isic_attach_avma1(dev);
181                         break;
182 #endif
183
184 #ifdef USR_STI
185                 case CARD_TYPEP_USRTA:
186                         ret = isic_attach_usrtai(dev);          
187                         break;
188 #endif
189
190 #ifdef ITKIX1
191                 case CARD_TYPEP_ITKIX1:
192                         ret = isic_attach_itkix1(dev);
193                         break;
194 #endif
195
196                 default:
197                         printf("isic%d: attach, unknown flag: %d\n",
198                                 device_get_unit(dev), device_get_flags(dev));
199                         break;
200         }
201
202         if(ret)
203                 return(ret);
204                 
205         ret = isic_attach_common(dev);
206
207         return(ret);
208 }
209 #endif /* NISIC > 0 */