if_ne_pcmcia.c revision 1.29 1 /* $NetBSD: if_ne_pcmcia.c,v 1.29 1998/12/18 21:54:14 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1997 Marc Horowitz. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Marc Horowitz.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/select.h>
35 #include <sys/device.h>
36 #include <sys/socket.h>
37
38 #include <net/if_types.h>
39 #include <net/if.h>
40 #include <net/if_media.h>
41 #include <net/if_ether.h>
42
43 #include <machine/bus.h>
44 #include <machine/intr.h>
45
46 #include <dev/pcmcia/pcmciareg.h>
47 #include <dev/pcmcia/pcmciavar.h>
48 #include <dev/pcmcia/pcmciadevs.h>
49
50 #include <dev/ic/dp8390reg.h>
51 #include <dev/ic/dp8390var.h>
52
53 #include <dev/ic/ne2000reg.h>
54 #include <dev/ic/ne2000var.h>
55
56 #include <dev/ic/rtl80x9reg.h>
57 #include <dev/ic/rtl80x9var.h>
58
59 int ne_pcmcia_match __P((struct device *, struct cfdata *, void *));
60 void ne_pcmcia_attach __P((struct device *, struct device *, void *));
61 int ne_pcmcia_detach __P((struct device *, int));
62
63 int ne_pcmcia_enable __P((struct dp8390_softc *));
64 void ne_pcmcia_disable __P((struct dp8390_softc *));
65
66 struct ne_pcmcia_softc {
67 struct ne2000_softc sc_ne2000; /* real "ne2000" softc */
68
69 /* PCMCIA-specific goo */
70 struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o information */
71 int sc_asic_io_window; /* i/o window for ASIC */
72 int sc_nic_io_window; /* i/o window for NIC */
73 struct pcmcia_function *sc_pf; /* our PCMCIA function */
74 void *sc_ih; /* interrupt handle */
75 };
76
77 struct cfattach ne_pcmcia_ca = {
78 sizeof(struct ne_pcmcia_softc), ne_pcmcia_match, ne_pcmcia_attach,
79 ne_pcmcia_detach, dp8390_activate
80 };
81
82 struct ne2000dev {
83 char *name;
84 int32_t manufacturer;
85 int32_t product;
86 char *cis_info[4];
87 int function;
88 int enet_maddr;
89 unsigned char enet_vendor[3];
90 } ne2000devs[] = {
91 { PCMCIA_STR_PREMAX_PE200,
92 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
93 PCMCIA_CIS_PREMAX_PE200,
94 0, 0x07f0, { 0x00, 0x20, 0xe0 } },
95
96 { PCMCIA_STR_DIGITAL_DEPCMXX,
97 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
98 PCMCIA_CIS_DIGITAL_DEPCMXX,
99 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
100
101 { PCMCIA_STR_PLANET_SMARTCOM2000,
102 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
103 PCMCIA_CIS_PLANET_SMARTCOM2000,
104 0, 0xff0, { 0x00, 0x00, 0xe8 } },
105
106 { PCMCIA_STR_DLINK_DE660,
107 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
108 PCMCIA_CIS_DLINK_DE660,
109 0, -1, { 0x00, 0x80, 0xc8 } },
110
111 { PCMCIA_STR_RPTI_EP401,
112 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
113 PCMCIA_CIS_RPTI_EP401,
114 0, -1, { 0x00, 0x40, 0x95 } },
115
116 { PCMCIA_STR_ACCTON_EN2212,
117 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
118 PCMCIA_CIS_ACCTON_EN2212,
119 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
120
121 { PCMCIA_STR_SVEC_COMBOCARD,
122 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
123 PCMCIA_CIS_SVEC_COMBOCARD,
124 0, -1, { 0x00, 0xe0, 0x98 } },
125
126 /*
127 * You have to add new entries which contains
128 * PCMCIA_VENDOR_INVALID and/or PCMCIA_PRODUCT_INVALID
129 * in front of this comment.
130 *
131 * There are cards which use a generic vendor and product id but needs
132 * a different handling depending on the cis_info, so ne2000_match
133 * needs a table where the exceptions comes first and then the normal
134 * product and vendor entries.
135 */
136
137 { PCMCIA_STR_IBM_INFOMOVER,
138 PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
139 PCMCIA_CIS_IBM_INFOMOVER,
140 0, 0x0ff0, { 0x08, 0x00, 0x5a } },
141
142 { PCMCIA_STR_LINKSYS_ECARD_1,
143 PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ECARD_1,
144 PCMCIA_CIS_LINKSYS_ECARD_1,
145 0, -1, { 0x00, 0x80, 0xc8 } },
146
147 { PCMCIA_STR_LINKSYS_COMBO_ECARD,
148 PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
149 PCMCIA_CIS_LINKSYS_COMBO_ECARD,
150 0, -1, { 0x00, 0x80, 0xc8 } },
151
152 { PCMCIA_STR_LINKSYS_TRUST_COMBO_ECARD,
153 PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_TRUST_COMBO_ECARD,
154 PCMCIA_CIS_LINKSYS_TRUST_COMBO_ECARD,
155 0, 0x0120, { 0x20, 0x04, 0x49 } },
156
157 /* Although the comments above say to put VENDOR/PRODUCT INVALID IDs
158 above this list, we need to keep this one below the ECARD_1, or else
159 both will match the same more-generic entry rather than the more
160 specific one above with proper vendor and product IDs. */
161 { PCMCIA_STR_LINKSYS_ECARD_2,
162 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
163 PCMCIA_CIS_LINKSYS_ECARD_2,
164 0, -1, { 0x00, 0x80, 0xc8 } },
165
166 /*
167 * D-Link DE-650 has many minor versions:
168 *
169 * CIS information Manufacturer Product Note
170 * 1 "D-Link, DE-650" INVALID INVALID white card
171 * 2 "D-Link, DE-650, Ver 01.00" INVALID INVALID became bare metal
172 * 3 "D-Link, DE-650, Ver 01.00" 0x149 0x265 minor change in look
173 * 4 "D-Link, DE-650, Ver 01.00" 0x149 0x265 collision LED added
174 *
175 * While the 1st and the 2nd types should use the "D-Link DE-650" entry,
176 * the 3rd and the 4th types should use the "Linksys EtherCard" entry.
177 * Therefore, this enty must be below the LINKSYS_ECARD_1. --itohy
178 */
179 { PCMCIA_STR_DLINK_DE650,
180 PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
181 PCMCIA_CIS_DLINK_DE650,
182 0, 0x0040, { 0x00, 0x80, 0xc8 } },
183
184 { PCMCIA_STR_IODATA_PCLAT,
185 PCMCIA_VENDOR_IODATA, PCMCIA_PRODUCT_IODATA_PCLAT,
186 PCMCIA_CIS_IODATA_PCLAT,
187 /* two possible location, 0x01c0 or 0x0ff0 */
188 0, -1, { 0x00, 0xa0, 0xb0 } },
189
190 { PCMCIA_STR_DAYNA_COMMUNICARD_E_1,
191 PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_1,
192 PCMCIA_CIS_DAYNA_COMMUNICARD_E_1,
193 0, 0x0110, { 0x00, 0x80, 0x19 } },
194
195 { PCMCIA_STR_DAYNA_COMMUNICARD_E_2,
196 PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_2,
197 PCMCIA_CIS_DAYNA_COMMUNICARD_E_2,
198 0, -1, { 0x00, 0x80, 0x19 } },
199
200 { PCMCIA_STR_COREGA_PCC_2,
201 PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_PCC_2,
202 PCMCIA_CIS_COREGA_PCC_2,
203 0, -1, { 0x00, 0x00, 0xf4 } },
204
205 #if 0
206 /* the rest of these are stolen from the linux pcnet pcmcia device
207 driver. Since I don't know the manfid or cis info strings for
208 any of them, they're not compiled in until I do. */
209 { "Allied Telesis LA-PCM",
210 0x0000, 0x0000, NULL, NULL, 0,
211 0x0ff0, { 0x00, 0x00, 0xf4 } },
212 { "APEX MultiCard",
213 0x0000, 0x0000, NULL, NULL, 0,
214 0x03f4, { 0x00, 0x20, 0xe5 } },
215 { "ASANTE FriendlyNet",
216 0x0000, 0x0000, NULL, NULL, 0,
217 0x4910, { 0x00, 0x00, 0x94 } },
218 { "Danpex EN-6200P2",
219 0x0000, 0x0000, NULL, NULL, 0,
220 0x0110, { 0x00, 0x40, 0xc7 } },
221 { "DataTrek NetCard",
222 0x0000, 0x0000, NULL, NULL, 0,
223 0x0ff0, { 0x00, 0x20, 0xe8 } },
224 { "Dayna CommuniCard E",
225 0x0000, 0x0000, NULL, NULL, 0,
226 0x0110, { 0x00, 0x80, 0x19 } },
227 { "EP-210 Ethernet",
228 0x0000, 0x0000, NULL, NULL, 0,
229 0x0110, { 0x00, 0x40, 0x33 } },
230 { "Epson EEN10B",
231 0x0000, 0x0000, NULL, NULL, 0,
232 0x0ff0, { 0x00, 0x00, 0x48 } },
233 { "ELECOM Laneed LD-CDWA",
234 0x0000, 0x0000, NULL, NULL, 0,
235 0x00b8, { 0x08, 0x00, 0x42 } },
236 { "Grey Cell GCS2220",
237 0x0000, 0x0000, NULL, NULL, 0,
238 0x0000, { 0x00, 0x47, 0x43 } },
239 { "Hypertec Ethernet",
240 0x0000, 0x0000, NULL, NULL, 0,
241 0x01c0, { 0x00, 0x40, 0x4c } },
242 { "IBM CCAE",
243 0x0000, 0x0000, NULL, NULL, 0,
244 0x0ff0, { 0x08, 0x00, 0x5a } },
245 { "IBM CCAE",
246 0x0000, 0x0000, NULL, NULL, 0,
247 0x0ff0, { 0x00, 0x04, 0xac } },
248 { "IBM CCAE",
249 0x0000, 0x0000, NULL, NULL, 0,
250 0x0ff0, { 0x00, 0x06, 0x29 } },
251 { "IBM FME",
252 0x0000, 0x0000, NULL, NULL, 0,
253 0x0374, { 0x00, 0x04, 0xac } },
254 { "IBM FME",
255 0x0000, 0x0000, NULL, NULL, 0,
256 0x0374, { 0x08, 0x00, 0x5a } },
257 { "Katron PE-520",
258 0x0000, 0x0000, NULL, NULL, 0,
259 0x0110, { 0x00, 0x40, 0xf6 } },
260 { "Kingston KNE-PCM/x",
261 0x0000, 0x0000, NULL, NULL, 0,
262 0x0ff0, { 0x00, 0xc0, 0xf0 } },
263 { "Kingston KNE-PCM/x",
264 0x0000, 0x0000, NULL, NULL, 0,
265 0x0ff0, { 0xe2, 0x0c, 0x0f } },
266 { "Kingston KNE-PC2",
267 0x0000, 0x0000, NULL, NULL, 0,
268 0x0180, { 0x00, 0xc0, 0xf0 } },
269 { "Longshine LCS-8534",
270 0x0000, 0x0000, NULL, NULL, 0,
271 0x0000, { 0x08, 0x00, 0x00 } },
272 { "Maxtech PCN2000",
273 0x0000, 0x0000, NULL, NULL, 0,
274 0x5000, { 0x00, 0x00, 0xe8 } },
275 { "NDC Instant-Link",
276 0x0000, 0x0000, NULL, NULL, 0,
277 0x003a, { 0x00, 0x80, 0xc6 } },
278 { "NE2000 Compatible",
279 0x0000, 0x0000, NULL, NULL, 0,
280 0x0ff0, { 0x00, 0xa0, 0x0c } },
281 { "Network General Sniffer",
282 0x0000, 0x0000, NULL, NULL, 0,
283 0x0ff0, { 0x00, 0x00, 0x65 } },
284 { "Panasonic VEL211",
285 0x0000, 0x0000, NULL, NULL, 0,
286 0x0ff0, { 0x00, 0x80, 0x45 } },
287 { "SCM Ethernet",
288 0x0000, 0x0000, NULL, NULL, 0,
289 0x0ff0, { 0x00, 0x20, 0xcb } },
290 { "Socket EA",
291 0x0000, 0x0000, NULL, NULL, 0,
292 0x4000, { 0x00, 0xc0, 0x1b } },
293 { "Volktek NPL-402CT",
294 0x0000, 0x0000, NULL, NULL, 0,
295 0x0060, { 0x00, 0x40, 0x05 } },
296 #endif
297 };
298
299 #define NE2000_NDEVS (sizeof(ne2000devs) / sizeof(ne2000devs[0]))
300
301 #define ne2000_match(card, fct, n) \
302 ((((((card)->manufacturer != PCMCIA_VENDOR_INVALID) && \
303 ((card)->manufacturer == ne2000devs[(n)].manufacturer) && \
304 ((card)->product != PCMCIA_PRODUCT_INVALID) && \
305 ((card)->product == ne2000devs[(n)].product)) || \
306 ((ne2000devs[(n)].cis_info[0]) && (ne2000devs[(n)].cis_info[1]) && \
307 (strcmp((card)->cis1_info[0], ne2000devs[(n)].cis_info[0]) == 0) && \
308 (strcmp((card)->cis1_info[1], ne2000devs[(n)].cis_info[1]) == 0))) && \
309 ((fct) == ne2000devs[(n)].function))? \
310 &ne2000devs[(n)]:NULL)
311
312 int
313 ne_pcmcia_match(parent, match, aux)
314 struct device *parent;
315 struct cfdata *match;
316 void *aux;
317 {
318 struct pcmcia_attach_args *pa = aux;
319 int i;
320
321 for (i = 0; i < NE2000_NDEVS; i++) {
322 if (ne2000_match(pa->card, pa->pf->number, i))
323 return (1);
324 }
325
326 return (0);
327 }
328
329 void
330 ne_pcmcia_attach(parent, self, aux)
331 struct device *parent, *self;
332 void *aux;
333 {
334 struct ne_pcmcia_softc *psc = (void *) self;
335 struct ne2000_softc *nsc = &psc->sc_ne2000;
336 struct dp8390_softc *dsc = &nsc->sc_dp8390;
337 struct pcmcia_attach_args *pa = aux;
338 struct pcmcia_config_entry *cfe;
339 struct ne2000dev *ne_dev;
340 struct pcmcia_mem_handle pcmh;
341 bus_addr_t offset;
342 int i, j, mwindow;
343 u_int8_t myea[6], *enaddr = NULL;
344 void (*npp_init_media) __P((struct dp8390_softc *, int **,
345 int *, int *));
346 int *media, nmedia, defmedia;
347 const char *typestr = "";
348
349 npp_init_media = NULL;
350 media = NULL;
351 nmedia = defmedia = 0;
352
353 psc->sc_pf = pa->pf;
354 cfe = pa->pf->cfe_head.sqh_first;
355
356 #if 0
357 /*
358 * Some ne2000 driver's claim to have memory; others don't.
359 * Since I don't care, I don't check.
360 */
361
362 if (cfe->num_memspace != 1) {
363 printf(": unexpected number of memory spaces "
364 " %d should be 1\n", cfe->num_memspace);
365 return;
366 }
367 #endif
368
369 if (cfe->num_iospace == 1) {
370 if (cfe->iospace[0].length != NE2000_NPORTS) {
371 printf(": unexpected I/O space configuration\n");
372 return;
373 }
374 } else if (cfe->num_iospace == 2) {
375 /*
376 * Some cards report a separate space for NIC and ASIC.
377 * This make some sense, but we must allocate a single
378 * NE2000_NPORTS-sized chunk, due to brain damaged
379 * address decoders on some of these cards.
380 */
381 if ((cfe->iospace[0].length + cfe->iospace[1].length) !=
382 NE2000_NPORTS) {
383 printf(": unexpected I/O space configuration\n");
384 return;
385 }
386 } else {
387 printf(": unexpected number of i/o spaces %d"
388 " should be 1 or 2\n", cfe->num_iospace);
389 }
390
391 if (pcmcia_io_alloc(pa->pf, 0, NE2000_NPORTS, NE2000_NPORTS,
392 &psc->sc_pcioh)) {
393 printf(": can't alloc i/o space\n");
394 return;
395 }
396
397 dsc->sc_regt = psc->sc_pcioh.iot;
398 dsc->sc_regh = psc->sc_pcioh.ioh;
399
400 nsc->sc_asict = psc->sc_pcioh.iot;
401 if (bus_space_subregion(dsc->sc_regt, dsc->sc_regh,
402 NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
403 &nsc->sc_asich)) {
404 printf(": can't get subregion for asic\n");
405 return;
406 }
407
408 /* Set up power management hooks. */
409 dsc->sc_enable = ne_pcmcia_enable;
410 dsc->sc_disable = ne_pcmcia_disable;
411
412 /* Enable the card. */
413 pcmcia_function_init(pa->pf, cfe);
414 if (pcmcia_function_enable(pa->pf)) {
415 printf(": function enable failed\n");
416 return;
417 }
418
419 /* some cards claim to be io16, but they're lying. */
420 if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO8,
421 NE2000_NIC_OFFSET, NE2000_NIC_NPORTS,
422 &psc->sc_pcioh, &psc->sc_nic_io_window)) {
423 printf(": can't map NIC i/o space\n");
424 return;
425 }
426
427 if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16,
428 NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
429 &psc->sc_pcioh, &psc->sc_asic_io_window)) {
430 printf(": can't map ASIC i/o space\n");
431 return;
432 }
433
434 printf("\n");
435
436 /*
437 * Read the station address from the board.
438 */
439 for (i = 0; i < NE2000_NDEVS; i++) {
440 if ((ne_dev = ne2000_match(pa->card, pa->pf->number, i))
441 != NULL) {
442 if (ne_dev->enet_maddr >= 0) {
443 if (pcmcia_mem_alloc(pa->pf,
444 ETHER_ADDR_LEN * 2, &pcmh)) {
445 printf("%s: can't alloc mem for"
446 " enet addr\n",
447 dsc->sc_dev.dv_xname);
448 return;
449 }
450 if (pcmcia_mem_map(pa->pf, PCMCIA_MEM_ATTR,
451 ne_dev->enet_maddr, ETHER_ADDR_LEN * 2,
452 &pcmh, &offset, &mwindow)) {
453 printf("%s: can't map mem for"
454 " enet addr\n",
455 dsc->sc_dev.dv_xname);
456 return;
457 }
458 for (j = 0; j < ETHER_ADDR_LEN; j++)
459 myea[j] = bus_space_read_1(pcmh.memt,
460 pcmh.memh, offset + (j * 2));
461 pcmcia_mem_unmap(pa->pf, mwindow);
462 pcmcia_mem_free(pa->pf, &pcmh);
463 enaddr = myea;
464 }
465 break;
466 }
467 }
468
469 if (enaddr != NULL) {
470 /*
471 * Make sure this is what we expect.
472 */
473 if (enaddr[0] != ne_dev->enet_vendor[0] ||
474 enaddr[1] != ne_dev->enet_vendor[1] ||
475 enaddr[2] != ne_dev->enet_vendor[2]) {
476 printf("%s: enet addr has incorrect vendor code\n",
477 dsc->sc_dev.dv_xname);
478 printf("%s: (%02x:%02x:%02x should be "
479 "%02x:%02x:%02x)\n", dsc->sc_dev.dv_xname,
480 enaddr[0], enaddr[1], enaddr[2],
481 ne_dev->enet_vendor[0],
482 ne_dev->enet_vendor[1],
483 ne_dev->enet_vendor[2]);
484 return;
485 }
486 }
487
488 /*
489 * Check for a RealTek 8019.
490 */
491 bus_space_write_1(dsc->sc_regt, dsc->sc_regh, ED_P0_CR,
492 ED_CR_PAGE_0 | ED_CR_STP);
493 if (bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID0)
494 == RTL0_8019ID0 &&
495 bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID1)
496 == RTL0_8019ID1) {
497 typestr = " (RTL8019)";
498 npp_init_media = rtl80x9_init_media;
499 dsc->sc_mediachange = rtl80x9_mediachange;
500 dsc->sc_mediastatus = rtl80x9_mediastatus;
501 dsc->init_card = rtl80x9_init_card;
502 }
503
504 printf("%s: %s%s Ethernet\n", dsc->sc_dev.dv_xname, ne_dev->name,
505 typestr);
506
507 /* Initialize media, if we have it. */
508 if (npp_init_media != NULL)
509 (*npp_init_media)(dsc, &media, &nmedia, &defmedia);
510
511 ne2000_attach(nsc, enaddr, media, nmedia, defmedia);
512
513 pcmcia_function_disable(pa->pf);
514 }
515
516 int
517 ne_pcmcia_detach(self, flags)
518 struct device *self;
519 int flags;
520 {
521 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)self;
522
523 /* Unmap our i/o windows. */
524 pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
525 pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
526
527 /* Free our i/o space. */
528 pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
529
530 #ifdef notyet
531 /*
532 * Our softc is about to go away, so drop our reference
533 * to the ifnet.
534 */
535 if_delref(psc->sc_ne2000.sc_dp8390.sc_ec.ec_if);
536 return (0);
537 #else
538 return (EBUSY);
539 #endif
540 }
541
542 int
543 ne_pcmcia_enable(dsc)
544 struct dp8390_softc *dsc;
545 {
546 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
547
548 /* set up the interrupt */
549 psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr,
550 dsc);
551 if (psc->sc_ih == NULL) {
552 printf("%s: couldn't establish interrupt\n",
553 dsc->sc_dev.dv_xname);
554 return (1);
555 }
556
557 return (pcmcia_function_enable(psc->sc_pf));
558 }
559
560 void
561 ne_pcmcia_disable(dsc)
562 struct dp8390_softc *dsc;
563 {
564 struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
565
566 pcmcia_function_disable(psc->sc_pf);
567
568 pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
569 }
570