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