Home | History | Annotate | Line # | Download | only in pcmcia
if_ne_pcmcia.c revision 1.100
      1 /*	$NetBSD: if_ne_pcmcia.c,v 1.100 2003/01/16 15:21:20 kanaoka 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/cdefs.h>
     33 __KERNEL_RCSID(0, "$NetBSD: if_ne_pcmcia.c,v 1.100 2003/01/16 15:21:20 kanaoka Exp $");
     34 
     35 #include <sys/param.h>
     36 #include <sys/systm.h>
     37 #include <sys/select.h>
     38 #include <sys/device.h>
     39 #include <sys/socket.h>
     40 
     41 #include <net/if_types.h>
     42 #include <net/if.h>
     43 #include <net/if_media.h>
     44 #include <net/if_ether.h>
     45 
     46 #include <machine/bus.h>
     47 #include <machine/intr.h>
     48 
     49 #include <dev/pcmcia/pcmciareg.h>
     50 #include <dev/pcmcia/pcmciavar.h>
     51 #include <dev/pcmcia/pcmciadevs.h>
     52 
     53 #include <dev/ic/dp8390reg.h>
     54 #include <dev/ic/dp8390var.h>
     55 
     56 #include <dev/ic/ne2000reg.h>
     57 #include <dev/ic/ne2000var.h>
     58 
     59 #include <dev/ic/rtl80x9reg.h>
     60 #include <dev/ic/rtl80x9var.h>
     61 
     62 #include <dev/ic/dl10019var.h>
     63 
     64 #include <dev/ic/ax88190reg.h>
     65 #include <dev/ic/ax88190var.h>
     66 
     67 int	ne_pcmcia_match __P((struct device *, struct cfdata *, void *));
     68 void	ne_pcmcia_attach __P((struct device *, struct device *, void *));
     69 int	ne_pcmcia_detach __P((struct device *, int));
     70 
     71 int	ne_pcmcia_enable __P((struct dp8390_softc *));
     72 void	ne_pcmcia_disable __P((struct dp8390_softc *));
     73 
     74 struct ne_pcmcia_softc {
     75 	struct ne2000_softc sc_ne2000;		/* real "ne2000" softc */
     76 
     77 	/* PCMCIA-specific goo */
     78 	struct pcmcia_io_handle sc_pcioh;	/* PCMCIA i/o information */
     79 	int sc_asic_io_window;			/* i/o window for ASIC */
     80 	int sc_nic_io_window;			/* i/o window for NIC */
     81 	struct pcmcia_function *sc_pf;		/* our PCMCIA function */
     82 	void *sc_ih;				/* interrupt handle */
     83 };
     84 
     85 u_int8_t *
     86 	ne_pcmcia_get_enaddr __P((struct ne_pcmcia_softc *, int,
     87 	    u_int8_t [ETHER_ADDR_LEN]));
     88 u_int8_t *
     89 	ne_pcmcia_dl10019_get_enaddr __P((struct ne_pcmcia_softc *,
     90 	    u_int8_t [ETHER_ADDR_LEN]));
     91 int	ne_pcmcia_ax88190_set_iobase __P((struct ne_pcmcia_softc *));
     92 
     93 CFATTACH_DECL(ne_pcmcia, sizeof(struct ne_pcmcia_softc),
     94     ne_pcmcia_match, ne_pcmcia_attach, ne_pcmcia_detach, dp8390_activate);
     95 
     96 static const struct ne2000dev {
     97     char *name;
     98     int32_t manufacturer;
     99     int32_t product;
    100     char *cis_info[4];
    101     int function;
    102     int enet_maddr;
    103     unsigned char enet_vendor[3];
    104     int flags;
    105 #define	NE2000DVF_DL10019	0x0001		/* chip is D-Link DL10019 */
    106 #define	NE2000DVF_AX88190	0x0002		/* chip is ASIX AX88190 */
    107 } ne2000devs[] = {
    108     { PCMCIA_STR_EDIMAX_EP4000A,
    109       PCMCIA_VENDOR_EDIMAX, PCMCIA_PRODUCT_EDIMAX_EP4000A,
    110       PCMCIA_CIS_EDIMAX_EP4000A,
    111       0, -1, { 0x00, 0xa0, 0x0c } },
    112 
    113     { PCMCIA_STR_SYNERGY21_S21810,
    114       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    115       PCMCIA_CIS_SYNERGY21_S21810,
    116       0, -1, { 0x00, 0x48, 0x54 } },
    117 
    118     { PCMCIA_STR_AMBICOM_AMB8002T,
    119       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    120       PCMCIA_CIS_AMBICOM_AMB8002T,
    121       0, -1, { 0x00, 0x10, 0x7a } },
    122 
    123     { PCMCIA_STR_PREMAX_PE200,
    124       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    125       PCMCIA_CIS_PREMAX_PE200,
    126       0, 0x07f0, { 0x00, 0x20, 0xe0 } },
    127 
    128     { PCMCIA_STR_DIGITAL_DEPCMXX,
    129       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    130       PCMCIA_CIS_DIGITAL_DEPCMXX,
    131       0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
    132 
    133     { PCMCIA_STR_PLANET_SMARTCOM2000,
    134       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    135       PCMCIA_CIS_PLANET_SMARTCOM2000,
    136       0, 0xff0, { 0x00, 0x00, 0xe8 } },
    137 
    138     { PCMCIA_STR_DLINK_DE660,
    139       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    140       PCMCIA_CIS_DLINK_DE660,
    141       0, -1, { 0x00, 0x80, 0xc8 } },
    142 
    143     { PCMCIA_STR_DLINK_DE660PLUS,
    144       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    145       PCMCIA_CIS_DLINK_DE660PLUS,
    146       0, -1, { 0x00, 0x80, 0xc8 } },
    147 
    148     { PCMCIA_STR_RPTI_EP400,
    149       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    150       PCMCIA_CIS_RPTI_EP400,
    151       0, -1, { 0x00, 0x40, 0x95 } },
    152 
    153     { PCMCIA_STR_RPTI_EP401,
    154       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    155       PCMCIA_CIS_RPTI_EP401,
    156       0, -1, { 0x00, 0x40, 0x95 } },
    157 
    158     { PCMCIA_STR_ACCTON_EN2212,
    159       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    160       PCMCIA_CIS_ACCTON_EN2212,
    161       0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
    162     { PCMCIA_STR_ACCTON_EN2216,
    163       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    164       PCMCIA_CIS_ACCTON_EN2216,
    165       0, -1, { 0x00, 0x00, 0xe8 } },
    166 
    167     { PCMCIA_STR_SVEC_COMBOCARD,
    168       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    169       PCMCIA_CIS_SVEC_COMBOCARD,
    170       0, -1, { 0x00, 0xe0, 0x98 } },
    171 
    172     { PCMCIA_STR_SVEC_LANCARD,
    173       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    174       PCMCIA_CIS_SVEC_LANCARD,
    175       0, 0x7f0, { 0x00, 0xc0, 0x6c } },
    176 
    177     { PCMCIA_STR_EPSON_EEN10B,
    178       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_EPSON_EEN10B,
    179       PCMCIA_CIS_EPSON_EEN10B,
    180       0, 0xff0, { 0x00, 0x00, 0x48 } },
    181 
    182     { PCMCIA_STR_CNET_NE2000,
    183       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    184       PCMCIA_CIS_CNET_NE2000,
    185       0, -1, { 0x00, 0x80, 0xad } },
    186 
    187     { PCMCIA_STR_ZONET_ZEN,
    188       PCMCIA_VENDOR_ZONET, PCMCIA_PRODUCT_ZONET_ZEN,
    189       PCMCIA_CIS_ZONET_ZEN,
    190       0, -1, { 0x00, 0x00, 0x00 } },
    191 
    192     /*
    193      * You have to add new entries which contains
    194      * PCMCIA_VENDOR_INVALID and/or PCMCIA_PRODUCT_INVALID
    195      * in front of this comment.
    196      *
    197      * There are cards which use a generic vendor and product id but needs
    198      * a different handling depending on the cis_info, so ne2000_match
    199      * needs a table where the exceptions comes first and then the normal
    200      * product and vendor entries.
    201      */
    202 
    203     { PCMCIA_STR_IBM_INFOMOVER,
    204       PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
    205       PCMCIA_CIS_IBM_INFOMOVER,
    206       0, 0x0ff0, { 0x08, 0x00, 0x5a } },
    207 
    208     { PCMCIA_STR_IBM_INFOMOVER,
    209       PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
    210       PCMCIA_CIS_IBM_INFOMOVER,
    211       0, 0x0ff0, { 0x00, 0x04, 0xac } },
    212 
    213     { PCMCIA_STR_IBM_INFOMOVER,
    214       PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
    215       PCMCIA_CIS_IBM_INFOMOVER,
    216       0, 0x0ff0, { 0x00, 0x06, 0x29 } },
    217 
    218     /* NEC 9801N_J12 */
    219     { PCMCIA_STR_IBM_INFOMOVER,
    220       PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
    221       PCMCIA_CIS_IBM_INFOMOVER,
    222       0, 0x0ff0, { 0x00, 0x00, 0x4c } },
    223 
    224     { PCMCIA_STR_LINKSYS_ECARD_1,
    225       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ECARD_1,
    226       PCMCIA_CIS_LINKSYS_ECARD_1,
    227       0, -1, { 0x00, 0x80, 0xc8 } },
    228 
    229     { PCMCIA_STR_PLANEX_FNW3600T,
    230       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
    231       PCMCIA_CIS_PLANEX_FNW3600T,
    232       0, -1, { 0x00, 0x90, 0xcc }, NE2000DVF_DL10019 },
    233 
    234     { PCMCIA_STR_SVEC_PN650TX,
    235       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
    236       PCMCIA_CIS_SVEC_PN650TX,
    237       0, -1, { 0x00, 0xe0, 0x98 }, NE2000DVF_DL10019 },
    238 
    239     /*
    240      * This entry should be here so that above two cards doesn't
    241      * match with this.  FNW-3700T won't match above entries due to
    242      * MAC address check.
    243      */
    244     { PCMCIA_STR_LANTECH_FASTNETTX,
    245       PCMCIA_VENDOR_LANTECH, PCMCIA_PRODUCT_LANTECH_FASTNETTX,
    246       PCMCIA_CIS_LANTECH_FASTNETTX,
    247       0, -1, { 0x00, 0x04, 0x1c }, NE2000DVF_AX88190 },
    248 
    249     { PCMCIA_STR_PLANEX_FNW3700T,
    250       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
    251       PCMCIA_CIS_PLANEX_FNW3700T,
    252       0, -1, { 0x00, 0x90, 0xcc }, NE2000DVF_AX88190 },
    253 
    254     { PCMCIA_STR_LINKSYS_ETHERFAST,
    255       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
    256       PCMCIA_CIS_LINKSYS_ETHERFAST,
    257       0, -1, { 0x00, 0x80, 0xc8 }, NE2000DVF_DL10019 },
    258 
    259     { PCMCIA_STR_LINKSYS_ETHERFAST,
    260       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
    261       PCMCIA_CIS_LINKSYS_ETHERFAST,
    262       0, -1, { 0x00, 0x40, 0x05 }, NE2000DVF_DL10019 },
    263 
    264     { PCMCIA_STR_LINKSYS_ETHERFAST,
    265       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
    266       PCMCIA_CIS_LINKSYS_ETHERFAST,
    267       0, -1, { 0x00, 0x90, 0xfe }, NE2000DVF_DL10019 },
    268 
    269     { PCMCIA_STR_DLINK_DE650,
    270       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
    271       PCMCIA_CIS_LINKSYS_ETHERFAST,
    272       0, -1, { 0x00, 0x50, 0xba }, NE2000DVF_DL10019 },
    273 
    274     { PCMCIA_STR_DLINK_DE650,
    275       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
    276       PCMCIA_CIS_DLINK_DE650,
    277       0, -1, { 0x00, 0xe0, 0x98 }, NE2000DVF_DL10019 },
    278 
    279     { PCMCIA_STR_DLINK_DFE670TXD,
    280       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
    281       PCMCIA_CIS_DLINK_DFE670TXD,
    282       0, -1, { 0x00, 0x50, 0xba }, NE2000DVF_DL10019 },
    283 
    284     { PCMCIA_STR_MELCO_LPC2_TX,
    285       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
    286       PCMCIA_CIS_MELCO_LPC2_TX,
    287       0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_DL10019 },
    288 
    289     { PCMCIA_STR_LINKSYS_COMBO_ECARD,
    290       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
    291       PCMCIA_CIS_LINKSYS_COMBO_ECARD,
    292       0, -1, { 0x00, 0x80, 0xc8 } },
    293 
    294     { PCMCIA_STR_LINKSYS_TRUST_COMBO_ECARD,
    295       PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_TRUST_COMBO_ECARD,
    296       PCMCIA_CIS_LINKSYS_TRUST_COMBO_ECARD,
    297       0, 0x0120, { 0x20, 0x04, 0x49 } },
    298 
    299     /* Although the comments above say to put VENDOR/PRODUCT INVALID IDs
    300        above this list, we need to keep this one below the ECARD_1, or else
    301        both will match the same more-generic entry rather than the more
    302        specific one above with proper vendor and product IDs. */
    303     { PCMCIA_STR_LINKSYS_ECARD_2,
    304       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    305       PCMCIA_CIS_LINKSYS_ECARD_2,
    306       0, -1, { 0x00, 0x80, 0xc8 } },
    307 
    308     /*
    309      * D-Link DE-650 has many minor versions:
    310      *
    311      *   CIS information          Manufacturer Product  Note
    312      * 1 "D-Link, DE-650"             INVALID  INVALID  white card
    313      * 2 "D-Link, DE-650, Ver 01.00"  INVALID  INVALID  became bare metal
    314      * 3 "D-Link, DE-650, Ver 01.00"   0x149    0x265   minor change in look
    315      * 4 "D-Link, DE-650, Ver 01.00"   0x149    0x265   collision LED added
    316      *
    317      * While the 1st and the 2nd types should use the "D-Link DE-650" entry,
    318      * the 3rd and the 4th types should use the "Linksys EtherCard" entry.
    319      * Therefore, this enty must be below the LINKSYS_ECARD_1.  --itohy
    320      */
    321     { PCMCIA_STR_DLINK_DE650,
    322       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    323       PCMCIA_CIS_DLINK_DE650,
    324       0, 0x0040, { 0x00, 0x80, 0xc8 } },
    325 
    326     /*
    327      * IO-DATA PCLA/TE and later version of PCLA/T has valid
    328      * vendor/product ID and it is possible to read MAC address
    329      * using standard I/O ports.  It also read from CIS offset 0x01c0.
    330      * On the other hand, earlier version of PCLA/T doesn't have valid
    331      * vendor/product ID and MAC address must be read from CIS offset
    332      * 0x0ff0 (i.e., usual ne2000 way to read it doesn't work).
    333      * And CIS information of earlier and later version of PCLA/T are
    334      * same except fourth element.  So, for now, we place the entry for
    335      * PCLA/TE (and later version of PCLA/T) followed by entry
    336      * for the earlier version of PCLA/T (or, modify to match all CIS
    337      * information and have three or more individual entries).
    338      */
    339     { PCMCIA_STR_IODATA_PCLATE,
    340       PCMCIA_VENDOR_IODATA, PCMCIA_PRODUCT_IODATA_PCLATE,
    341       PCMCIA_CIS_IODATA_PCLATE,
    342       0, -1, { 0x00, 0xa0, 0xb0 } },
    343 
    344     /*
    345      * This entry should be placed after above PCLA-TE entry.
    346      * See above comments for detail.
    347      */
    348     { PCMCIA_STR_IODATA_PCLAT,
    349       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    350       PCMCIA_CIS_IODATA_PCLAT,
    351       0, 0x0ff0, { 0x00, 0xa0, 0xb0 } },
    352 
    353     { PCMCIA_STR_DAYNA_COMMUNICARD_E_1,
    354       PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_1,
    355       PCMCIA_CIS_DAYNA_COMMUNICARD_E_1,
    356       0, 0x0110, { 0x00, 0x80, 0x19 } },
    357 
    358     { PCMCIA_STR_DAYNA_COMMUNICARD_E_2,
    359       PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_2,
    360       PCMCIA_CIS_DAYNA_COMMUNICARD_E_2,
    361       0, -1, { 0x00, 0x80, 0x19 } },
    362 
    363     { PCMCIA_STR_COREGA_ETHER_PCC_T,
    364       PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_T,
    365       PCMCIA_CIS_COREGA_ETHER_PCC_T,
    366       0, -1, { 0x00, 0x00, 0xf4 } },
    367 
    368     { PCMCIA_STR_COREGA_ETHER_PCC_TD,
    369       PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_TD,
    370       PCMCIA_CIS_COREGA_ETHER_PCC_TD,
    371       0, -1, { 0x00, 0x00, 0xf4 } },
    372 
    373     { PCMCIA_STR_COREGA_ETHER_II_PCC_T,
    374       PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_T,
    375       PCMCIA_CIS_COREGA_ETHER_II_PCC_T,
    376       0, -1, { 0x00, 0x00, 0xf4 } },
    377 
    378     { PCMCIA_STR_COREGA_ETHER_II_PCC_TD,
    379       PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_TD,
    380       PCMCIA_CIS_COREGA_ETHER_II_PCC_TD,
    381       0, -1, { 0x00, 0x00, 0xf4 } },
    382 
    383     { PCMCIA_STR_COREGA_FAST_ETHER_PCC_TX,
    384       PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FAST_ETHER_PCC_TX,
    385       PCMCIA_CIS_COREGA_FAST_ETHER_PCC_TX,
    386       0, -1, { 0x00, 0x00, 0xf4 }, NE2000DVF_DL10019 },
    387 
    388     { PCMCIA_STR_COREGA_FETHER_PCC_TXF,
    389       PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXF,
    390       PCMCIA_CIS_COREGA_FETHER_PCC_TXF,
    391       0, -1, { 0x00, 0x90, 0x99 }, NE2000DVF_DL10019 },
    392 
    393     { PCMCIA_STR_COREGA_FETHER_PCC_TXD,
    394       PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXD,
    395       PCMCIA_CIS_COREGA_FETHER_PCC_TXD,
    396       0, -1, { 0x00, 0x90, 0x99 } },
    397 
    398     { PCMCIA_STR_COMPEX_LINKPORT_ENET_B,
    399       PCMCIA_VENDOR_COMPEX, PCMCIA_PRODUCT_COMPEX_LINKPORT_ENET_B,
    400       PCMCIA_CIS_COMPEX_LINKPORT_ENET_B,
    401       0, 0x01c0, { 0x00, 0xa0, 0x0c } },
    402 
    403     { PCMCIA_STR_SMC_EZCARD,
    404       PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_EZCARD,
    405       PCMCIA_CIS_SMC_EZCARD,
    406       0, 0x01c0, { 0x00, 0xe0, 0x29 } },
    407 
    408     { PCMCIA_STR_SMC_8041,
    409       PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_8041,
    410       PCMCIA_CIS_SMC_8041,
    411       0, -1, { 0x00, 0x04, 0xe2 } },
    412 
    413     { PCMCIA_STR_SOCKET_EA_ETHER,
    414       PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_EA_ETHER,
    415       PCMCIA_CIS_SOCKET_EA_ETHER,
    416       0, -1, { 0x00, 0xc0, 0x1b } },
    417 
    418     { PCMCIA_STR_SOCKET_LP_ETHER_CF,
    419       PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER_CF,
    420       PCMCIA_CIS_SOCKET_LP_ETHER_CF,
    421       0, -1, { 0x00, 0xc0, 0x1b } },
    422 
    423     { PCMCIA_STR_SOCKET_LP_ETHER,
    424       PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER,
    425       PCMCIA_CIS_SOCKET_LP_ETHER,
    426       0, -1, { 0x00, 0xc0, 0x1b } },
    427 
    428     { PCMCIA_STR_KINGSTON_KNE2,
    429       PCMCIA_VENDOR_KINGSTON, PCMCIA_PRODUCT_KINGSTON_KNE2,
    430       PCMCIA_CIS_KINGSTON_KNE2,
    431       0, -1, { 0x00, 0xc0, 0xf0 } },
    432 
    433     { PCMCIA_STR_XIRCOM_CFE_10,
    434       PCMCIA_VENDOR_XIRCOM, PCMCIA_PRODUCT_XIRCOM_CFE_10,
    435       PCMCIA_CIS_XIRCOM_CFE_10,
    436       0, -1, { 0x00, 0x10, 0xa4 } },
    437 
    438     { PCMCIA_STR_MELCO_LPC3_TX,
    439       PCMCIA_VENDOR_MELCO, PCMCIA_PRODUCT_MELCO_LPC3_TX,
    440       PCMCIA_CIS_MELCO_LPC3_TX,
    441       0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
    442 
    443     { PCMCIA_STR_BUFFALO_LPC3_CLT,
    444       PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC3_CLT,
    445       PCMCIA_CIS_BUFFALO_LPC3_CLT,
    446       0, -1, { 0x00, 0x07, 0x40 } },
    447 
    448     { PCMCIA_STR_BILLIONTON_LNT10TN,
    449       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    450       PCMCIA_CIS_BILLIONTON_LNT10TN,
    451       0, -1, { 0x00, 0x00, 0x00 } },
    452 
    453     { PCMCIA_STR_NDC_ND5100_E,
    454       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    455       PCMCIA_CIS_NDC_ND5100_E,
    456       0, -1, { 0x00, 0x80, 0xc6 } },
    457 
    458     { PCMCIA_STR_TELECOMDEVICE_TCD_HPC100,
    459       PCMCIA_VENDOR_TELECOMDEVICE, PCMCIA_PRODUCT_TELECOMDEVICE_TCD_HPC100,
    460       PCMCIA_CIS_TELECOMDEVICE_TCD_HPC100,
    461       0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
    462 
    463     { PCMCIA_STR_MACNICA_ME1_JEIDA,
    464       PCMCIA_VENDOR_MACNICA, PCMCIA_PRODUCT_MACNICA_ME1_JEIDA,
    465       PCMCIA_CIS_MACNICA_ME1_JEIDA,
    466       0, 0x00b8, { 0x08, 0x00, 0x42 } },
    467 
    468     { PCMCIA_STR_NETGEAR_FA411,
    469       PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA411,
    470       PCMCIA_CIS_NETGEAR_FA411,
    471       0, -1, { 0x00, 0x40, 0xf4 } },
    472 
    473     { PCMCIA_STR_DYNALINK_L10C,
    474       PCMCIA_VENDOR_DYNALINK, PCMCIA_PRODUCT_DYNALINK_L10C,
    475       PCMCIA_CIS_DYNALINK_L10C,
    476       0, -1, { 0x00, 0x00, 0x00 } },
    477 
    478 #if 0
    479     /* the rest of these are stolen from the linux pcnet pcmcia device
    480        driver.  Since I don't know the manfid or cis info strings for
    481        any of them, they're not compiled in until I do. */
    482     { "APEX MultiCard",
    483       0x0000, 0x0000, NULL, NULL, 0,
    484       0x03f4, { 0x00, 0x20, 0xe5 } },
    485     { "ASANTE FriendlyNet",
    486       0x0000, 0x0000, NULL, NULL, 0,
    487       0x4910, { 0x00, 0x00, 0x94 } },
    488     { "Danpex EN-6200P2",
    489       0x0000, 0x0000, NULL, NULL, 0,
    490       0x0110, { 0x00, 0x40, 0xc7 } },
    491     { "DataTrek NetCard",
    492       0x0000, 0x0000, NULL, NULL, 0,
    493       0x0ff0, { 0x00, 0x20, 0xe8 } },
    494     { "Dayna CommuniCard E",
    495       0x0000, 0x0000, NULL, NULL, 0,
    496       0x0110, { 0x00, 0x80, 0x19 } },
    497     { "EP-210 Ethernet",
    498       0x0000, 0x0000, NULL, NULL, 0,
    499       0x0110, { 0x00, 0x40, 0x33 } },
    500     { "ELECOM Laneed LD-CDWA",
    501       0x0000, 0x0000, NULL, NULL, 0,
    502       0x00b8, { 0x08, 0x00, 0x42 } },
    503     { "Grey Cell GCS2220",
    504       0x0000, 0x0000, NULL, NULL, 0,
    505       0x0000, { 0x00, 0x47, 0x43 } },
    506     { "Hypertec Ethernet",
    507       0x0000, 0x0000, NULL, NULL, 0,
    508       0x01c0, { 0x00, 0x40, 0x4c } },
    509     { "IBM CCAE",
    510       0x0000, 0x0000, NULL, NULL, 0,
    511       0x0ff0, { 0x08, 0x00, 0x5a } },
    512     { "IBM CCAE",
    513       0x0000, 0x0000, NULL, NULL, 0,
    514       0x0ff0, { 0x00, 0x04, 0xac } },
    515     { "IBM CCAE",
    516       0x0000, 0x0000, NULL, NULL, 0,
    517       0x0ff0, { 0x00, 0x06, 0x29 } },
    518     { "IBM FME",
    519       0x0000, 0x0000, NULL, NULL, 0,
    520       0x0374, { 0x00, 0x04, 0xac } },
    521     { "IBM FME",
    522       0x0000, 0x0000, NULL, NULL, 0,
    523       0x0374, { 0x08, 0x00, 0x5a } },
    524     { "Katron PE-520",
    525       0x0000, 0x0000, NULL, NULL, 0,
    526       0x0110, { 0x00, 0x40, 0xf6 } },
    527     { "Kingston KNE-PCM/x",
    528       0x0000, 0x0000, NULL, NULL, 0,
    529       0x0ff0, { 0x00, 0xc0, 0xf0 } },
    530     { "Kingston KNE-PCM/x",
    531       0x0000, 0x0000, NULL, NULL, 0,
    532       0x0ff0, { 0xe2, 0x0c, 0x0f } },
    533     { "Longshine LCS-8534",
    534       0x0000, 0x0000, NULL, NULL, 0,
    535       0x0000, { 0x08, 0x00, 0x00 } },
    536     { "Maxtech PCN2000",
    537       0x0000, 0x0000, NULL, NULL, 0,
    538       0x5000, { 0x00, 0x00, 0xe8 } },
    539     { "NDC Instant-Link",
    540       0x0000, 0x0000, NULL, NULL, 0,
    541       0x003a, { 0x00, 0x80, 0xc6 } },
    542     { "NE2000 Compatible",
    543       0x0000, 0x0000, NULL, NULL, 0,
    544       0x0ff0, { 0x00, 0xa0, 0x0c } },
    545     { "Network General Sniffer",
    546       0x0000, 0x0000, NULL, NULL, 0,
    547       0x0ff0, { 0x00, 0x00, 0x65 } },
    548     { "Panasonic VEL211",
    549       0x0000, 0x0000, NULL, NULL, 0,
    550       0x0ff0, { 0x00, 0x80, 0x45 } },
    551     { "SCM Ethernet",
    552       0x0000, 0x0000, NULL, NULL, 0,
    553       0x0ff0, { 0x00, 0x20, 0xcb } },
    554     { "Volktek NPL-402CT",
    555       0x0000, 0x0000, NULL, NULL, 0,
    556       0x0060, { 0x00, 0x40, 0x05 } },
    557 #endif
    558 
    559     { PCMCIA_STR_ALLIEDTELESIS_LA_PCM,
    560       PCMCIA_VENDOR_ALLIEDTELESIS, PCMCIA_PRODUCT_ALLIEDTELESIS_LA_PCM,
    561       PCMCIA_CIS_ALLIEDTELESIS_LA_PCM,
    562       0, 0x0ff0, { 0x00, 0x00, 0xf4 } },
    563 };
    564 
    565 #define	NE2000_NDEVS	(sizeof(ne2000devs) / sizeof(ne2000devs[0]))
    566 
    567 #define ne2000_match(card, fct, n) \
    568 ((((((card)->manufacturer != PCMCIA_VENDOR_INVALID) && \
    569     ((card)->manufacturer == ne2000devs[(n)].manufacturer) && \
    570     ((card)->product != PCMCIA_PRODUCT_INVALID) && \
    571     ((card)->product == ne2000devs[(n)].product)) || \
    572    ((ne2000devs[(n)].cis_info[0]) && (ne2000devs[(n)].cis_info[1]) && \
    573     (strcmp((card)->cis1_info[0], ne2000devs[(n)].cis_info[0]) == 0) && \
    574     (strcmp((card)->cis1_info[1], ne2000devs[(n)].cis_info[1]) == 0))) && \
    575   ((fct) == ne2000devs[(n)].function))? \
    576  &ne2000devs[(n)]:NULL)
    577 
    578 int
    579 ne_pcmcia_match(parent, match, aux)
    580 	struct device *parent;
    581 	struct cfdata *match;
    582 	void *aux;
    583 {
    584 	struct pcmcia_attach_args *pa = aux;
    585 	int i;
    586 
    587 	for (i = 0; i < NE2000_NDEVS; i++) {
    588 		if (ne2000_match(pa->card, pa->pf->number, i))
    589 			return (1);
    590 	}
    591 
    592 	return (0);
    593 }
    594 
    595 void
    596 ne_pcmcia_attach(parent, self, aux)
    597 	struct device *parent, *self;
    598 	void *aux;
    599 {
    600 	struct ne_pcmcia_softc *psc = (void *) self;
    601 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    602 	struct dp8390_softc *dsc = &nsc->sc_dp8390;
    603 	struct pcmcia_attach_args *pa = aux;
    604 	struct pcmcia_config_entry *cfe;
    605 	const struct ne2000dev *ne_dev;
    606 	int i;
    607 	u_int8_t myea[6], *enaddr;
    608 	const char *typestr = "";
    609 
    610 	psc->sc_pf = pa->pf;
    611 
    612 	SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
    613 #if 0
    614 		/*
    615 		 * Some ne2000 driver's claim to have memory; others don't.
    616 		 * Since I don't care, I don't check.
    617 		 */
    618 
    619 		if (cfe->num_memspace != 1) {
    620 			printf(": unexpected number of memory spaces "
    621 			    " %d should be 1\n", cfe->num_memspace);
    622 			continue;
    623 		}
    624 #endif
    625 
    626 		if (cfe->num_iospace == 1) {
    627 			if (cfe->iospace[0].length != NE2000_NPORTS) {
    628 				printf(": unexpected I/O space configuration"
    629 				    " (continued)\n%s", dsc->sc_dev.dv_xname);
    630 				/* XXX really safe for all other cards? */
    631 			}
    632 		} else if (cfe->num_iospace == 2) {
    633 			/*
    634 			 * Some cards report a separate space for NIC and ASIC.
    635 			 * This make some sense, but we must allocate a single
    636 			 * NE2000_NPORTS-sized chunk, due to brain damaged
    637 			 * address decoders on some of these cards.
    638 			 */
    639 			if (cfe->iospace[0].length + cfe->iospace[1].length !=
    640 			    NE2000_NPORTS) {
    641 #ifdef DIAGNOSTIC
    642 				printf(": unexpected I/O "
    643 				    "space configuration; ignored\n%s",
    644 				    dsc->sc_dev.dv_xname);
    645 #endif
    646 				continue;
    647 			}
    648 		} else {
    649 #ifdef DIAGNOSTIC
    650 			printf(": unexpected number of i/o spaces %d"
    651 			    " should be 1 or 2; ignored\n%s",
    652 			    cfe->num_iospace, dsc->sc_dev.dv_xname);
    653 #endif
    654 			continue;
    655 		}
    656 
    657 		if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
    658 		    NE2000_NPORTS, NE2000_NPORTS, &psc->sc_pcioh)) {
    659 #ifdef DIAGNOSTIC
    660 			printf(": can't allocate i/o space %lx; ignored\n%s",
    661 			    cfe->iospace[0].start, dsc->sc_dev.dv_xname);
    662 #endif
    663 			continue;
    664 		}
    665 
    666 		/* Ok, found. */
    667 		break;
    668 	}
    669 
    670 	if (cfe == NULL) {
    671 		printf(": no suitable config entry\n");
    672 		goto fail_1;
    673 	}
    674 
    675 	dsc->sc_regt = psc->sc_pcioh.iot;
    676 	dsc->sc_regh = psc->sc_pcioh.ioh;
    677 
    678 	nsc->sc_asict = psc->sc_pcioh.iot;
    679 	if (bus_space_subregion(dsc->sc_regt, dsc->sc_regh,
    680 	    NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
    681 	    &nsc->sc_asich)) {
    682 		printf(": can't get subregion for asic\n");
    683 		goto fail_2;
    684 	}
    685 
    686 	/* Set up power management hooks. */
    687 	dsc->sc_enable = ne_pcmcia_enable;
    688 	dsc->sc_disable = ne_pcmcia_disable;
    689 
    690 	/* Enable the card. */
    691 	pcmcia_function_init(pa->pf, cfe);
    692 	if (pcmcia_function_enable(pa->pf)) {
    693 		printf(": function enable failed\n");
    694 		goto fail_2;
    695 	}
    696 
    697 	/* some cards claim to be io16, but they're lying. */
    698 	if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO8,
    699 	    NE2000_NIC_OFFSET, NE2000_NIC_NPORTS,
    700 	    &psc->sc_pcioh, &psc->sc_nic_io_window)) {
    701 		printf(": can't map NIC i/o space\n");
    702 		goto fail_3;
    703 	}
    704 
    705 	if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16,
    706 	    NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
    707 	    &psc->sc_pcioh, &psc->sc_asic_io_window)) {
    708 		printf(": can't map ASIC i/o space\n");
    709 		goto fail_4;
    710 	}
    711 
    712 	printf("\n");
    713 
    714 	/*
    715 	 * Read the station address from the board.
    716 	 */
    717 	i = 0;
    718 again:
    719 	enaddr = NULL;			/* Ask ASIC by default */
    720 	typestr = "";			/* clear previous card-type */
    721 	for (; i < NE2000_NDEVS; i++) {
    722 		ne_dev = ne2000_match(pa->card, pa->pf->number, i);
    723 		if (ne_dev != NULL) {
    724 			if (ne_dev->enet_maddr >= 0) {
    725 				enaddr = ne_pcmcia_get_enaddr(psc,
    726 				    ne_dev->enet_maddr, myea);
    727 				if (enaddr == NULL)
    728 					continue;
    729 			}
    730 			break;
    731 		}
    732 	}
    733 	if (i == NE2000_NDEVS) {
    734 		printf("%s (manf %08x prod %08x) cis %s %s: "
    735 		       "can't match ethernet vendor code\n",
    736 		       dsc->sc_dev.dv_xname,
    737 		       pa->manufacturer, pa->product,
    738 		       pa->card->cis1_info[0], pa->card->cis1_info[1]);
    739 		goto fail_5;
    740 	}
    741 
    742 	if ((ne_dev->flags & NE2000DVF_DL10019) != 0) {
    743 		u_int8_t type;
    744 
    745 		enaddr = ne_pcmcia_dl10019_get_enaddr(psc, myea);
    746 		if (enaddr == NULL) {
    747 			++i;
    748 			goto again;
    749 		}
    750 
    751 		dsc->sc_mediachange = dl10019_mediachange;
    752 		dsc->sc_mediastatus = dl10019_mediastatus;
    753 		dsc->init_card = dl10019_init_card;
    754 		dsc->stop_card = dl10019_stop_card;
    755 		dsc->sc_media_init = dl10019_media_init;
    756 		dsc->sc_media_fini = dl10019_media_fini;
    757 
    758 		/* Determine if this is a DL10019 or a DL10022. */
    759 		type = bus_space_read_1(nsc->sc_asict, nsc->sc_asich, 0x0f);
    760 		if (type == 0x91 || type == 0x99) {
    761 			nsc->sc_type = NE2000_TYPE_DL10022;
    762 			typestr = " (DL10022)";
    763 		} else {
    764 			nsc->sc_type = NE2000_TYPE_DL10019;
    765 			typestr = " (DL10019)";
    766 		}
    767 	}
    768 
    769 	if ((ne_dev->flags & NE2000DVF_AX88190) != 0) {
    770 		if (ne_pcmcia_ax88190_set_iobase(psc)) {
    771 			++i;
    772 			goto again;
    773 		}
    774 
    775 		dsc->sc_mediachange = ax88190_mediachange;
    776 		dsc->sc_mediastatus = ax88190_mediastatus;
    777 		dsc->init_card = ax88190_init_card;
    778 		dsc->stop_card = ax88190_stop_card;
    779 		dsc->sc_media_init = ax88190_media_init;
    780 		dsc->sc_media_fini = ax88190_media_fini;
    781 
    782 		nsc->sc_type = NE2000_TYPE_AX88190;
    783 		typestr = " (AX88190)";
    784 	}
    785 
    786 	if (enaddr != NULL) {
    787 		/*
    788 		 * Make sure this is what we expect.
    789 		 */
    790 		if (enaddr[0] != ne_dev->enet_vendor[0] ||
    791 		    enaddr[1] != ne_dev->enet_vendor[1] ||
    792 		    enaddr[2] != ne_dev->enet_vendor[2]) {
    793 			++i;
    794 			goto again;
    795 		}
    796 	}
    797 
    798 	/*
    799 	 * Check for a RealTek 8019.
    800 	 */
    801 	if (nsc->sc_type == 0) {
    802 		bus_space_write_1(dsc->sc_regt, dsc->sc_regh, ED_P0_CR,
    803 		    ED_CR_PAGE_0 | ED_CR_STP);
    804 		if (bus_space_read_1(dsc->sc_regt, dsc->sc_regh,
    805 		    NERTL_RTL0_8019ID0) == RTL0_8019ID0 &&
    806 		    bus_space_read_1(dsc->sc_regt, dsc->sc_regh,
    807 		    NERTL_RTL0_8019ID1) == RTL0_8019ID1) {
    808 			typestr = " (RTL8019)";
    809 			dsc->sc_mediachange = rtl80x9_mediachange;
    810 			dsc->sc_mediastatus = rtl80x9_mediastatus;
    811 			dsc->init_card = rtl80x9_init_card;
    812 			dsc->sc_media_init = rtl80x9_media_init;
    813 		}
    814 	}
    815 
    816 	printf("%s: %s%s Ethernet\n", dsc->sc_dev.dv_xname, ne_dev->name,
    817 	    typestr);
    818 
    819 	if (ne2000_attach(nsc, enaddr))
    820 		goto fail_5;
    821 
    822 	pcmcia_function_disable(pa->pf);
    823 	return;
    824 
    825  fail_5:
    826 	/* Unmap ASIC i/o windows. */
    827 	pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
    828 
    829  fail_4:
    830 	/* Unmap NIC i/o windows. */
    831 	pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
    832 
    833  fail_3:
    834 	pcmcia_function_disable(pa->pf);
    835 
    836  fail_2:
    837 	/* Free our i/o space. */
    838 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    839 
    840  fail_1:
    841 	psc->sc_nic_io_window = -1;
    842 }
    843 
    844 int
    845 ne_pcmcia_detach(self, flags)
    846 	struct device *self;
    847 	int flags;
    848 {
    849 	struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)self;
    850 	int error;
    851 
    852 	if (psc->sc_nic_io_window == -1)
    853 		/* Nothing to detach. */
    854 		return (0);
    855 
    856 	error = ne2000_detach(&psc->sc_ne2000, flags);
    857 	if (error != 0)
    858 		return (error);
    859 
    860 	/* Unmap our i/o windows. */
    861 	pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
    862 	pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
    863 
    864 	/* Free our i/o space. */
    865 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    866 
    867 	return (0);
    868 }
    869 
    870 int
    871 ne_pcmcia_enable(dsc)
    872 	struct dp8390_softc *dsc;
    873 {
    874 	struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
    875 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    876 
    877 	/* set up the interrupt */
    878 	psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr,
    879 	    dsc);
    880 	if (psc->sc_ih == NULL) {
    881 		printf("%s: couldn't establish interrupt\n",
    882 		    dsc->sc_dev.dv_xname);
    883 		goto fail_1;
    884 	}
    885 
    886 	if (pcmcia_function_enable(psc->sc_pf))
    887 		goto fail_2;
    888 
    889 	if (nsc->sc_type == NE2000_TYPE_AX88190)
    890 		if (ne_pcmcia_ax88190_set_iobase(psc))
    891 			goto fail_3;
    892 
    893 	return (0);
    894 
    895  fail_3:
    896 	pcmcia_function_disable(psc->sc_pf);
    897  fail_2:
    898 	pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
    899  fail_1:
    900 	return (1);
    901 }
    902 
    903 void
    904 ne_pcmcia_disable(dsc)
    905 	struct dp8390_softc *dsc;
    906 {
    907 	struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
    908 
    909 	pcmcia_function_disable(psc->sc_pf);
    910 	pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
    911 }
    912 
    913 u_int8_t *
    914 ne_pcmcia_get_enaddr(psc, maddr, myea)
    915 	struct ne_pcmcia_softc *psc;
    916 	int maddr;
    917 	u_int8_t myea[ETHER_ADDR_LEN];
    918 {
    919 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    920 	struct dp8390_softc *dsc = &nsc->sc_dp8390;
    921 	struct pcmcia_mem_handle pcmh;
    922 	bus_size_t offset;
    923 	u_int8_t *enaddr = NULL;
    924 	int j, mwindow;
    925 
    926 	if (maddr < 0)
    927 		return (NULL);
    928 
    929 	if (pcmcia_mem_alloc(psc->sc_pf, ETHER_ADDR_LEN * 2, &pcmh)) {
    930 		printf("%s: can't alloc mem for enet addr\n",
    931 		    dsc->sc_dev.dv_xname);
    932 		goto fail_1;
    933 	}
    934 	if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, maddr,
    935 	    ETHER_ADDR_LEN * 2, &pcmh, &offset, &mwindow)) {
    936 		printf("%s: can't map mem for enet addr\n",
    937 		    dsc->sc_dev.dv_xname);
    938 		goto fail_2;
    939 	}
    940 	for (j = 0; j < ETHER_ADDR_LEN; j++)
    941 		myea[j] = bus_space_read_1(pcmh.memt, pcmh.memh,
    942 		    offset + (j * 2));
    943 	enaddr = myea;
    944 
    945 	pcmcia_mem_unmap(psc->sc_pf, mwindow);
    946  fail_2:
    947 	pcmcia_mem_free(psc->sc_pf, &pcmh);
    948  fail_1:
    949 	return (enaddr);
    950 }
    951 
    952 u_int8_t *
    953 ne_pcmcia_dl10019_get_enaddr(psc, myea)
    954 	struct ne_pcmcia_softc *psc;
    955 	u_int8_t myea[ETHER_ADDR_LEN];
    956 {
    957 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    958 	u_int8_t sum;
    959 	int j;
    960 
    961 #define PAR0	0x04
    962 	for (j = 0, sum = 0; j < 8; j++)
    963 		sum += bus_space_read_1(nsc->sc_asict, nsc->sc_asich,
    964 		    PAR0 + j);
    965 	if (sum != 0xff)
    966 		return (NULL);
    967 	for (j = 0; j < ETHER_ADDR_LEN; j++)
    968 		myea[j] = bus_space_read_1(nsc->sc_asict,
    969 		    nsc->sc_asich, PAR0 + j);
    970 #undef PAR0
    971 	return (myea);
    972 }
    973 
    974 int
    975 ne_pcmcia_ax88190_set_iobase(psc)
    976 	struct ne_pcmcia_softc *psc;
    977 {
    978 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    979 	struct dp8390_softc *dsc = &nsc->sc_dp8390;
    980 	struct pcmcia_mem_handle pcmh;
    981 	bus_size_t offset;
    982 	int rv = 1, mwindow;
    983 	u_int last_liobase, new_liobase;
    984 
    985 	if (pcmcia_mem_alloc(psc->sc_pf, AX88190_LAN_IOSIZE, &pcmh)) {
    986 #if 0
    987 		printf("%s: can't alloc mem for LAN iobase\n",
    988 		    dsc->sc_dev.dv_xname);
    989 #endif
    990 		goto fail_1;
    991 	}
    992 	if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR,
    993 	    AX88190_LAN_IOBASE, AX88190_LAN_IOSIZE,
    994 	    &pcmh, &offset, &mwindow)) {
    995 		printf("%s: can't map mem for LAN iobase\n",
    996 		    dsc->sc_dev.dv_xname);
    997 		goto fail_2;
    998 	}
    999 
   1000 	last_liobase = bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
   1001 	    (bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8);
   1002 #ifdef DIAGNOSTIC
   1003 	printf("%s: LAN iobase 0x%x (0x%x) ->", dsc->sc_dev.dv_xname,
   1004 	    last_liobase, (u_int)psc->sc_pcioh.addr);
   1005 #endif
   1006 	bus_space_write_1(pcmh.memt, pcmh.memh, offset,
   1007 	    psc->sc_pcioh.addr & 0xff);
   1008 	bus_space_write_1(pcmh.memt, pcmh.memh, offset + 2,
   1009 	    psc->sc_pcioh.addr >> 8);
   1010 
   1011 	new_liobase = bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
   1012 	    (bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8);
   1013 #ifdef DIAGNOSTIC
   1014 	printf(" 0x%x\n", new_liobase);
   1015 #endif
   1016 	if ((last_liobase == psc->sc_pcioh.addr)
   1017 	    || (last_liobase != new_liobase))
   1018 		rv = 0;
   1019 
   1020 	pcmcia_mem_unmap(psc->sc_pf, mwindow);
   1021  fail_2:
   1022 	pcmcia_mem_free(psc->sc_pf, &pcmh);
   1023  fail_1:
   1024 	return (rv);
   1025 }
   1026