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