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