79static int linksys; 80 81/* 82 * ed_pccard_detach - unload the driver and clear the table. 83 * XXX TODO: 84 * This is usually called when the card is ejected, but 85 * can be caused by a modunload of a controller driver. 86 * The idea is to reset the driver's view of the device 87 * and ensure that any driver entry points such as 88 * read and write do not hang. 89 */ 90static int 91ed_pccard_detach(device_t dev) 92{ 93 struct ed_softc *sc = device_get_softc(dev); 94 struct ifnet *ifp = &sc->arpcom.ac_if; 95 96 if (sc->gone) { 97 device_printf(dev, "already unloaded\n"); 98 return (0); 99 } 100 ed_stop(sc); 101 ifp->if_flags &= ~IFF_RUNNING; 102 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); 103 sc->gone = 1; 104 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); 105 ed_release_resources(dev); 106 return (0); 107} 108 109static const struct ed_product { 110 struct pccard_product prod; 111 int enet_maddr; 112 unsigned char enet_vendor[3]; 113 int flags; 114#define NE2000DVF_DL10019 0x0001 /* chip is D-Link DL10019 */ 115#define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */ 116} ed_pccard_products[] = { 117 { { PCCARD_STR_AMBICOM_AMB8002T, 118 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 119 PCCARD_CIS_AMBICOM_AMB8002T }, 120 -1, { 0x00, 0x10, 0x7a } }, 121 122 { { PCCARD_STR_PREMAX_PE200, 123 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 124 PCCARD_CIS_PREMAX_PE200 }, 125 0x07f0, { 0x00, 0x20, 0xe0 } }, 126 127 { { PCCARD_STR_DIGITAL_DEPCMXX, 128 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 129 PCCARD_CIS_DIGITAL_DEPCMXX }, 130 0x0ff0, { 0x00, 0x00, 0xe8 } }, 131 132 { { PCCARD_STR_PLANET_SMARTCOM2000, 133 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 134 PCCARD_CIS_PLANET_SMARTCOM2000 }, 135 0xff0, { 0x00, 0x00, 0xe8 } }, 136 137 { { PCCARD_STR_DLINK_DE660, 138 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 139 PCCARD_CIS_DLINK_DE660 }, 140 -1, { 0x00, 0x80, 0xc8 } }, 141 142 { { PCCARD_STR_RPTI_EP400, 143 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 144 PCCARD_CIS_RPTI_EP400 }, 145 -1, { 0x00, 0x40, 0x95 } }, 146 147 { { PCCARD_STR_RPTI_EP401, 148 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 149 PCCARD_CIS_RPTI_EP401 }, 150 -1, { 0x00, 0x40, 0x95 } }, 151 152 { { PCCARD_STR_ACCTON_EN2212, 153 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 154 PCCARD_CIS_ACCTON_EN2212 }, 155 0x0ff0, { 0x00, 0x00, 0xe8 } }, 156 157 { { PCCARD_STR_SVEC_COMBOCARD, 158 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 159 PCCARD_CIS_SVEC_COMBOCARD }, 160 -1, { 0x00, 0xe0, 0x98 } }, 161 162 { { PCCARD_STR_SVEC_LANCARD, 163 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 164 PCCARD_CIS_SVEC_LANCARD }, 165 0x7f0, { 0x00, 0xc0, 0x6c } }, 166 167 { { PCCARD_STR_EPSON_EEN10B, 168 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_EPSON_EEN10B, 0, 169 PCCARD_CIS_EPSON_EEN10B }, 170 0xff0, { 0x00, 0x00, 0x48 } }, 171 172 /* 173 * You have to add new entries which contains 174 * PCCARD_VENDOR_INVALID and/or PCCARD_PRODUCT_INVALID 175 * in front of this comment. 176 * 177 * There are cards which use a generic vendor and product id but needs 178 * a different handling depending on the cis_info, so ne2000_match 179 * needs a table where the exceptions comes first and then the normal 180 * product and vendor entries. 181 */ 182 183 { { PCCARD_STR_IBM_INFOMOVER, 184 PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_INFOMOVER, 0, 185 PCCARD_CIS_IBM_INFOMOVER }, 186 0x0ff0, { 0x08, 0x00, 0x5a } }, 187 188 { { PCCARD_STR_IBM_INFOMOVER, 189 PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_INFOMOVER, 0, 190 PCCARD_CIS_IBM_INFOMOVER }, 191 0x0ff0, { 0x00, 0x04, 0xac } }, 192 193 { { PCCARD_STR_IBM_INFOMOVER, 194 PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_INFOMOVER, 0, 195 PCCARD_CIS_IBM_INFOMOVER }, 196 0x0ff0, { 0x00, 0x06, 0x29 } }, 197 198 { { PCCARD_STR_KINGSTON_KNE2, PCCARD_VENDOR_KINGSTON, 199 PCCARD_PRODUCT_KINGSTON_KNE2, 0, 200 PCCARD_CIS_KINGSTON_KNE2 }, 201 -1, { 0, 0, 0 }, 0 }, /* XXX */ 202 203 { { PCCARD_STR_LINKSYS_ECARD_1, 204 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ECARD_1, 0, 205 PCCARD_CIS_LINKSYS_ECARD_1 }, 206 -1, { 0x00, 0x80, 0xc8 } }, 207 208 { { PCCARD_STR_PLANEX_FNW3600T, 209 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0, 210 PCCARD_CIS_PLANEX_FNW3600T }, 211 -1, { 0x00, 0x90, 0xcc }, NE2000DVF_DL10019 }, 212 213 { { PCCARD_STR_SVEC_PN650TX, 214 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0, 215 PCCARD_CIS_SVEC_PN650TX }, 216 -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 { { PCCARD_STR_PLANEX_FNW3700T, 224 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0, 225 PCCARD_CIS_PLANEX_FNW3700T }, 226 -1, { 0x00, 0x90, 0xcc }, NE2000DVF_AX88190 }, 227 228 { { PCCARD_STR_LINKSYS_ETHERFAST, 229 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ETHERFAST, 0, 230 PCCARD_CIS_LINKSYS_ETHERFAST }, 231 -1, { 0x00, 0x80, 0xc8 }, NE2000DVF_DL10019 }, 232 233 { { PCCARD_STR_DLINK_DE650, 234 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ETHERFAST, 0, 235 PCCARD_CIS_DLINK_DE650 }, 236 -1, { 0x00, 0xe0, 0x98 }, NE2000DVF_DL10019 }, 237 238 { { PCCARD_STR_MELCO_LPC2_TX, 239 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ETHERFAST, 0, 240 PCCARD_CIS_MELCO_LPC2_TX }, 241 -1, { 0x00, 0x40, 0x26 }, NE2000DVF_DL10019 }, 242 243 { { PCCARD_STR_LINKSYS_COMBO_ECARD, 244 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0, 245 PCCARD_CIS_LINKSYS_COMBO_ECARD }, 246 -1, { 0x00, 0x80, 0xc8 } }, 247 248 { { PCCARD_STR_LINKSYS_TRUST_COMBO_ECARD, 249 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_TRUST_COMBO_ECARD, 0, 250 PCCARD_CIS_LINKSYS_TRUST_COMBO_ECARD }, 251 0x0120, { 0x20, 0x04, 0x49 } }, 252 253 /* 254 * Although the comments above say to put VENDOR/PRODUCT 255 * INVALID IDs above this list, we need to keep this one below 256 * the ECARD_1, or else both will match the same more-generic 257 * entry rather than the more specific one above with proper 258 * vendor and product IDs. 259 */ 260 { { PCCARD_STR_LINKSYS_ECARD_2, 261 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 262 PCCARD_CIS_LINKSYS_ECARD_2 }, 263 -1, { 0x00, 0x80, 0xc8 } }, 264 265 /* 266 * D-Link DE-650 has many minor versions: 267 * 268 * CIS information Manufacturer Product Note 269 * 1 "D-Link, DE-650" INVALID INVALID white card 270 * 2 "D-Link, DE-650, Ver 01.00" INVALID INVALID became bare metal 271 * 3 "D-Link, DE-650, Ver 01.00" 0x149 0x265 minor changed look 272 * 4 "D-Link, DE-650, Ver 01.00" 0x149 0x265 collision LED added 273 * 274 * While the 1st and the 2nd types should use the "D-Link DE-650" 275 * entry, the 3rd and the 4th types should use the "Linksys 276 * EtherCard" entry. Therefore, this enty must be below the 277 * LINKSYS_ECARD_1. --itohy 278 */ 279 { { PCCARD_STR_DLINK_DE650, 280 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 281 PCCARD_CIS_DLINK_DE650 }, 282 0x0040, { 0x00, 0x80, 0xc8 } }, 283 284 /* 285 * IO-DATA PCLA/TE and later version of PCLA/T has valid 286 * vendor/product ID and it is possible to read MAC address 287 * using standard I/O ports. It also read from CIS offset 0x01c0. 288 * On the other hand, earlier version of PCLA/T doesn't have valid 289 * vendor/product ID and MAC address must be read from CIS offset 290 * 0x0ff0 (i.e., usual ne2000 way to read it doesn't work). 291 * And CIS information of earlier and later version of PCLA/T are 292 * same except fourth element. So, for now, we place the entry for 293 * PCLA/TE (and later version of PCLA/T) followed by entry 294 * for the earlier version of PCLA/T (or, modify to match all CIS 295 * information and have three or more individual entries). 296 */ 297 { { PCCARD_STR_IODATA_PCLATE, 298 PCCARD_VENDOR_IODATA, PCCARD_PRODUCT_IODATA_PCLATE, 0, 299 PCCARD_CIS_IODATA_PCLATE }, 300 -1, { 0x00, 0xa0, 0xb0 } }, 301 302 /* 303 * This entry should be placed after above PCLA-TE entry. 304 * See above comments for detail. 305 */ 306 { { PCCARD_STR_IODATA_PCLAT, 307 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 308 PCCARD_CIS_IODATA_PCLAT }, 309 0x0ff0, { 0x00, 0xa0, 0xb0 } }, 310 311 { { PCCARD_STR_DAYNA_COMMUNICARD_E_1, 312 PCCARD_VENDOR_DAYNA, PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_1, 0, 313 PCCARD_CIS_DAYNA_COMMUNICARD_E_1 }, 314 0x0110, { 0x00, 0x80, 0x19 } }, 315 316 { { PCCARD_STR_DAYNA_COMMUNICARD_E_2, 317 PCCARD_VENDOR_DAYNA, PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_2, 0, 318 PCCARD_CIS_DAYNA_COMMUNICARD_E_2 }, 319 -1, { 0x00, 0x80, 0x19 } }, 320 321 { { PCCARD_STR_COREGA_ETHER_PCC_T, 322 PCCARD_VENDOR_COREGA, PCCARD_PRODUCT_COREGA_ETHER_PCC_T, 0, 323 PCCARD_CIS_COREGA_ETHER_PCC_T }, 324 -1, { 0x00, 0x00, 0xf4 } }, 325 326 { { PCCARD_STR_COREGA_ETHER_II_PCC_T, 327 PCCARD_VENDOR_COREGA, PCCARD_PRODUCT_COREGA_ETHER_II_PCC_T, 0, 328 PCCARD_CIS_COREGA_ETHER_II_PCC_T }, 329 -1, { 0x00, 0x00, 0xf4 } }, 330 331 { { PCCARD_STR_COREGA_FAST_ETHER_PCC_TX, 332 PCCARD_VENDOR_COREGA, PCCARD_PRODUCT_COREGA_FAST_ETHER_PCC_TX, 0, 333 PCCARD_CIS_COREGA_FAST_ETHER_PCC_TX }, 334 -1, { 0x00, 0x00, 0xf4 }, NE2000DVF_DL10019 }, 335 336 { { PCCARD_STR_COMPEX_LINKPORT_ENET_B, 337 PCCARD_VENDOR_COMPEX, PCCARD_PRODUCT_COMPEX_LINKPORT_ENET_B, 0, 338 PCCARD_CIS_COMPEX_LINKPORT_ENET_B }, 339 0x01c0, { 0x00, 0xa0, 0x0c } }, 340 341 { { PCCARD_STR_SMC_EZCARD, 342 PCCARD_VENDOR_SMC, PCCARD_PRODUCT_SMC_EZCARD, 0, 343 PCCARD_CIS_SMC_EZCARD }, 344 0x01c0, { 0x00, 0xe0, 0x29 } }, 345 346 { { PCCARD_STR_SOCKET_LP_ETHER_CF, 347 PCCARD_VENDOR_SOCKET, PCCARD_PRODUCT_SOCKET_LP_ETHER_CF, 0, 348 PCCARD_CIS_SOCKET_LP_ETHER_CF }, 349 -1, { 0x00, 0xc0, 0x1b } }, 350 351 { { PCCARD_STR_SOCKET_LP_ETHER, 352 PCCARD_VENDOR_SOCKET, PCCARD_PRODUCT_SOCKET_LP_ETHER, 0, 353 PCCARD_CIS_SOCKET_LP_ETHER }, 354 -1, { 0x00, 0xc0, 0x1b } }, 355 356 { { PCCARD_STR_XIRCOM_CFE_10, 357 PCCARD_VENDOR_XIRCOM, PCCARD_PRODUCT_XIRCOM_CFE_10, 0, 358 PCCARD_CIS_XIRCOM_CFE_10 }, 359 -1, { 0x00, 0x10, 0xa4 } }, 360 361 { { PCCARD_STR_MELCO_LPC3_TX, 362 PCCARD_VENDOR_MELCO, PCCARD_PRODUCT_MELCO_LPC3_TX, 0, 363 PCCARD_CIS_MELCO_LPC3_TX }, 364 -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 }, 365 366 { { PCCARD_STR_BILLIONTON_LNT10TN, 367 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 368 PCCARD_CIS_BILLIONTON_LNT10TN }, 369 -1, { 0x00, 0x00, 0x00 } }, 370 371 { { PCCARD_STR_NDC_ND5100_E, 372 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0, 373 PCCARD_CIS_NDC_ND5100_E }, 374 -1, { 0x00, 0x80, 0xc6 } }, 375 376 { { PCCARD_STR_TELECOMDEVICE_TCD_HPC100, 377 PCCARD_VENDOR_TELECOMDEVICE, PCCARD_PRODUCT_TELECOMDEVICE_TCD_HPC100, 0, 378 PCCARD_CIS_TELECOMDEVICE_TCD_HPC100 }, 379 -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 }, 380 381 { { PCCARD_STR_MACNICA_ME1_JEIDA, 382 PCCARD_VENDOR_MACNICA, PCCARD_PRODUCT_MACNICA_ME1_JEIDA, 0, 383 PCCARD_CIS_MACNICA_ME1_JEIDA }, 384 0x00b8, { 0x08, 0x00, 0x42 } }, 385 386#if 0 387 /* the rest of these are stolen from the linux pcnet pcmcia device 388 driver. Since I don't know the manfid or cis info strings for 389 any of them, they're not compiled in until I do. */ 390 { "APEX MultiCard", 391 0x0000, 0x0000, NULL, NULL, 0, 392 0x03f4, { 0x00, 0x20, 0xe5 } }, 393 { "ASANTE FriendlyNet", 394 0x0000, 0x0000, NULL, NULL, 0, 395 0x4910, { 0x00, 0x00, 0x94 } }, 396 { "Danpex EN-6200P2", 397 0x0000, 0x0000, NULL, NULL, 0, 398 0x0110, { 0x00, 0x40, 0xc7 } }, 399 { "DataTrek NetCard", 400 0x0000, 0x0000, NULL, NULL, 0, 401 0x0ff0, { 0x00, 0x20, 0xe8 } }, 402 { "Dayna CommuniCard E", 403 0x0000, 0x0000, NULL, NULL, 0, 404 0x0110, { 0x00, 0x80, 0x19 } }, 405 { "EP-210 Ethernet", 406 0x0000, 0x0000, NULL, NULL, 0, 407 0x0110, { 0x00, 0x40, 0x33 } }, 408 { "ELECOM Laneed LD-CDWA", 409 0x0000, 0x0000, NULL, NULL, 0, 410 0x00b8, { 0x08, 0x00, 0x42 } }, 411 { "Grey Cell GCS2220", 412 0x0000, 0x0000, NULL, NULL, 0, 413 0x0000, { 0x00, 0x47, 0x43 } }, 414 { "Hypertec Ethernet", 415 0x0000, 0x0000, NULL, NULL, 0, 416 0x01c0, { 0x00, 0x40, 0x4c } }, 417 { "IBM CCAE", 418 0x0000, 0x0000, NULL, NULL, 0, 419 0x0ff0, { 0x08, 0x00, 0x5a } }, 420 { "IBM CCAE", 421 0x0000, 0x0000, NULL, NULL, 0, 422 0x0ff0, { 0x00, 0x04, 0xac } }, 423 { "IBM CCAE", 424 0x0000, 0x0000, NULL, NULL, 0, 425 0x0ff0, { 0x00, 0x06, 0x29 } }, 426 { "IBM FME", 427 0x0000, 0x0000, NULL, NULL, 0, 428 0x0374, { 0x00, 0x04, 0xac } }, 429 { "IBM FME", 430 0x0000, 0x0000, NULL, NULL, 0, 431 0x0374, { 0x08, 0x00, 0x5a } }, 432 { "Katron PE-520", 433 0x0000, 0x0000, NULL, NULL, 0, 434 0x0110, { 0x00, 0x40, 0xf6 } }, 435 { "Kingston KNE-PCM/x", 436 0x0000, 0x0000, NULL, NULL, 0, 437 0x0ff0, { 0x00, 0xc0, 0xf0 } }, 438 { "Kingston KNE-PCM/x", 439 0x0000, 0x0000, NULL, NULL, 0, 440 0x0ff0, { 0xe2, 0x0c, 0x0f } }, 441 { "Kingston KNE-PC2", 442 0x0000, 0x0000, NULL, NULL, 0, 443 0x0180, { 0x00, 0xc0, 0xf0 } }, 444 { "Longshine LCS-8534", 445 0x0000, 0x0000, NULL, NULL, 0, 446 0x0000, { 0x08, 0x00, 0x00 } }, 447 { "Maxtech PCN2000", 448 0x0000, 0x0000, NULL, NULL, 0, 449 0x5000, { 0x00, 0x00, 0xe8 } }, 450 { "NDC Instant-Link", 451 0x0000, 0x0000, NULL, NULL, 0, 452 0x003a, { 0x00, 0x80, 0xc6 } }, 453 { "NE2000 Compatible", 454 0x0000, 0x0000, NULL, NULL, 0, 455 0x0ff0, { 0x00, 0xa0, 0x0c } }, 456 { "Network General Sniffer", 457 0x0000, 0x0000, NULL, NULL, 0, 458 0x0ff0, { 0x00, 0x00, 0x65 } }, 459 { "Panasonic VEL211", 460 0x0000, 0x0000, NULL, NULL, 0, 461 0x0ff0, { 0x00, 0x80, 0x45 } }, 462 { "SCM Ethernet", 463 0x0000, 0x0000, NULL, NULL, 0, 464 0x0ff0, { 0x00, 0x20, 0xcb } }, 465 { "Socket EA", 466 0x0000, 0x0000, NULL, NULL, 0, 467 0x4000, { 0x00, 0xc0, 0x1b } }, 468 { "Volktek NPL-402CT", 469 0x0000, 0x0000, NULL, NULL, 0, 470 0x0060, { 0x00, 0x40, 0x05 } }, 471#endif 472 473 { { PCCARD_STR_ALLIEDTELESIS_LA_PCM, 474 PCCARD_VENDOR_ALLIEDTELESIS, PCCARD_PRODUCT_ALLIEDTELESIS_LA_PCM, 0, 475 PCCARD_CIS_ALLIEDTELESIS_LA_PCM }, 476 0x0ff0, { 0x00, 0x00, 0xf4 } }, 477 478}; 479 480static int 481ed_pccard_match(device_t dev) 482{ 483 const struct pccard_product *pp; 484 485 if ((pp = pccard_product_lookup(dev, 486 (const struct pccard_product *) ed_pccard_products, 487 sizeof(ed_pccard_products[0]), NULL)) != NULL) { 488 device_set_desc(dev, pp->pp_name); 489 return 0; 490 } 491 return EIO; 492} 493 494/* 495 * Probe framework for pccards. Replicates the standard framework, 496 * minus the pccard driver registration and ignores the ether address 497 * supplied (from the CIS), relying on the probe to find it instead. 498 */ 499static int 500ed_pccard_probe(device_t dev) 501{ 502 int error; 503 int flags = device_get_flags(dev); 504 505 if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_AX88190) { 506 error = ed_pccard_ax88190(dev); 507 goto end2; 508 } 509 510 error = ed_probe_Novell(dev, 0, flags); 511 if (error == 0) 512 goto end; 513 ed_release_resources(dev); 514 515 error = ed_probe_WD80x3(dev, 0, flags); 516 if (error == 0) 517 goto end; 518 ed_release_resources(dev); 519 goto end2; 520 521end: 522 if (ED_FLAGS_GETTYPE(flags) & ED_FLAGS_LINKSYS) { 523 linksys = ed_pccard_Linksys(dev); 524 } else { 525 linksys = 0; 526 } 527end2: 528 if (error == 0) 529 error = ed_alloc_irq(dev, 0, 0); 530 531 ed_release_resources(dev); 532 return (error); 533} 534 535static int 536ed_pccard_attach(device_t dev) 537{ 538 int error; 539 int flags = device_get_flags(dev); 540 int i; 541 struct ed_softc *sc = device_get_softc(dev); 542 u_char sum; 543 u_char ether_addr[ETHER_ADDR_LEN]; 544 545 if (sc->port_used > 0) 546 ed_alloc_port(dev, sc->port_rid, sc->port_used); 547 if (sc->mem_used) 548 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used); 549 ed_alloc_irq(dev, sc->irq_rid, 0); 550 551 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 552 edintr, sc, &sc->irq_handle); 553 if (error) { 554 printf("setup intr failed %d \n", error); 555 ed_release_resources(dev); 556 return (error); 557 } 558 559 if (linksys == 0) { 560 pccard_get_ether(dev, ether_addr); 561 for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++) 562 sum |= ether_addr[i]; 563 if (sum) 564 bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); 565 } 566 567 error = ed_attach(sc, device_get_unit(dev), flags); 568 return (error); 569} 570 571static void 572ax88190_geteprom(struct ed_softc *sc) 573{ 574 int prom[16],i; 575 u_char tmp; 576 struct { 577 unsigned char offset, value; 578 } pg_seq[] = { 579 {ED_P0_CR, ED_CR_RD2|ED_CR_STP},/* Select Page0 */ 580 {ED_P0_DCR, 0x01}, 581 {ED_P0_RBCR0, 0x00}, /* Clear the count regs. */ 582 {ED_P0_RBCR1, 0x00}, 583 {ED_P0_IMR, 0x00}, /* Mask completion irq. */ 584 {ED_P0_ISR, 0xff}, 585 {ED_P0_RCR, ED_RCR_MON | ED_RCR_INTT}, /* Set To Monitor */ 586 {ED_P0_TCR, ED_TCR_LB0}, /* loopback mode. */ 587 {ED_P0_RBCR0, 32}, 588 {ED_P0_RBCR1, 0x00}, 589 {ED_P0_RSAR0, 0x00}, 590 {ED_P0_RSAR1, 0x04}, 591 {ED_P0_CR ,ED_CR_RD0 | ED_CR_STA}, 592 }; 593 594 /* Reset Card */ 595 tmp = ed_asic_inb(sc, ED_NOVELL_RESET); 596 ed_asic_outb(sc, ED_NOVELL_RESET, tmp); 597 DELAY(5000); 598 ed_asic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP); 599 DELAY(5000); 600 601 /* Card Settings */ 602 for (i = 0; i < sizeof(pg_seq) / sizeof(pg_seq[0]); i++) 603 ed_nic_outb(sc, pg_seq[i].offset, pg_seq[i].value); 604 605 /* Get Data */ 606 for (i = 0; i < 16; i++) 607 prom[i] = ed_asic_inb(sc, 0); 608 sc->arpcom.ac_enaddr[0] = prom[0] & 0xff; 609 sc->arpcom.ac_enaddr[1] = prom[0] >> 8; 610 sc->arpcom.ac_enaddr[2] = prom[1] & 0xff; 611 sc->arpcom.ac_enaddr[3] = prom[1] >> 8; 612 sc->arpcom.ac_enaddr[4] = prom[2] & 0xff; 613 sc->arpcom.ac_enaddr[5] = prom[2] >> 8; 614} 615 616static int 617ed_pccard_memwrite(device_t dev, off_t offset, u_char byte) 618{ 619 int cis_rid; 620 struct resource *cis; 621 622 cis_rid = 0; 623 cis = bus_alloc_resource(dev, SYS_RES_MEMORY, &cis_rid, 0, ~0, 624 4 << 10, RF_ACTIVE | RF_SHAREABLE); 625 if (cis == NULL) 626 return (ENXIO); 627 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, 628 cis_rid, PCCARD_A_MEM_ATTR); 629 630 bus_space_write_1(rman_get_bustag(cis), rman_get_bushandle(cis), 631 offset, byte); 632 633 bus_deactivate_resource(dev, SYS_RES_MEMORY, cis_rid, cis); 634 bus_release_resource(dev, SYS_RES_MEMORY, cis_rid, cis); 635 636 return (0); 637} 638 639/* 640 * Probe the Ethernet MAC addrees for PCMCIA Linksys EtherFast 10/100 641 * and compatible cards (DL10019C Ethernet controller). 642 * 643 * Note: The PAO patches try to use more memory for the card, but that 644 * seems to fail for my card. A future optimization would add this back 645 * conditionally. 646 */ 647static int 648ed_pccard_Linksys(device_t dev) 649{ 650 struct ed_softc *sc = device_get_softc(dev); 651 u_char sum; 652 int i; 653 654 /* 655 * Linksys registers(offset from ASIC base) 656 * 657 * 0x04-0x09 : Physical Address Register 0-5 (PAR0-PAR5) 658 * 0x0A : Card ID Register (CIR) 659 * 0x0B : Check Sum Register (SR) 660 */ 661 for (sum = 0, i = 0x04; i < 0x0c; i++) 662 sum += ed_asic_inb(sc, i); 663 if (sum != 0xff) 664 return (0); /* invalid DL10019C */ 665 for (i = 0; i < ETHER_ADDR_LEN; i++) { 666 sc->arpcom.ac_enaddr[i] = ed_asic_inb(sc, 0x04 + i); 667 } 668 669 ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS); 670 sc->isa16bit = 1; 671 sc->type = ED_TYPE_NE2000; 672 sc->type_str = "Linksys";
|