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