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