Home | History | Annotate | Line # | Download | only in pcmcia
if_ne_pcmcia.c revision 1.101
      1 /*	$NetBSD: if_ne_pcmcia.c,v 1.101 2003/04/09 02:09:55 christos 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.101 2003/04/09 02:09:55 christos 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_BILLIONTON_CFLT10N,
    454       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    455       PCMCIA_CIS_BILLIONTON_CFLT10N,
    456       0, -1, { 0x00, 0x00, 0x00 } },
    457 
    458     { PCMCIA_STR_NDC_ND5100_E,
    459       PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
    460       PCMCIA_CIS_NDC_ND5100_E,
    461       0, -1, { 0x00, 0x80, 0xc6 } },
    462 
    463     { PCMCIA_STR_TELECOMDEVICE_TCD_HPC100,
    464       PCMCIA_VENDOR_TELECOMDEVICE, PCMCIA_PRODUCT_TELECOMDEVICE_TCD_HPC100,
    465       PCMCIA_CIS_TELECOMDEVICE_TCD_HPC100,
    466       0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
    467 
    468     { PCMCIA_STR_MACNICA_ME1_JEIDA,
    469       PCMCIA_VENDOR_MACNICA, PCMCIA_PRODUCT_MACNICA_ME1_JEIDA,
    470       PCMCIA_CIS_MACNICA_ME1_JEIDA,
    471       0, 0x00b8, { 0x08, 0x00, 0x42 } },
    472 
    473     { PCMCIA_STR_NETGEAR_FA411,
    474       PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA411,
    475       PCMCIA_CIS_NETGEAR_FA411,
    476       0, -1, { 0x00, 0x40, 0xf4 } },
    477 
    478     { PCMCIA_STR_DYNALINK_L10C,
    479       PCMCIA_VENDOR_DYNALINK, PCMCIA_PRODUCT_DYNALINK_L10C,
    480       PCMCIA_CIS_DYNALINK_L10C,
    481       0, -1, { 0x00, 0x00, 0x00 } },
    482 
    483 #if 0
    484     /* the rest of these are stolen from the linux pcnet pcmcia device
    485        driver.  Since I don't know the manfid or cis info strings for
    486        any of them, they're not compiled in until I do. */
    487     { "APEX MultiCard",
    488       0x0000, 0x0000, NULL, NULL, 0,
    489       0x03f4, { 0x00, 0x20, 0xe5 } },
    490     { "ASANTE FriendlyNet",
    491       0x0000, 0x0000, NULL, NULL, 0,
    492       0x4910, { 0x00, 0x00, 0x94 } },
    493     { "Danpex EN-6200P2",
    494       0x0000, 0x0000, NULL, NULL, 0,
    495       0x0110, { 0x00, 0x40, 0xc7 } },
    496     { "DataTrek NetCard",
    497       0x0000, 0x0000, NULL, NULL, 0,
    498       0x0ff0, { 0x00, 0x20, 0xe8 } },
    499     { "Dayna CommuniCard E",
    500       0x0000, 0x0000, NULL, NULL, 0,
    501       0x0110, { 0x00, 0x80, 0x19 } },
    502     { "EP-210 Ethernet",
    503       0x0000, 0x0000, NULL, NULL, 0,
    504       0x0110, { 0x00, 0x40, 0x33 } },
    505     { "ELECOM Laneed LD-CDWA",
    506       0x0000, 0x0000, NULL, NULL, 0,
    507       0x00b8, { 0x08, 0x00, 0x42 } },
    508     { "Grey Cell GCS2220",
    509       0x0000, 0x0000, NULL, NULL, 0,
    510       0x0000, { 0x00, 0x47, 0x43 } },
    511     { "Hypertec Ethernet",
    512       0x0000, 0x0000, NULL, NULL, 0,
    513       0x01c0, { 0x00, 0x40, 0x4c } },
    514     { "IBM CCAE",
    515       0x0000, 0x0000, NULL, NULL, 0,
    516       0x0ff0, { 0x08, 0x00, 0x5a } },
    517     { "IBM CCAE",
    518       0x0000, 0x0000, NULL, NULL, 0,
    519       0x0ff0, { 0x00, 0x04, 0xac } },
    520     { "IBM CCAE",
    521       0x0000, 0x0000, NULL, NULL, 0,
    522       0x0ff0, { 0x00, 0x06, 0x29 } },
    523     { "IBM FME",
    524       0x0000, 0x0000, NULL, NULL, 0,
    525       0x0374, { 0x00, 0x04, 0xac } },
    526     { "IBM FME",
    527       0x0000, 0x0000, NULL, NULL, 0,
    528       0x0374, { 0x08, 0x00, 0x5a } },
    529     { "Katron PE-520",
    530       0x0000, 0x0000, NULL, NULL, 0,
    531       0x0110, { 0x00, 0x40, 0xf6 } },
    532     { "Kingston KNE-PCM/x",
    533       0x0000, 0x0000, NULL, NULL, 0,
    534       0x0ff0, { 0x00, 0xc0, 0xf0 } },
    535     { "Kingston KNE-PCM/x",
    536       0x0000, 0x0000, NULL, NULL, 0,
    537       0x0ff0, { 0xe2, 0x0c, 0x0f } },
    538     { "Longshine LCS-8534",
    539       0x0000, 0x0000, NULL, NULL, 0,
    540       0x0000, { 0x08, 0x00, 0x00 } },
    541     { "Maxtech PCN2000",
    542       0x0000, 0x0000, NULL, NULL, 0,
    543       0x5000, { 0x00, 0x00, 0xe8 } },
    544     { "NDC Instant-Link",
    545       0x0000, 0x0000, NULL, NULL, 0,
    546       0x003a, { 0x00, 0x80, 0xc6 } },
    547     { "NE2000 Compatible",
    548       0x0000, 0x0000, NULL, NULL, 0,
    549       0x0ff0, { 0x00, 0xa0, 0x0c } },
    550     { "Network General Sniffer",
    551       0x0000, 0x0000, NULL, NULL, 0,
    552       0x0ff0, { 0x00, 0x00, 0x65 } },
    553     { "Panasonic VEL211",
    554       0x0000, 0x0000, NULL, NULL, 0,
    555       0x0ff0, { 0x00, 0x80, 0x45 } },
    556     { "SCM Ethernet",
    557       0x0000, 0x0000, NULL, NULL, 0,
    558       0x0ff0, { 0x00, 0x20, 0xcb } },
    559     { "Volktek NPL-402CT",
    560       0x0000, 0x0000, NULL, NULL, 0,
    561       0x0060, { 0x00, 0x40, 0x05 } },
    562 #endif
    563 
    564     { PCMCIA_STR_ALLIEDTELESIS_LA_PCM,
    565       PCMCIA_VENDOR_ALLIEDTELESIS, PCMCIA_PRODUCT_ALLIEDTELESIS_LA_PCM,
    566       PCMCIA_CIS_ALLIEDTELESIS_LA_PCM,
    567       0, 0x0ff0, { 0x00, 0x00, 0xf4 } },
    568 };
    569 
    570 #define	NE2000_NDEVS	(sizeof(ne2000devs) / sizeof(ne2000devs[0]))
    571 
    572 #define ne2000_match(card, fct, n) \
    573 ((((((card)->manufacturer != PCMCIA_VENDOR_INVALID) && \
    574     ((card)->manufacturer == ne2000devs[(n)].manufacturer) && \
    575     ((card)->product != PCMCIA_PRODUCT_INVALID) && \
    576     ((card)->product == ne2000devs[(n)].product)) || \
    577    ((ne2000devs[(n)].cis_info[0]) && (ne2000devs[(n)].cis_info[1]) && \
    578     (strcmp((card)->cis1_info[0], ne2000devs[(n)].cis_info[0]) == 0) && \
    579     (strcmp((card)->cis1_info[1], ne2000devs[(n)].cis_info[1]) == 0))) && \
    580   ((fct) == ne2000devs[(n)].function))? \
    581  &ne2000devs[(n)]:NULL)
    582 
    583 int
    584 ne_pcmcia_match(parent, match, aux)
    585 	struct device *parent;
    586 	struct cfdata *match;
    587 	void *aux;
    588 {
    589 	struct pcmcia_attach_args *pa = aux;
    590 	int i;
    591 
    592 	for (i = 0; i < NE2000_NDEVS; i++) {
    593 		if (ne2000_match(pa->card, pa->pf->number, i))
    594 			return (1);
    595 	}
    596 
    597 	return (0);
    598 }
    599 
    600 void
    601 ne_pcmcia_attach(parent, self, aux)
    602 	struct device *parent, *self;
    603 	void *aux;
    604 {
    605 	struct ne_pcmcia_softc *psc = (void *) self;
    606 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    607 	struct dp8390_softc *dsc = &nsc->sc_dp8390;
    608 	struct pcmcia_attach_args *pa = aux;
    609 	struct pcmcia_config_entry *cfe;
    610 	const struct ne2000dev *ne_dev;
    611 	int i;
    612 	u_int8_t myea[6], *enaddr;
    613 	const char *typestr = "";
    614 
    615 	psc->sc_pf = pa->pf;
    616 
    617 	SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
    618 #if 0
    619 		/*
    620 		 * Some ne2000 driver's claim to have memory; others don't.
    621 		 * Since I don't care, I don't check.
    622 		 */
    623 
    624 		if (cfe->num_memspace != 1) {
    625 			printf(": unexpected number of memory spaces "
    626 			    " %d should be 1\n", cfe->num_memspace);
    627 			continue;
    628 		}
    629 #endif
    630 
    631 		if (cfe->num_iospace == 1) {
    632 			if (cfe->iospace[0].length != NE2000_NPORTS) {
    633 				printf(": unexpected I/O space configuration"
    634 				    " (continued)\n%s", dsc->sc_dev.dv_xname);
    635 				/* XXX really safe for all other cards? */
    636 			}
    637 		} else if (cfe->num_iospace == 2) {
    638 			/*
    639 			 * Some cards report a separate space for NIC and ASIC.
    640 			 * This make some sense, but we must allocate a single
    641 			 * NE2000_NPORTS-sized chunk, due to brain damaged
    642 			 * address decoders on some of these cards.
    643 			 */
    644 			if (cfe->iospace[0].length + cfe->iospace[1].length !=
    645 			    NE2000_NPORTS) {
    646 #ifdef DIAGNOSTIC
    647 				printf(": unexpected I/O "
    648 				    "space configuration; ignored\n%s",
    649 				    dsc->sc_dev.dv_xname);
    650 #endif
    651 				continue;
    652 			}
    653 		} else {
    654 #ifdef DIAGNOSTIC
    655 			printf(": unexpected number of i/o spaces %d"
    656 			    " should be 1 or 2; ignored\n%s",
    657 			    cfe->num_iospace, dsc->sc_dev.dv_xname);
    658 #endif
    659 			continue;
    660 		}
    661 
    662 		if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
    663 		    NE2000_NPORTS, NE2000_NPORTS, &psc->sc_pcioh)) {
    664 #ifdef DIAGNOSTIC
    665 			printf(": can't allocate i/o space %lx; ignored\n%s",
    666 			    cfe->iospace[0].start, dsc->sc_dev.dv_xname);
    667 #endif
    668 			continue;
    669 		}
    670 
    671 		/* Ok, found. */
    672 		break;
    673 	}
    674 
    675 	if (cfe == NULL) {
    676 		printf(": no suitable config entry\n");
    677 		goto fail_1;
    678 	}
    679 
    680 	dsc->sc_regt = psc->sc_pcioh.iot;
    681 	dsc->sc_regh = psc->sc_pcioh.ioh;
    682 
    683 	nsc->sc_asict = psc->sc_pcioh.iot;
    684 	if (bus_space_subregion(dsc->sc_regt, dsc->sc_regh,
    685 	    NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
    686 	    &nsc->sc_asich)) {
    687 		printf(": can't get subregion for asic\n");
    688 		goto fail_2;
    689 	}
    690 
    691 	/* Set up power management hooks. */
    692 	dsc->sc_enable = ne_pcmcia_enable;
    693 	dsc->sc_disable = ne_pcmcia_disable;
    694 
    695 	/* Enable the card. */
    696 	pcmcia_function_init(pa->pf, cfe);
    697 	if (pcmcia_function_enable(pa->pf)) {
    698 		printf(": function enable failed\n");
    699 		goto fail_2;
    700 	}
    701 
    702 	/* some cards claim to be io16, but they're lying. */
    703 	if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO8,
    704 	    NE2000_NIC_OFFSET, NE2000_NIC_NPORTS,
    705 	    &psc->sc_pcioh, &psc->sc_nic_io_window)) {
    706 		printf(": can't map NIC i/o space\n");
    707 		goto fail_3;
    708 	}
    709 
    710 	if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16,
    711 	    NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS,
    712 	    &psc->sc_pcioh, &psc->sc_asic_io_window)) {
    713 		printf(": can't map ASIC i/o space\n");
    714 		goto fail_4;
    715 	}
    716 
    717 	printf("\n");
    718 
    719 	/*
    720 	 * Read the station address from the board.
    721 	 */
    722 	i = 0;
    723 again:
    724 	enaddr = NULL;			/* Ask ASIC by default */
    725 	typestr = "";			/* clear previous card-type */
    726 	for (; i < NE2000_NDEVS; i++) {
    727 		ne_dev = ne2000_match(pa->card, pa->pf->number, i);
    728 		if (ne_dev != NULL) {
    729 			if (ne_dev->enet_maddr >= 0) {
    730 				enaddr = ne_pcmcia_get_enaddr(psc,
    731 				    ne_dev->enet_maddr, myea);
    732 				if (enaddr == NULL)
    733 					continue;
    734 			}
    735 			break;
    736 		}
    737 	}
    738 	if (i == NE2000_NDEVS) {
    739 		printf("%s (manf %08x prod %08x) cis %s %s: "
    740 		       "can't match ethernet vendor code\n",
    741 		       dsc->sc_dev.dv_xname,
    742 		       pa->manufacturer, pa->product,
    743 		       pa->card->cis1_info[0], pa->card->cis1_info[1]);
    744 		goto fail_5;
    745 	}
    746 
    747 	if ((ne_dev->flags & NE2000DVF_DL10019) != 0) {
    748 		u_int8_t type;
    749 
    750 		enaddr = ne_pcmcia_dl10019_get_enaddr(psc, myea);
    751 		if (enaddr == NULL) {
    752 			++i;
    753 			goto again;
    754 		}
    755 
    756 		dsc->sc_mediachange = dl10019_mediachange;
    757 		dsc->sc_mediastatus = dl10019_mediastatus;
    758 		dsc->init_card = dl10019_init_card;
    759 		dsc->stop_card = dl10019_stop_card;
    760 		dsc->sc_media_init = dl10019_media_init;
    761 		dsc->sc_media_fini = dl10019_media_fini;
    762 
    763 		/* Determine if this is a DL10019 or a DL10022. */
    764 		type = bus_space_read_1(nsc->sc_asict, nsc->sc_asich, 0x0f);
    765 		if (type == 0x91 || type == 0x99) {
    766 			nsc->sc_type = NE2000_TYPE_DL10022;
    767 			typestr = " (DL10022)";
    768 		} else {
    769 			nsc->sc_type = NE2000_TYPE_DL10019;
    770 			typestr = " (DL10019)";
    771 		}
    772 	}
    773 
    774 	if ((ne_dev->flags & NE2000DVF_AX88190) != 0) {
    775 		if (ne_pcmcia_ax88190_set_iobase(psc)) {
    776 			++i;
    777 			goto again;
    778 		}
    779 
    780 		dsc->sc_mediachange = ax88190_mediachange;
    781 		dsc->sc_mediastatus = ax88190_mediastatus;
    782 		dsc->init_card = ax88190_init_card;
    783 		dsc->stop_card = ax88190_stop_card;
    784 		dsc->sc_media_init = ax88190_media_init;
    785 		dsc->sc_media_fini = ax88190_media_fini;
    786 
    787 		nsc->sc_type = NE2000_TYPE_AX88190;
    788 		typestr = " (AX88190)";
    789 	}
    790 
    791 	if (enaddr != NULL) {
    792 		/*
    793 		 * Make sure this is what we expect.
    794 		 */
    795 		if (enaddr[0] != ne_dev->enet_vendor[0] ||
    796 		    enaddr[1] != ne_dev->enet_vendor[1] ||
    797 		    enaddr[2] != ne_dev->enet_vendor[2]) {
    798 			++i;
    799 			goto again;
    800 		}
    801 	}
    802 
    803 	/*
    804 	 * Check for a RealTek 8019.
    805 	 */
    806 	if (nsc->sc_type == 0) {
    807 		bus_space_write_1(dsc->sc_regt, dsc->sc_regh, ED_P0_CR,
    808 		    ED_CR_PAGE_0 | ED_CR_STP);
    809 		if (bus_space_read_1(dsc->sc_regt, dsc->sc_regh,
    810 		    NERTL_RTL0_8019ID0) == RTL0_8019ID0 &&
    811 		    bus_space_read_1(dsc->sc_regt, dsc->sc_regh,
    812 		    NERTL_RTL0_8019ID1) == RTL0_8019ID1) {
    813 			typestr = " (RTL8019)";
    814 			dsc->sc_mediachange = rtl80x9_mediachange;
    815 			dsc->sc_mediastatus = rtl80x9_mediastatus;
    816 			dsc->init_card = rtl80x9_init_card;
    817 			dsc->sc_media_init = rtl80x9_media_init;
    818 		}
    819 	}
    820 
    821 	printf("%s: %s%s Ethernet\n", dsc->sc_dev.dv_xname, ne_dev->name,
    822 	    typestr);
    823 
    824 	if (ne2000_attach(nsc, enaddr))
    825 		goto fail_5;
    826 
    827 	pcmcia_function_disable(pa->pf);
    828 	return;
    829 
    830  fail_5:
    831 	/* Unmap ASIC i/o windows. */
    832 	pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
    833 
    834  fail_4:
    835 	/* Unmap NIC i/o windows. */
    836 	pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
    837 
    838  fail_3:
    839 	pcmcia_function_disable(pa->pf);
    840 
    841  fail_2:
    842 	/* Free our i/o space. */
    843 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    844 
    845  fail_1:
    846 	psc->sc_nic_io_window = -1;
    847 }
    848 
    849 int
    850 ne_pcmcia_detach(self, flags)
    851 	struct device *self;
    852 	int flags;
    853 {
    854 	struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)self;
    855 	int error;
    856 
    857 	if (psc->sc_nic_io_window == -1)
    858 		/* Nothing to detach. */
    859 		return (0);
    860 
    861 	error = ne2000_detach(&psc->sc_ne2000, flags);
    862 	if (error != 0)
    863 		return (error);
    864 
    865 	/* Unmap our i/o windows. */
    866 	pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
    867 	pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
    868 
    869 	/* Free our i/o space. */
    870 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    871 
    872 	return (0);
    873 }
    874 
    875 int
    876 ne_pcmcia_enable(dsc)
    877 	struct dp8390_softc *dsc;
    878 {
    879 	struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
    880 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    881 
    882 	/* set up the interrupt */
    883 	psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr,
    884 	    dsc);
    885 	if (psc->sc_ih == NULL) {
    886 		printf("%s: couldn't establish interrupt\n",
    887 		    dsc->sc_dev.dv_xname);
    888 		goto fail_1;
    889 	}
    890 
    891 	if (pcmcia_function_enable(psc->sc_pf))
    892 		goto fail_2;
    893 
    894 	if (nsc->sc_type == NE2000_TYPE_AX88190)
    895 		if (ne_pcmcia_ax88190_set_iobase(psc))
    896 			goto fail_3;
    897 
    898 	return (0);
    899 
    900  fail_3:
    901 	pcmcia_function_disable(psc->sc_pf);
    902  fail_2:
    903 	pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
    904  fail_1:
    905 	return (1);
    906 }
    907 
    908 void
    909 ne_pcmcia_disable(dsc)
    910 	struct dp8390_softc *dsc;
    911 {
    912 	struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
    913 
    914 	pcmcia_function_disable(psc->sc_pf);
    915 	pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
    916 }
    917 
    918 u_int8_t *
    919 ne_pcmcia_get_enaddr(psc, maddr, myea)
    920 	struct ne_pcmcia_softc *psc;
    921 	int maddr;
    922 	u_int8_t myea[ETHER_ADDR_LEN];
    923 {
    924 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    925 	struct dp8390_softc *dsc = &nsc->sc_dp8390;
    926 	struct pcmcia_mem_handle pcmh;
    927 	bus_size_t offset;
    928 	u_int8_t *enaddr = NULL;
    929 	int j, mwindow;
    930 
    931 	if (maddr < 0)
    932 		return (NULL);
    933 
    934 	if (pcmcia_mem_alloc(psc->sc_pf, ETHER_ADDR_LEN * 2, &pcmh)) {
    935 		printf("%s: can't alloc mem for enet addr\n",
    936 		    dsc->sc_dev.dv_xname);
    937 		goto fail_1;
    938 	}
    939 	if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, maddr,
    940 	    ETHER_ADDR_LEN * 2, &pcmh, &offset, &mwindow)) {
    941 		printf("%s: can't map mem for enet addr\n",
    942 		    dsc->sc_dev.dv_xname);
    943 		goto fail_2;
    944 	}
    945 	for (j = 0; j < ETHER_ADDR_LEN; j++)
    946 		myea[j] = bus_space_read_1(pcmh.memt, pcmh.memh,
    947 		    offset + (j * 2));
    948 	enaddr = myea;
    949 
    950 	pcmcia_mem_unmap(psc->sc_pf, mwindow);
    951  fail_2:
    952 	pcmcia_mem_free(psc->sc_pf, &pcmh);
    953  fail_1:
    954 	return (enaddr);
    955 }
    956 
    957 u_int8_t *
    958 ne_pcmcia_dl10019_get_enaddr(psc, myea)
    959 	struct ne_pcmcia_softc *psc;
    960 	u_int8_t myea[ETHER_ADDR_LEN];
    961 {
    962 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    963 	u_int8_t sum;
    964 	int j;
    965 
    966 #define PAR0	0x04
    967 	for (j = 0, sum = 0; j < 8; j++)
    968 		sum += bus_space_read_1(nsc->sc_asict, nsc->sc_asich,
    969 		    PAR0 + j);
    970 	if (sum != 0xff)
    971 		return (NULL);
    972 	for (j = 0; j < ETHER_ADDR_LEN; j++)
    973 		myea[j] = bus_space_read_1(nsc->sc_asict,
    974 		    nsc->sc_asich, PAR0 + j);
    975 #undef PAR0
    976 	return (myea);
    977 }
    978 
    979 int
    980 ne_pcmcia_ax88190_set_iobase(psc)
    981 	struct ne_pcmcia_softc *psc;
    982 {
    983 	struct ne2000_softc *nsc = &psc->sc_ne2000;
    984 	struct dp8390_softc *dsc = &nsc->sc_dp8390;
    985 	struct pcmcia_mem_handle pcmh;
    986 	bus_size_t offset;
    987 	int rv = 1, mwindow;
    988 	u_int last_liobase, new_liobase;
    989 
    990 	if (pcmcia_mem_alloc(psc->sc_pf, AX88190_LAN_IOSIZE, &pcmh)) {
    991 #if 0
    992 		printf("%s: can't alloc mem for LAN iobase\n",
    993 		    dsc->sc_dev.dv_xname);
    994 #endif
    995 		goto fail_1;
    996 	}
    997 	if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR,
    998 	    AX88190_LAN_IOBASE, AX88190_LAN_IOSIZE,
    999 	    &pcmh, &offset, &mwindow)) {
   1000 		printf("%s: can't map mem for LAN iobase\n",
   1001 		    dsc->sc_dev.dv_xname);
   1002 		goto fail_2;
   1003 	}
   1004 
   1005 	last_liobase = bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
   1006 	    (bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8);
   1007 #ifdef DIAGNOSTIC
   1008 	printf("%s: LAN iobase 0x%x (0x%x) ->", dsc->sc_dev.dv_xname,
   1009 	    last_liobase, (u_int)psc->sc_pcioh.addr);
   1010 #endif
   1011 	bus_space_write_1(pcmh.memt, pcmh.memh, offset,
   1012 	    psc->sc_pcioh.addr & 0xff);
   1013 	bus_space_write_1(pcmh.memt, pcmh.memh, offset + 2,
   1014 	    psc->sc_pcioh.addr >> 8);
   1015 
   1016 	new_liobase = bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
   1017 	    (bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8);
   1018 #ifdef DIAGNOSTIC
   1019 	printf(" 0x%x\n", new_liobase);
   1020 #endif
   1021 	if ((last_liobase == psc->sc_pcioh.addr)
   1022 	    || (last_liobase != new_liobase))
   1023 		rv = 0;
   1024 
   1025 	pcmcia_mem_unmap(psc->sc_pf, mwindow);
   1026  fail_2:
   1027 	pcmcia_mem_free(psc->sc_pf, &pcmh);
   1028  fail_1:
   1029 	return (rv);
   1030 }
   1031