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