[BACK]Return to if_ne_pcmcia.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev / pcmcia

Annotation of src/sys/dev/pcmcia/if_ne_pcmcia.c, Revision 1.79

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

CVSweb <webmaster@jp.NetBSD.org>