Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

3c509: convert to isa_driver and pnp_driver

Convert 3c509 driver to isa_driver and pnp_driver. The result is that
autoloading using udev and hibernation works with ISA PnP cards. It also adds
hibernation support for non-PnP ISA cards.

xcvr module parameter was removed as its value was not used.

Tested using 3 ISA cards in various combinations of PnP and non-PnP modes.
EISA and MCA only compile-tested.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by

Ondrej Zary and committed by
Jeff Garzik
ac4bed13 a0f55e0e

+372 -357
+372 -357
drivers/net/3c509.c
··· 54 54 v1.19a 28Oct2002 Davud Ruggiero <jdr@farfalle.com> 55 55 - Increase *read_eeprom udelay to workaround oops with 2 cards. 56 56 v1.19b 08Nov2002 Marc Zyngier <maz@wild-wind.fr.eu.org> 57 - - Introduce driver model for EISA cards. 57 + - Introduce driver model for EISA cards. 58 + v1.20 04Feb2008 Ondrej Zary <linux@rainbow-software.org> 59 + - convert to isa_driver and pnp_driver and some cleanups 58 60 */ 59 61 60 62 #define DRV_NAME "3c509" 61 - #define DRV_VERSION "1.19b" 62 - #define DRV_RELDATE "08Nov2002" 63 + #define DRV_VERSION "1.20" 64 + #define DRV_RELDATE "04Feb2008" 63 65 64 66 /* A few values that may be tweaked. */ 65 67 66 68 /* Time in jiffies before concluding the transmitter is hung. */ 67 69 #define TX_TIMEOUT (400*HZ/1000) 68 - /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ 69 - static int max_interrupt_work = 10; 70 70 71 71 #include <linux/module.h> 72 - #ifdef CONFIG_MCA 73 72 #include <linux/mca.h> 74 - #endif 75 - #include <linux/isapnp.h> 73 + #include <linux/isa.h> 74 + #include <linux/pnp.h> 76 75 #include <linux/string.h> 77 76 #include <linux/interrupt.h> 78 77 #include <linux/errno.h> ··· 96 97 97 98 static char version[] __initdata = DRV_NAME ".c:" DRV_VERSION " " DRV_RELDATE " becker@scyld.com\n"; 98 99 99 - #if defined(CONFIG_PM) && (defined(CONFIG_MCA) || defined(CONFIG_EISA)) 100 - #define EL3_SUSPEND 101 - #endif 102 - 103 100 #ifdef EL3_DEBUG 104 101 static int el3_debug = EL3_DEBUG; 105 102 #else ··· 106 111 * a global variable so that the mca/eisa probe routines can increment 107 112 * it */ 108 113 static int el3_cards = 0; 114 + #define EL3_MAX_CARDS 8 109 115 110 116 /* To minimize the size of the driver source I only define operating 111 117 constants if they are used several times. You'll need the manual ··· 115 119 #define EL3_DATA 0x00 116 120 #define EL3_CMD 0x0e 117 121 #define EL3_STATUS 0x0e 118 - #define EEPROM_READ 0x80 122 + #define EEPROM_READ 0x80 119 123 120 124 #define EL3_IO_EXTENT 16 121 125 ··· 164 168 */ 165 169 #define SKB_QUEUE_SIZE 64 166 170 171 + enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA }; 172 + 167 173 struct el3_private { 168 174 struct net_device_stats stats; 169 - struct net_device *next_dev; 170 175 spinlock_t lock; 171 176 /* skb send-queue */ 172 177 int head, size; 173 178 struct sk_buff *queue[SKB_QUEUE_SIZE]; 174 - enum { 175 - EL3_MCA, 176 - EL3_PNP, 177 - EL3_EISA, 178 - } type; /* type of device */ 179 - struct device *dev; 179 + enum el3_cardtype type; 180 180 }; 181 - static int id_port __initdata = 0x110; /* Start with 0x110 to avoid new sound cards.*/ 182 - static struct net_device *el3_root_dev; 181 + static int id_port; 182 + static int current_tag; 183 + static struct net_device *el3_devs[EL3_MAX_CARDS]; 183 184 185 + /* Parameters that may be passed into the module. */ 186 + static int debug = -1; 187 + static int irq[] = {-1, -1, -1, -1, -1, -1, -1, -1}; 188 + /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ 189 + static int max_interrupt_work = 10; 190 + #ifdef CONFIG_PNP 191 + static int nopnp; 192 + #endif 193 + 194 + static int __init el3_common_init(struct net_device *dev); 195 + static void el3_common_remove(struct net_device *dev); 184 196 static ushort id_read_eeprom(int index); 185 197 static ushort read_eeprom(int ioaddr, int index); 186 198 static int el3_open(struct net_device *dev); ··· 203 199 static void el3_down(struct net_device *dev); 204 200 static void el3_up(struct net_device *dev); 205 201 static const struct ethtool_ops ethtool_ops; 206 - #ifdef EL3_SUSPEND 202 + #ifdef CONFIG_PM 207 203 static int el3_suspend(struct device *, pm_message_t); 208 204 static int el3_resume(struct device *); 209 205 #else ··· 213 209 214 210 215 211 /* generic device remove for all device types */ 216 - #if defined(CONFIG_EISA) || defined(CONFIG_MCA) 217 212 static int el3_device_remove (struct device *device); 218 - #endif 219 213 #ifdef CONFIG_NET_POLL_CONTROLLER 220 214 static void el3_poll_controller(struct net_device *dev); 221 215 #endif 216 + 217 + /* Return 0 on success, 1 on error, 2 when found already detected PnP card */ 218 + static int el3_isa_id_sequence(__be16 *phys_addr) 219 + { 220 + short lrs_state = 0xff; 221 + int i; 222 + 223 + /* ISA boards are detected by sending the ID sequence to the 224 + ID_PORT. We find cards past the first by setting the 'current_tag' 225 + on cards as they are found. Cards with their tag set will not 226 + respond to subsequent ID sequences. */ 227 + 228 + outb(0x00, id_port); 229 + outb(0x00, id_port); 230 + for (i = 0; i < 255; i++) { 231 + outb(lrs_state, id_port); 232 + lrs_state <<= 1; 233 + lrs_state = lrs_state & 0x100 ? lrs_state ^ 0xcf : lrs_state; 234 + } 235 + /* For the first probe, clear all board's tag registers. */ 236 + if (current_tag == 0) 237 + outb(0xd0, id_port); 238 + else /* Otherwise kill off already-found boards. */ 239 + outb(0xd8, id_port); 240 + if (id_read_eeprom(7) != 0x6d50) 241 + return 1; 242 + /* Read in EEPROM data, which does contention-select. 243 + Only the lowest address board will stay "on-line". 244 + 3Com got the byte order backwards. */ 245 + for (i = 0; i < 3; i++) 246 + phys_addr[i] = htons(id_read_eeprom(i)); 247 + #ifdef CONFIG_PNP 248 + if (!nopnp) { 249 + /* The ISA PnP 3c509 cards respond to the ID sequence too. 250 + This check is needed in order not to register them twice. */ 251 + for (i = 0; i < el3_cards; i++) { 252 + struct el3_private *lp = netdev_priv(el3_devs[i]); 253 + if (lp->type == EL3_PNP 254 + && !memcmp(phys_addr, el3_devs[i]->dev_addr, 255 + ETH_ALEN)) { 256 + if (el3_debug > 3) 257 + printk(KERN_DEBUG "3c509 with address %02x %02x %02x %02x %02x %02x was found by ISAPnP\n", 258 + phys_addr[0] & 0xff, phys_addr[0] >> 8, 259 + phys_addr[1] & 0xff, phys_addr[1] >> 8, 260 + phys_addr[2] & 0xff, phys_addr[2] >> 8); 261 + /* Set the adaptor tag so that the next card can be found. */ 262 + outb(0xd0 + ++current_tag, id_port); 263 + return 2; 264 + } 265 + } 266 + } 267 + #endif /* CONFIG_PNP */ 268 + return 0; 269 + 270 + } 271 + 272 + static void __devinit el3_dev_fill(struct net_device *dev, __be16 *phys_addr, 273 + int ioaddr, int irq, int if_port, 274 + enum el3_cardtype type) 275 + { 276 + struct el3_private *lp = netdev_priv(dev); 277 + 278 + memcpy(dev->dev_addr, phys_addr, ETH_ALEN); 279 + dev->base_addr = ioaddr; 280 + dev->irq = irq; 281 + dev->if_port = if_port; 282 + lp->type = type; 283 + } 284 + 285 + static int __devinit el3_isa_match(struct device *pdev, 286 + unsigned int ndev) 287 + { 288 + struct net_device *dev; 289 + int ioaddr, isa_irq, if_port, err; 290 + unsigned int iobase; 291 + __be16 phys_addr[3]; 292 + 293 + while ((err = el3_isa_id_sequence(phys_addr)) == 2) 294 + ; /* Skip to next card when PnP card found */ 295 + if (err == 1) 296 + return 0; 297 + 298 + iobase = id_read_eeprom(8); 299 + if_port = iobase >> 14; 300 + ioaddr = 0x200 + ((iobase & 0x1f) << 4); 301 + if (irq[el3_cards] > 1 && irq[el3_cards] < 16) 302 + isa_irq = irq[el3_cards]; 303 + else 304 + isa_irq = id_read_eeprom(9) >> 12; 305 + 306 + dev = alloc_etherdev(sizeof(struct el3_private)); 307 + if (!dev) 308 + return -ENOMEM; 309 + 310 + netdev_boot_setup_check(dev); 311 + 312 + if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509-isa")) { 313 + free_netdev(dev); 314 + return 0; 315 + } 316 + 317 + /* Set the adaptor tag so that the next card can be found. */ 318 + outb(0xd0 + ++current_tag, id_port); 319 + 320 + /* Activate the adaptor at the EEPROM location. */ 321 + outb((ioaddr >> 4) | 0xe0, id_port); 322 + 323 + EL3WINDOW(0); 324 + if (inw(ioaddr) != 0x6d50) { 325 + free_netdev(dev); 326 + return 0; 327 + } 328 + 329 + /* Free the interrupt so that some other card can use it. */ 330 + outw(0x0f00, ioaddr + WN0_IRQ); 331 + 332 + el3_dev_fill(dev, phys_addr, ioaddr, isa_irq, if_port, EL3_ISA); 333 + dev_set_drvdata(pdev, dev); 334 + if (el3_common_init(dev)) { 335 + free_netdev(dev); 336 + return 0; 337 + } 338 + 339 + el3_devs[el3_cards++] = dev; 340 + return 1; 341 + } 342 + 343 + static int __devexit el3_isa_remove(struct device *pdev, 344 + unsigned int ndev) 345 + { 346 + el3_device_remove(pdev); 347 + dev_set_drvdata(pdev, NULL); 348 + return 0; 349 + } 350 + 351 + #ifdef CONFIG_PM 352 + static int el3_isa_suspend(struct device *dev, unsigned int n, 353 + pm_message_t state) 354 + { 355 + current_tag = 0; 356 + return el3_suspend(dev, state); 357 + } 358 + 359 + static int el3_isa_resume(struct device *dev, unsigned int n) 360 + { 361 + struct net_device *ndev = dev_get_drvdata(dev); 362 + int ioaddr = ndev->base_addr, err; 363 + __be16 phys_addr[3]; 364 + 365 + while ((err = el3_isa_id_sequence(phys_addr)) == 2) 366 + ; /* Skip to next card when PnP card found */ 367 + if (err == 1) 368 + return 0; 369 + /* Set the adaptor tag so that the next card can be found. */ 370 + outb(0xd0 + ++current_tag, id_port); 371 + /* Enable the card */ 372 + outb((ioaddr >> 4) | 0xe0, id_port); 373 + EL3WINDOW(0); 374 + if (inw(ioaddr) != 0x6d50) 375 + return 1; 376 + /* Free the interrupt so that some other card can use it. */ 377 + outw(0x0f00, ioaddr + WN0_IRQ); 378 + return el3_resume(dev); 379 + } 380 + #endif 381 + 382 + static struct isa_driver el3_isa_driver = { 383 + .match = el3_isa_match, 384 + .remove = __devexit_p(el3_isa_remove), 385 + #ifdef CONFIG_PM 386 + .suspend = el3_isa_suspend, 387 + .resume = el3_isa_resume, 388 + #endif 389 + .driver = { 390 + .name = "3c509" 391 + }, 392 + }; 393 + static int isa_registered; 394 + 395 + #ifdef CONFIG_PNP 396 + static struct pnp_device_id el3_pnp_ids[] = { 397 + { .id = "TCM5090" }, /* 3Com Etherlink III (TP) */ 398 + { .id = "TCM5091" }, /* 3Com Etherlink III */ 399 + { .id = "TCM5094" }, /* 3Com Etherlink III (combo) */ 400 + { .id = "TCM5095" }, /* 3Com Etherlink III (TPO) */ 401 + { .id = "TCM5098" }, /* 3Com Etherlink III (TPC) */ 402 + { .id = "PNP80f7" }, /* 3Com Etherlink III compatible */ 403 + { .id = "PNP80f8" }, /* 3Com Etherlink III compatible */ 404 + { .id = "" } 405 + }; 406 + MODULE_DEVICE_TABLE(pnp, el3_pnp_ids); 407 + 408 + static int __devinit el3_pnp_probe(struct pnp_dev *pdev, 409 + const struct pnp_device_id *id) 410 + { 411 + short i; 412 + int ioaddr, irq, if_port; 413 + u16 phys_addr[3]; 414 + struct net_device *dev = NULL; 415 + int err; 416 + 417 + ioaddr = pnp_port_start(pdev, 0); 418 + if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509-pnp")) 419 + return -EBUSY; 420 + irq = pnp_irq(pdev, 0); 421 + EL3WINDOW(0); 422 + for (i = 0; i < 3; i++) 423 + phys_addr[i] = htons(read_eeprom(ioaddr, i)); 424 + if_port = read_eeprom(ioaddr, 8) >> 14; 425 + dev = alloc_etherdev(sizeof(struct el3_private)); 426 + if (!dev) { 427 + release_region(ioaddr, EL3_IO_EXTENT); 428 + return -ENOMEM; 429 + } 430 + SET_NETDEV_DEV(dev, &pdev->dev); 431 + netdev_boot_setup_check(dev); 432 + 433 + el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_PNP); 434 + pnp_set_drvdata(pdev, dev); 435 + err = el3_common_init(dev); 436 + 437 + if (err) { 438 + pnp_set_drvdata(pdev, NULL); 439 + free_netdev(dev); 440 + return err; 441 + } 442 + 443 + el3_devs[el3_cards++] = dev; 444 + return 0; 445 + } 446 + 447 + static void __devexit el3_pnp_remove(struct pnp_dev *pdev) 448 + { 449 + el3_common_remove(pnp_get_drvdata(pdev)); 450 + pnp_set_drvdata(pdev, NULL); 451 + } 452 + 453 + #ifdef CONFIG_PM 454 + static int el3_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) 455 + { 456 + return el3_suspend(&pdev->dev, state); 457 + } 458 + 459 + static int el3_pnp_resume(struct pnp_dev *pdev) 460 + { 461 + return el3_resume(&pdev->dev); 462 + } 463 + #endif 464 + 465 + static struct pnp_driver el3_pnp_driver = { 466 + .name = "3c509", 467 + .id_table = el3_pnp_ids, 468 + .probe = el3_pnp_probe, 469 + .remove = __devexit_p(el3_pnp_remove), 470 + #ifdef CONFIG_PM 471 + .suspend = el3_pnp_suspend, 472 + .resume = el3_pnp_resume, 473 + #endif 474 + }; 475 + static int pnp_registered; 476 + #endif /* CONFIG_PNP */ 222 477 223 478 #ifdef CONFIG_EISA 224 479 static struct eisa_device_id el3_eisa_ids[] = { ··· 493 230 static struct eisa_driver el3_eisa_driver = { 494 231 .id_table = el3_eisa_ids, 495 232 .driver = { 496 - .name = "3c509", 233 + .name = "3c579", 497 234 .probe = el3_eisa_probe, 498 235 .remove = __devexit_p (el3_device_remove), 499 236 .suspend = el3_suspend, 500 237 .resume = el3_resume, 501 238 } 502 239 }; 240 + static int eisa_registered; 503 241 #endif 504 242 505 243 #ifdef CONFIG_MCA ··· 535 271 .resume = el3_resume, 536 272 }, 537 273 }; 274 + static int mca_registered; 538 275 #endif /* CONFIG_MCA */ 539 - 540 - #if defined(__ISAPNP__) 541 - static struct isapnp_device_id el3_isapnp_adapters[] __initdata = { 542 - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 543 - ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5090), 544 - (long) "3Com Etherlink III (TP)" }, 545 - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 546 - ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5091), 547 - (long) "3Com Etherlink III" }, 548 - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 549 - ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5094), 550 - (long) "3Com Etherlink III (combo)" }, 551 - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 552 - ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5095), 553 - (long) "3Com Etherlink III (TPO)" }, 554 - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 555 - ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5098), 556 - (long) "3Com Etherlink III (TPC)" }, 557 - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 558 - ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_FUNCTION(0x80f7), 559 - (long) "3Com Etherlink III compatible" }, 560 - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 561 - ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_FUNCTION(0x80f8), 562 - (long) "3Com Etherlink III compatible" }, 563 - { } /* terminate list */ 564 - }; 565 - 566 - static __be16 el3_isapnp_phys_addr[8][3]; 567 - static int nopnp; 568 - #endif /* __ISAPNP__ */ 569 - 570 - /* With the driver model introduction for EISA devices, both init 571 - * and cleanup have been split : 572 - * - EISA devices probe/remove starts in el3_eisa_probe/el3_device_remove 573 - * - MCA/ISA still use el3_probe 574 - * 575 - * Both call el3_common_init/el3_common_remove. */ 576 276 577 277 static int __init el3_common_init(struct net_device *dev) 578 278 { ··· 588 360 589 361 static void el3_common_remove (struct net_device *dev) 590 362 { 591 - struct el3_private *lp = netdev_priv(dev); 592 - 593 - (void) lp; /* Keep gcc quiet... */ 594 - #if defined(__ISAPNP__) 595 - if (lp->type == EL3_PNP) 596 - pnp_device_detach(to_pnp_dev(lp->dev)); 597 - #endif 598 - 599 363 unregister_netdev (dev); 600 364 release_region(dev->base_addr, EL3_IO_EXTENT); 601 365 free_netdev (dev); 602 - } 603 - 604 - static int __init el3_probe(int card_idx) 605 - { 606 - struct net_device *dev; 607 - struct el3_private *lp; 608 - short lrs_state = 0xff, i; 609 - int ioaddr, irq, if_port; 610 - __be16 phys_addr[3]; 611 - static int current_tag; 612 - int err = -ENODEV; 613 - #if defined(__ISAPNP__) 614 - static int pnp_cards; 615 - struct pnp_dev *idev = NULL; 616 - int pnp_found = 0; 617 - 618 - if (nopnp == 1) 619 - goto no_pnp; 620 - 621 - for (i=0; el3_isapnp_adapters[i].vendor != 0; i++) { 622 - int j; 623 - while ((idev = pnp_find_dev(NULL, 624 - el3_isapnp_adapters[i].vendor, 625 - el3_isapnp_adapters[i].function, 626 - idev))) { 627 - if (pnp_device_attach(idev) < 0) 628 - continue; 629 - if (pnp_activate_dev(idev) < 0) { 630 - __again: 631 - pnp_device_detach(idev); 632 - continue; 633 - } 634 - if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0)) 635 - goto __again; 636 - ioaddr = pnp_port_start(idev, 0); 637 - if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509 PnP")) { 638 - pnp_device_detach(idev); 639 - return -EBUSY; 640 - } 641 - irq = pnp_irq(idev, 0); 642 - if (el3_debug > 3) 643 - printk ("ISAPnP reports %s at i/o 0x%x, irq %d\n", 644 - (char*) el3_isapnp_adapters[i].driver_data, ioaddr, irq); 645 - EL3WINDOW(0); 646 - for (j = 0; j < 3; j++) 647 - el3_isapnp_phys_addr[pnp_cards][j] = 648 - phys_addr[j] = 649 - htons(read_eeprom(ioaddr, j)); 650 - if_port = read_eeprom(ioaddr, 8) >> 14; 651 - dev = alloc_etherdev(sizeof (struct el3_private)); 652 - if (!dev) { 653 - release_region(ioaddr, EL3_IO_EXTENT); 654 - pnp_device_detach(idev); 655 - return -ENOMEM; 656 - } 657 - 658 - SET_NETDEV_DEV(dev, &idev->dev); 659 - pnp_cards++; 660 - 661 - netdev_boot_setup_check(dev); 662 - pnp_found = 1; 663 - goto found; 664 - } 665 - } 666 - no_pnp: 667 - #endif /* __ISAPNP__ */ 668 - 669 - /* Select an open I/O location at 0x1*0 to do contention select. */ 670 - for ( ; id_port < 0x200; id_port += 0x10) { 671 - if (!request_region(id_port, 1, "3c509")) 672 - continue; 673 - outb(0x00, id_port); 674 - outb(0xff, id_port); 675 - if (inb(id_port) & 0x01){ 676 - release_region(id_port, 1); 677 - break; 678 - } else 679 - release_region(id_port, 1); 680 - } 681 - if (id_port >= 0x200) { 682 - /* Rare -- do we really need a warning? */ 683 - printk(" WARNING: No I/O port available for 3c509 activation.\n"); 684 - return -ENODEV; 685 - } 686 - 687 - /* Next check for all ISA bus boards by sending the ID sequence to the 688 - ID_PORT. We find cards past the first by setting the 'current_tag' 689 - on cards as they are found. Cards with their tag set will not 690 - respond to subsequent ID sequences. */ 691 - 692 - outb(0x00, id_port); 693 - outb(0x00, id_port); 694 - for(i = 0; i < 255; i++) { 695 - outb(lrs_state, id_port); 696 - lrs_state <<= 1; 697 - lrs_state = lrs_state & 0x100 ? lrs_state ^ 0xcf : lrs_state; 698 - } 699 - 700 - /* For the first probe, clear all board's tag registers. */ 701 - if (current_tag == 0) 702 - outb(0xd0, id_port); 703 - else /* Otherwise kill off already-found boards. */ 704 - outb(0xd8, id_port); 705 - 706 - if (id_read_eeprom(7) != 0x6d50) { 707 - return -ENODEV; 708 - } 709 - 710 - /* Read in EEPROM data, which does contention-select. 711 - Only the lowest address board will stay "on-line". 712 - 3Com got the byte order backwards. */ 713 - for (i = 0; i < 3; i++) { 714 - phys_addr[i] = htons(id_read_eeprom(i)); 715 - } 716 - 717 - #if defined(__ISAPNP__) 718 - if (nopnp == 0) { 719 - /* The ISA PnP 3c509 cards respond to the ID sequence. 720 - This check is needed in order not to register them twice. */ 721 - for (i = 0; i < pnp_cards; i++) { 722 - if (phys_addr[0] == el3_isapnp_phys_addr[i][0] && 723 - phys_addr[1] == el3_isapnp_phys_addr[i][1] && 724 - phys_addr[2] == el3_isapnp_phys_addr[i][2]) 725 - { 726 - if (el3_debug > 3) 727 - printk("3c509 with address %02x %02x %02x %02x %02x %02x was found by ISAPnP\n", 728 - phys_addr[0] & 0xff, phys_addr[0] >> 8, 729 - phys_addr[1] & 0xff, phys_addr[1] >> 8, 730 - phys_addr[2] & 0xff, phys_addr[2] >> 8); 731 - /* Set the adaptor tag so that the next card can be found. */ 732 - outb(0xd0 + ++current_tag, id_port); 733 - goto no_pnp; 734 - } 735 - } 736 - } 737 - #endif /* __ISAPNP__ */ 738 - 739 - { 740 - unsigned int iobase = id_read_eeprom(8); 741 - if_port = iobase >> 14; 742 - ioaddr = 0x200 + ((iobase & 0x1f) << 4); 743 - } 744 - irq = id_read_eeprom(9) >> 12; 745 - 746 - dev = alloc_etherdev(sizeof (struct el3_private)); 747 - if (!dev) 748 - return -ENOMEM; 749 - 750 - netdev_boot_setup_check(dev); 751 - 752 - /* Set passed-in IRQ or I/O Addr. */ 753 - if (dev->irq > 1 && dev->irq < 16) 754 - irq = dev->irq; 755 - 756 - if (dev->base_addr) { 757 - if (dev->mem_end == 0x3c509 /* Magic key */ 758 - && dev->base_addr >= 0x200 && dev->base_addr <= 0x3e0) 759 - ioaddr = dev->base_addr & 0x3f0; 760 - else if (dev->base_addr != ioaddr) 761 - goto out; 762 - } 763 - 764 - if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509")) { 765 - err = -EBUSY; 766 - goto out; 767 - } 768 - 769 - /* Set the adaptor tag so that the next card can be found. */ 770 - outb(0xd0 + ++current_tag, id_port); 771 - 772 - /* Activate the adaptor at the EEPROM location. */ 773 - outb((ioaddr >> 4) | 0xe0, id_port); 774 - 775 - EL3WINDOW(0); 776 - if (inw(ioaddr) != 0x6d50) 777 - goto out1; 778 - 779 - /* Free the interrupt so that some other card can use it. */ 780 - outw(0x0f00, ioaddr + WN0_IRQ); 781 - 782 - #if defined(__ISAPNP__) 783 - found: /* PNP jumps here... */ 784 - #endif /* __ISAPNP__ */ 785 - 786 - memcpy(dev->dev_addr, phys_addr, sizeof(phys_addr)); 787 - dev->base_addr = ioaddr; 788 - dev->irq = irq; 789 - dev->if_port = if_port; 790 - lp = netdev_priv(dev); 791 - #if defined(__ISAPNP__) 792 - lp->dev = &idev->dev; 793 - if (pnp_found) 794 - lp->type = EL3_PNP; 795 - #endif 796 - err = el3_common_init(dev); 797 - 798 - if (err) 799 - goto out1; 800 - 801 - el3_cards++; 802 - lp->next_dev = el3_root_dev; 803 - el3_root_dev = dev; 804 - return 0; 805 - 806 - out1: 807 - #if defined(__ISAPNP__) 808 - if (idev) 809 - pnp_device_detach(idev); 810 - #endif 811 - out: 812 - free_netdev(dev); 813 - return err; 814 366 } 815 367 816 368 #ifdef CONFIG_MCA ··· 604 596 * redone for multi-card detection by ZP Gu (zpg@castle.net) 605 597 * now works as a module */ 606 598 607 - struct el3_private *lp; 608 599 short i; 609 600 int ioaddr, irq, if_port; 610 601 u16 phys_addr[3]; ··· 620 613 irq = pos5 & 0x0f; 621 614 622 615 623 - printk("3c529: found %s at slot %d\n", 616 + printk(KERN_INFO "3c529: found %s at slot %d\n", 624 617 el3_mca_adapter_names[mdev->index], slot + 1); 625 618 626 619 /* claim the slot */ ··· 633 626 irq = mca_device_transform_irq(mdev, irq); 634 627 ioaddr = mca_device_transform_ioport(mdev, ioaddr); 635 628 if (el3_debug > 2) { 636 - printk("3c529: irq %d ioaddr 0x%x ifport %d\n", irq, ioaddr, if_port); 629 + printk(KERN_DEBUG "3c529: irq %d ioaddr 0x%x ifport %d\n", irq, ioaddr, if_port); 637 630 } 638 631 EL3WINDOW(0); 639 632 for (i = 0; i < 3; i++) { ··· 648 641 649 642 netdev_boot_setup_check(dev); 650 643 651 - memcpy(dev->dev_addr, phys_addr, sizeof(phys_addr)); 652 - dev->base_addr = ioaddr; 653 - dev->irq = irq; 654 - dev->if_port = if_port; 655 - lp = netdev_priv(dev); 656 - lp->dev = device; 657 - lp->type = EL3_MCA; 644 + el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_MCA); 658 645 device->driver_data = dev; 659 646 err = el3_common_init(dev); 660 647 ··· 658 657 return -ENOMEM; 659 658 } 660 659 661 - el3_cards++; 660 + el3_devs[el3_cards++] = dev; 662 661 return 0; 663 662 } 664 663 ··· 667 666 #ifdef CONFIG_EISA 668 667 static int __init el3_eisa_probe (struct device *device) 669 668 { 670 - struct el3_private *lp; 671 669 short i; 672 670 int ioaddr, irq, if_port; 673 671 u16 phys_addr[3]; ··· 678 678 edev = to_eisa_device (device); 679 679 ioaddr = edev->base_addr; 680 680 681 - if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509")) 681 + if (!request_region(ioaddr, EL3_IO_EXTENT, "3c579-eisa")) 682 682 return -EBUSY; 683 683 684 684 /* Change the register set to the configuration window 0. */ ··· 700 700 701 701 netdev_boot_setup_check(dev); 702 702 703 - memcpy(dev->dev_addr, phys_addr, sizeof(phys_addr)); 704 - dev->base_addr = ioaddr; 705 - dev->irq = irq; 706 - dev->if_port = if_port; 707 - lp = netdev_priv(dev); 708 - lp->dev = device; 709 - lp->type = EL3_EISA; 703 + el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_EISA); 710 704 eisa_set_drvdata (edev, dev); 711 705 err = el3_common_init(dev); 712 706 ··· 710 716 return err; 711 717 } 712 718 713 - el3_cards++; 719 + el3_devs[el3_cards++] = dev; 714 720 return 0; 715 721 } 716 722 #endif 717 723 718 - #if defined(CONFIG_EISA) || defined(CONFIG_MCA) 719 724 /* This remove works for all device types. 720 725 * 721 726 * The net dev must be stored in the driver_data field */ ··· 727 734 el3_common_remove (dev); 728 735 return 0; 729 736 } 730 - #endif 731 737 732 738 /* Read a word from the EEPROM using the regular EEPROM access register. 733 739 Assume that we are in register window zero. ··· 741 749 } 742 750 743 751 /* Read a word from the EEPROM when in the ISA ID probe state. */ 744 - static ushort __init id_read_eeprom(int index) 752 + static ushort id_read_eeprom(int index) 745 753 { 746 754 int bit, word = 0; 747 755 ··· 757 765 word = (word << 1) + (inb(id_port) & 0x01); 758 766 759 767 if (el3_debug > 3) 760 - printk(" 3c509 EEPROM word %d %#4.4x.\n", index, word); 768 + printk(KERN_DEBUG " 3c509 EEPROM word %d %#4.4x.\n", index, word); 761 769 762 770 return word; 763 771 } ··· 779 787 780 788 EL3WINDOW(0); 781 789 if (el3_debug > 3) 782 - printk("%s: Opening, IRQ %d status@%x %4.4x.\n", dev->name, 790 + printk(KERN_DEBUG "%s: Opening, IRQ %d status@%x %4.4x.\n", dev->name, 783 791 dev->irq, ioaddr + EL3_STATUS, inw(ioaddr + EL3_STATUS)); 784 792 785 793 el3_up(dev); 786 794 787 795 if (el3_debug > 3) 788 - printk("%s: Opened 3c509 IRQ %d status %4.4x.\n", 796 + printk(KERN_DEBUG "%s: Opened 3c509 IRQ %d status %4.4x.\n", 789 797 dev->name, dev->irq, inw(ioaddr + EL3_STATUS)); 790 798 791 799 return 0; ··· 798 806 int ioaddr = dev->base_addr; 799 807 800 808 /* Transmitter timeout, serious problems. */ 801 - printk("%s: transmit timed out, Tx_status %2.2x status %4.4x " 809 + printk(KERN_WARNING "%s: transmit timed out, Tx_status %2.2x status %4.4x " 802 810 "Tx FIFO room %d.\n", 803 811 dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS), 804 812 inw(ioaddr + TX_FREE)); ··· 823 831 lp->stats.tx_bytes += skb->len; 824 832 825 833 if (el3_debug > 4) { 826 - printk("%s: el3_start_xmit(length = %u) called, status %4.4x.\n", 834 + printk(KERN_DEBUG "%s: el3_start_xmit(length = %u) called, status %4.4x.\n", 827 835 dev->name, skb->len, inw(ioaddr + EL3_STATUS)); 828 836 } 829 837 #if 0 ··· 832 840 ushort status = inw(ioaddr + EL3_STATUS); 833 841 if (status & 0x0001 /* IRQ line active, missed one. */ 834 842 && inw(ioaddr + EL3_STATUS) & 1) { /* Make sure. */ 835 - printk("%s: Missed interrupt, status then %04x now %04x" 843 + printk(KERN_DEBUG "%s: Missed interrupt, status then %04x now %04x" 836 844 " Tx %2.2x Rx %4.4x.\n", dev->name, status, 837 845 inw(ioaddr + EL3_STATUS), inb(ioaddr + TX_STATUS), 838 846 inw(ioaddr + RX_STATUS)); ··· 906 914 907 915 if (el3_debug > 4) { 908 916 status = inw(ioaddr + EL3_STATUS); 909 - printk("%s: interrupt, status %4.4x.\n", dev->name, status); 917 + printk(KERN_DEBUG "%s: interrupt, status %4.4x.\n", dev->name, status); 910 918 } 911 919 912 920 while ((status = inw(ioaddr + EL3_STATUS)) & ··· 917 925 918 926 if (status & TxAvailable) { 919 927 if (el3_debug > 5) 920 - printk(" TX room bit was handled.\n"); 928 + printk(KERN_DEBUG " TX room bit was handled.\n"); 921 929 /* There's room in the FIFO for a full-sized packet. */ 922 930 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); 923 931 netif_wake_queue (dev); ··· 956 964 } 957 965 958 966 if (--i < 0) { 959 - printk("%s: Infinite loop in interrupt, status %4.4x.\n", 967 + printk(KERN_ERR "%s: Infinite loop in interrupt, status %4.4x.\n", 960 968 dev->name, status); 961 969 /* Clear all interrupts. */ 962 970 outw(AckIntr | 0xFF, ioaddr + EL3_CMD); ··· 967 975 } 968 976 969 977 if (el3_debug > 4) { 970 - printk("%s: exiting interrupt, status %4.4x.\n", dev->name, 978 + printk(KERN_DEBUG "%s: exiting interrupt, status %4.4x.\n", dev->name, 971 979 inw(ioaddr + EL3_STATUS)); 972 980 } 973 981 spin_unlock(&lp->lock); ··· 1442 1450 } 1443 1451 1444 1452 /* Power Management support functions */ 1445 - #ifdef EL3_SUSPEND 1453 + #ifdef CONFIG_PM 1446 1454 1447 1455 static int 1448 1456 el3_suspend(struct device *pdev, pm_message_t state) ··· 1492 1500 return 0; 1493 1501 } 1494 1502 1495 - #endif /* EL3_SUSPEND */ 1496 - 1497 - /* Parameters that may be passed into the module. */ 1498 - static int debug = -1; 1499 - static int irq[] = {-1, -1, -1, -1, -1, -1, -1, -1}; 1500 - static int xcvr[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; 1503 + #endif /* CONFIG_PM */ 1501 1504 1502 1505 module_param(debug,int, 0); 1503 1506 module_param_array(irq, int, NULL, 0); 1504 - module_param_array(xcvr, int, NULL, 0); 1505 1507 module_param(max_interrupt_work, int, 0); 1506 1508 MODULE_PARM_DESC(debug, "debug level (0-6)"); 1507 1509 MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); 1508 - MODULE_PARM_DESC(xcvr,"transceiver(s) (0=internal, 1=external)"); 1509 1510 MODULE_PARM_DESC(max_interrupt_work, "maximum events handled per interrupt"); 1510 - #if defined(__ISAPNP__) 1511 + #ifdef CONFIG_PNP 1511 1512 module_param(nopnp, int, 0); 1512 1513 MODULE_PARM_DESC(nopnp, "disable ISA PnP support (0-1)"); 1513 - MODULE_DEVICE_TABLE(isapnp, el3_isapnp_adapters); 1514 - #endif /* __ISAPNP__ */ 1515 - MODULE_DESCRIPTION("3Com Etherlink III (3c509, 3c509B) ISA/PnP ethernet driver"); 1514 + #endif /* CONFIG_PNP */ 1515 + MODULE_DESCRIPTION("3Com Etherlink III (3c509, 3c509B, 3c529, 3c579) ethernet driver"); 1516 1516 MODULE_LICENSE("GPL"); 1517 1517 1518 1518 static int __init el3_init_module(void) 1519 1519 { 1520 1520 int ret = 0; 1521 - el3_cards = 0; 1522 1521 1523 1522 if (debug >= 0) 1524 1523 el3_debug = debug; 1525 1524 1526 - el3_root_dev = NULL; 1527 - while (el3_probe(el3_cards) == 0) { 1528 - if (irq[el3_cards] > 1) 1529 - el3_root_dev->irq = irq[el3_cards]; 1530 - if (xcvr[el3_cards] >= 0) 1531 - el3_root_dev->if_port = xcvr[el3_cards]; 1532 - el3_cards++; 1525 + #ifdef CONFIG_PNP 1526 + if (!nopnp) { 1527 + ret = pnp_register_driver(&el3_pnp_driver); 1528 + if (!ret) 1529 + pnp_registered = 1; 1533 1530 } 1534 - 1531 + #endif 1532 + /* Select an open I/O location at 0x1*0 to do ISA contention select. */ 1533 + /* Start with 0x110 to avoid some sound cards.*/ 1534 + for (id_port = 0x110 ; id_port < 0x200; id_port += 0x10) { 1535 + if (!request_region(id_port, 1, "3c509-control")) 1536 + continue; 1537 + outb(0x00, id_port); 1538 + outb(0xff, id_port); 1539 + if (inb(id_port) & 0x01) 1540 + break; 1541 + else 1542 + release_region(id_port, 1); 1543 + } 1544 + if (id_port >= 0x200) { 1545 + id_port = 0; 1546 + printk(KERN_ERR "No I/O port available for 3c509 activation.\n"); 1547 + } else { 1548 + ret = isa_register_driver(&el3_isa_driver, EL3_MAX_CARDS); 1549 + if (!ret) 1550 + isa_registered = 1; 1551 + } 1535 1552 #ifdef CONFIG_EISA 1536 1553 ret = eisa_driver_register(&el3_eisa_driver); 1554 + if (!ret) 1555 + eisa_registered = 1; 1537 1556 #endif 1538 1557 #ifdef CONFIG_MCA 1539 - { 1540 - int err = mca_register_driver(&el3_mca_driver); 1541 - if (ret == 0) 1542 - ret = err; 1543 - } 1558 + ret = mca_register_driver(&el3_mca_driver); 1559 + if (!ret) 1560 + mca_registered = 1; 1561 + #endif 1562 + 1563 + #ifdef CONFIG_PNP 1564 + if (pnp_registered) 1565 + ret = 0; 1566 + #endif 1567 + if (isa_registered) 1568 + ret = 0; 1569 + #ifdef CONFIG_EISA 1570 + if (eisa_registered) 1571 + ret = 0; 1572 + #endif 1573 + #ifdef CONFIG_MCA 1574 + if (mca_registered) 1575 + ret = 0; 1544 1576 #endif 1545 1577 return ret; 1546 1578 } 1547 1579 1548 1580 static void __exit el3_cleanup_module(void) 1549 1581 { 1550 - struct net_device *next_dev; 1551 - 1552 - while (el3_root_dev) { 1553 - struct el3_private *lp = netdev_priv(el3_root_dev); 1554 - 1555 - next_dev = lp->next_dev; 1556 - el3_common_remove (el3_root_dev); 1557 - el3_root_dev = next_dev; 1558 - } 1559 - 1582 + #ifdef CONFIG_PNP 1583 + if (pnp_registered) 1584 + pnp_unregister_driver(&el3_pnp_driver); 1585 + #endif 1586 + if (isa_registered) 1587 + isa_unregister_driver(&el3_isa_driver); 1588 + if (id_port) 1589 + release_region(id_port, 1); 1560 1590 #ifdef CONFIG_EISA 1561 - eisa_driver_unregister (&el3_eisa_driver); 1591 + if (eisa_registered) 1592 + eisa_driver_unregister(&el3_eisa_driver); 1562 1593 #endif 1563 1594 #ifdef CONFIG_MCA 1564 - mca_unregister_driver(&el3_mca_driver); 1595 + if (mca_registered) 1596 + mca_unregister_driver(&el3_mca_driver); 1565 1597 #endif 1566 1598 } 1567 1599 1568 1600 module_init (el3_init_module); 1569 1601 module_exit (el3_cleanup_module); 1570 -