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