diff options
Diffstat (limited to 'drivers/net/pcmcia/smc91c92_cs.c')
-rw-r--r-- | drivers/net/pcmcia/smc91c92_cs.c | 235 |
1 files changed, 101 insertions, 134 deletions
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 8839c4faafd6..e74bf5014ef6 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <pcmcia/cisreg.h> | 49 | #include <pcmcia/cisreg.h> |
50 | #include <pcmcia/ciscode.h> | 50 | #include <pcmcia/ciscode.h> |
51 | #include <pcmcia/ds.h> | 51 | #include <pcmcia/ds.h> |
52 | #include <pcmcia/ss.h> | ||
52 | 53 | ||
53 | #include <asm/io.h> | 54 | #include <asm/io.h> |
54 | #include <asm/system.h> | 55 | #include <asm/system.h> |
@@ -103,7 +104,7 @@ static const char *version = | |||
103 | #define MEMORY_WAIT_TIME 8 | 104 | #define MEMORY_WAIT_TIME 8 |
104 | 105 | ||
105 | struct smc_private { | 106 | struct smc_private { |
106 | dev_link_t link; | 107 | struct pcmcia_device *p_dev; |
107 | spinlock_t lock; | 108 | spinlock_t lock; |
108 | u_short manfid; | 109 | u_short manfid; |
109 | u_short cardid; | 110 | u_short cardid; |
@@ -278,8 +279,8 @@ enum RxCfg { RxAllMulti = 0x0004, RxPromisc = 0x0002, | |||
278 | /*====================================================================*/ | 279 | /*====================================================================*/ |
279 | 280 | ||
280 | static void smc91c92_detach(struct pcmcia_device *p_dev); | 281 | static void smc91c92_detach(struct pcmcia_device *p_dev); |
281 | static void smc91c92_config(dev_link_t *link); | 282 | static int smc91c92_config(struct pcmcia_device *link); |
282 | static void smc91c92_release(dev_link_t *link); | 283 | static void smc91c92_release(struct pcmcia_device *link); |
283 | 284 | ||
284 | static int smc_open(struct net_device *dev); | 285 | static int smc_open(struct net_device *dev); |
285 | static int smc_close(struct net_device *dev); | 286 | static int smc_close(struct net_device *dev); |
@@ -308,10 +309,9 @@ static struct ethtool_ops ethtool_ops; | |||
308 | 309 | ||
309 | ======================================================================*/ | 310 | ======================================================================*/ |
310 | 311 | ||
311 | static int smc91c92_attach(struct pcmcia_device *p_dev) | 312 | static int smc91c92_probe(struct pcmcia_device *link) |
312 | { | 313 | { |
313 | struct smc_private *smc; | 314 | struct smc_private *smc; |
314 | dev_link_t *link; | ||
315 | struct net_device *dev; | 315 | struct net_device *dev; |
316 | 316 | ||
317 | DEBUG(0, "smc91c92_attach()\n"); | 317 | DEBUG(0, "smc91c92_attach()\n"); |
@@ -321,7 +321,7 @@ static int smc91c92_attach(struct pcmcia_device *p_dev) | |||
321 | if (!dev) | 321 | if (!dev) |
322 | return -ENOMEM; | 322 | return -ENOMEM; |
323 | smc = netdev_priv(dev); | 323 | smc = netdev_priv(dev); |
324 | link = &smc->link; | 324 | smc->p_dev = link; |
325 | link->priv = dev; | 325 | link->priv = dev; |
326 | 326 | ||
327 | spin_lock_init(&smc->lock); | 327 | spin_lock_init(&smc->lock); |
@@ -333,7 +333,6 @@ static int smc91c92_attach(struct pcmcia_device *p_dev) | |||
333 | link->irq.Handler = &smc_interrupt; | 333 | link->irq.Handler = &smc_interrupt; |
334 | link->irq.Instance = dev; | 334 | link->irq.Instance = dev; |
335 | link->conf.Attributes = CONF_ENABLE_IRQ; | 335 | link->conf.Attributes = CONF_ENABLE_IRQ; |
336 | link->conf.Vcc = 50; | ||
337 | link->conf.IntType = INT_MEMORY_AND_IO; | 336 | link->conf.IntType = INT_MEMORY_AND_IO; |
338 | 337 | ||
339 | /* The SMC91c92-specific entries in the device structure. */ | 338 | /* The SMC91c92-specific entries in the device structure. */ |
@@ -357,13 +356,7 @@ static int smc91c92_attach(struct pcmcia_device *p_dev) | |||
357 | smc->mii_if.phy_id_mask = 0x1f; | 356 | smc->mii_if.phy_id_mask = 0x1f; |
358 | smc->mii_if.reg_num_mask = 0x1f; | 357 | smc->mii_if.reg_num_mask = 0x1f; |
359 | 358 | ||
360 | link->handle = p_dev; | 359 | return smc91c92_config(link); |
361 | p_dev->instance = link; | ||
362 | |||
363 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
364 | smc91c92_config(link); | ||
365 | |||
366 | return 0; | ||
367 | } /* smc91c92_attach */ | 360 | } /* smc91c92_attach */ |
368 | 361 | ||
369 | /*====================================================================== | 362 | /*====================================================================== |
@@ -375,18 +368,16 @@ static int smc91c92_attach(struct pcmcia_device *p_dev) | |||
375 | 368 | ||
376 | ======================================================================*/ | 369 | ======================================================================*/ |
377 | 370 | ||
378 | static void smc91c92_detach(struct pcmcia_device *p_dev) | 371 | static void smc91c92_detach(struct pcmcia_device *link) |
379 | { | 372 | { |
380 | dev_link_t *link = dev_to_instance(p_dev); | ||
381 | struct net_device *dev = link->priv; | 373 | struct net_device *dev = link->priv; |
382 | 374 | ||
383 | DEBUG(0, "smc91c92_detach(0x%p)\n", link); | 375 | DEBUG(0, "smc91c92_detach(0x%p)\n", link); |
384 | 376 | ||
385 | if (link->dev) | 377 | if (link->dev_node) |
386 | unregister_netdev(dev); | 378 | unregister_netdev(dev); |
387 | 379 | ||
388 | if (link->state & DEV_CONFIG) | 380 | smc91c92_release(link); |
389 | smc91c92_release(link); | ||
390 | 381 | ||
391 | free_netdev(dev); | 382 | free_netdev(dev); |
392 | } /* smc91c92_detach */ | 383 | } /* smc91c92_detach */ |
@@ -414,7 +405,7 @@ static int cvt_ascii_address(struct net_device *dev, char *s) | |||
414 | 405 | ||
415 | /*====================================================================*/ | 406 | /*====================================================================*/ |
416 | 407 | ||
417 | static int first_tuple(client_handle_t handle, tuple_t *tuple, | 408 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, |
418 | cisparse_t *parse) | 409 | cisparse_t *parse) |
419 | { | 410 | { |
420 | int i; | 411 | int i; |
@@ -425,7 +416,7 @@ static int first_tuple(client_handle_t handle, tuple_t *tuple, | |||
425 | return pcmcia_parse_tuple(handle, tuple, parse); | 416 | return pcmcia_parse_tuple(handle, tuple, parse); |
426 | } | 417 | } |
427 | 418 | ||
428 | static int next_tuple(client_handle_t handle, tuple_t *tuple, | 419 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, |
429 | cisparse_t *parse) | 420 | cisparse_t *parse) |
430 | { | 421 | { |
431 | int i; | 422 | int i; |
@@ -447,7 +438,7 @@ static int next_tuple(client_handle_t handle, tuple_t *tuple, | |||
447 | 438 | ||
448 | ======================================================================*/ | 439 | ======================================================================*/ |
449 | 440 | ||
450 | static int mhz_3288_power(dev_link_t *link) | 441 | static int mhz_3288_power(struct pcmcia_device *link) |
451 | { | 442 | { |
452 | struct net_device *dev = link->priv; | 443 | struct net_device *dev = link->priv; |
453 | struct smc_private *smc = netdev_priv(dev); | 444 | struct smc_private *smc = netdev_priv(dev); |
@@ -469,7 +460,7 @@ static int mhz_3288_power(dev_link_t *link) | |||
469 | return 0; | 460 | return 0; |
470 | } | 461 | } |
471 | 462 | ||
472 | static int mhz_mfc_config(dev_link_t *link) | 463 | static int mhz_mfc_config(struct pcmcia_device *link) |
473 | { | 464 | { |
474 | struct net_device *dev = link->priv; | 465 | struct net_device *dev = link->priv; |
475 | struct smc_private *smc = netdev_priv(dev); | 466 | struct smc_private *smc = netdev_priv(dev); |
@@ -504,7 +495,7 @@ static int mhz_mfc_config(dev_link_t *link) | |||
504 | tuple->TupleDataMax = 255; | 495 | tuple->TupleDataMax = 255; |
505 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | 496 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; |
506 | 497 | ||
507 | i = first_tuple(link->handle, tuple, parse); | 498 | i = first_tuple(link, tuple, parse); |
508 | /* The Megahertz combo cards have modem-like CIS entries, so | 499 | /* The Megahertz combo cards have modem-like CIS entries, so |
509 | we have to explicitly try a bunch of port combinations. */ | 500 | we have to explicitly try a bunch of port combinations. */ |
510 | while (i == CS_SUCCESS) { | 501 | while (i == CS_SUCCESS) { |
@@ -513,11 +504,11 @@ static int mhz_mfc_config(dev_link_t *link) | |||
513 | for (k = 0; k < 0x400; k += 0x10) { | 504 | for (k = 0; k < 0x400; k += 0x10) { |
514 | if (k & 0x80) continue; | 505 | if (k & 0x80) continue; |
515 | link->io.BasePort1 = k ^ 0x300; | 506 | link->io.BasePort1 = k ^ 0x300; |
516 | i = pcmcia_request_io(link->handle, &link->io); | 507 | i = pcmcia_request_io(link, &link->io); |
517 | if (i == CS_SUCCESS) break; | 508 | if (i == CS_SUCCESS) break; |
518 | } | 509 | } |
519 | if (i == CS_SUCCESS) break; | 510 | if (i == CS_SUCCESS) break; |
520 | i = next_tuple(link->handle, tuple, parse); | 511 | i = next_tuple(link, tuple, parse); |
521 | } | 512 | } |
522 | if (i != CS_SUCCESS) | 513 | if (i != CS_SUCCESS) |
523 | goto free_cfg_mem; | 514 | goto free_cfg_mem; |
@@ -527,7 +518,7 @@ static int mhz_mfc_config(dev_link_t *link) | |||
527 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; | 518 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; |
528 | req.Base = req.Size = 0; | 519 | req.Base = req.Size = 0; |
529 | req.AccessSpeed = 0; | 520 | req.AccessSpeed = 0; |
530 | i = pcmcia_request_window(&link->handle, &req, &link->win); | 521 | i = pcmcia_request_window(&link, &req, &link->win); |
531 | if (i != CS_SUCCESS) | 522 | if (i != CS_SUCCESS) |
532 | goto free_cfg_mem; | 523 | goto free_cfg_mem; |
533 | smc->base = ioremap(req.Base, req.Size); | 524 | smc->base = ioremap(req.Base, req.Size); |
@@ -546,9 +537,8 @@ free_cfg_mem: | |||
546 | return i; | 537 | return i; |
547 | } | 538 | } |
548 | 539 | ||
549 | static int mhz_setup(dev_link_t *link) | 540 | static int mhz_setup(struct pcmcia_device *link) |
550 | { | 541 | { |
551 | client_handle_t handle = link->handle; | ||
552 | struct net_device *dev = link->priv; | 542 | struct net_device *dev = link->priv; |
553 | struct smc_cfg_mem *cfg_mem; | 543 | struct smc_cfg_mem *cfg_mem; |
554 | tuple_t *tuple; | 544 | tuple_t *tuple; |
@@ -571,13 +561,13 @@ static int mhz_setup(dev_link_t *link) | |||
571 | /* Read the station address from the CIS. It is stored as the last | 561 | /* Read the station address from the CIS. It is stored as the last |
572 | (fourth) string in the Version 1 Version/ID tuple. */ | 562 | (fourth) string in the Version 1 Version/ID tuple. */ |
573 | tuple->DesiredTuple = CISTPL_VERS_1; | 563 | tuple->DesiredTuple = CISTPL_VERS_1; |
574 | if (first_tuple(handle, tuple, parse) != CS_SUCCESS) { | 564 | if (first_tuple(link, tuple, parse) != CS_SUCCESS) { |
575 | rc = -1; | 565 | rc = -1; |
576 | goto free_cfg_mem; | 566 | goto free_cfg_mem; |
577 | } | 567 | } |
578 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ | 568 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ |
579 | if (next_tuple(handle, tuple, parse) != CS_SUCCESS) | 569 | if (next_tuple(link, tuple, parse) != CS_SUCCESS) |
580 | first_tuple(handle, tuple, parse); | 570 | first_tuple(link, tuple, parse); |
581 | if (parse->version_1.ns > 3) { | 571 | if (parse->version_1.ns > 3) { |
582 | station_addr = parse->version_1.str + parse->version_1.ofs[3]; | 572 | station_addr = parse->version_1.str + parse->version_1.ofs[3]; |
583 | if (cvt_ascii_address(dev, station_addr) == 0) { | 573 | if (cvt_ascii_address(dev, station_addr) == 0) { |
@@ -588,11 +578,11 @@ static int mhz_setup(dev_link_t *link) | |||
588 | 578 | ||
589 | /* Another possibility: for the EM3288, in a special tuple */ | 579 | /* Another possibility: for the EM3288, in a special tuple */ |
590 | tuple->DesiredTuple = 0x81; | 580 | tuple->DesiredTuple = 0x81; |
591 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) { | 581 | if (pcmcia_get_first_tuple(link, tuple) != CS_SUCCESS) { |
592 | rc = -1; | 582 | rc = -1; |
593 | goto free_cfg_mem; | 583 | goto free_cfg_mem; |
594 | } | 584 | } |
595 | if (pcmcia_get_tuple_data(handle, tuple) != CS_SUCCESS) { | 585 | if (pcmcia_get_tuple_data(link, tuple) != CS_SUCCESS) { |
596 | rc = -1; | 586 | rc = -1; |
597 | goto free_cfg_mem; | 587 | goto free_cfg_mem; |
598 | } | 588 | } |
@@ -616,7 +606,7 @@ free_cfg_mem: | |||
616 | 606 | ||
617 | ======================================================================*/ | 607 | ======================================================================*/ |
618 | 608 | ||
619 | static void mot_config(dev_link_t *link) | 609 | static void mot_config(struct pcmcia_device *link) |
620 | { | 610 | { |
621 | struct net_device *dev = link->priv; | 611 | struct net_device *dev = link->priv; |
622 | struct smc_private *smc = netdev_priv(dev); | 612 | struct smc_private *smc = netdev_priv(dev); |
@@ -637,7 +627,7 @@ static void mot_config(dev_link_t *link) | |||
637 | mdelay(100); | 627 | mdelay(100); |
638 | } | 628 | } |
639 | 629 | ||
640 | static int mot_setup(dev_link_t *link) | 630 | static int mot_setup(struct pcmcia_device *link) |
641 | { | 631 | { |
642 | struct net_device *dev = link->priv; | 632 | struct net_device *dev = link->priv; |
643 | kio_addr_t ioaddr = dev->base_addr; | 633 | kio_addr_t ioaddr = dev->base_addr; |
@@ -671,7 +661,7 @@ static int mot_setup(dev_link_t *link) | |||
671 | 661 | ||
672 | /*====================================================================*/ | 662 | /*====================================================================*/ |
673 | 663 | ||
674 | static int smc_config(dev_link_t *link) | 664 | static int smc_config(struct pcmcia_device *link) |
675 | { | 665 | { |
676 | struct net_device *dev = link->priv; | 666 | struct net_device *dev = link->priv; |
677 | struct smc_cfg_mem *cfg_mem; | 667 | struct smc_cfg_mem *cfg_mem; |
@@ -696,16 +686,16 @@ static int smc_config(dev_link_t *link) | |||
696 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | 686 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; |
697 | 687 | ||
698 | link->io.NumPorts1 = 16; | 688 | link->io.NumPorts1 = 16; |
699 | i = first_tuple(link->handle, tuple, parse); | 689 | i = first_tuple(link, tuple, parse); |
700 | while (i != CS_NO_MORE_ITEMS) { | 690 | while (i != CS_NO_MORE_ITEMS) { |
701 | if (i == CS_SUCCESS) { | 691 | if (i == CS_SUCCESS) { |
702 | link->conf.ConfigIndex = cf->index; | 692 | link->conf.ConfigIndex = cf->index; |
703 | link->io.BasePort1 = cf->io.win[0].base; | 693 | link->io.BasePort1 = cf->io.win[0].base; |
704 | link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | 694 | link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; |
705 | i = pcmcia_request_io(link->handle, &link->io); | 695 | i = pcmcia_request_io(link, &link->io); |
706 | if (i == CS_SUCCESS) break; | 696 | if (i == CS_SUCCESS) break; |
707 | } | 697 | } |
708 | i = next_tuple(link->handle, tuple, parse); | 698 | i = next_tuple(link, tuple, parse); |
709 | } | 699 | } |
710 | if (i == CS_SUCCESS) | 700 | if (i == CS_SUCCESS) |
711 | dev->base_addr = link->io.BasePort1; | 701 | dev->base_addr = link->io.BasePort1; |
@@ -714,9 +704,8 @@ static int smc_config(dev_link_t *link) | |||
714 | return i; | 704 | return i; |
715 | } | 705 | } |
716 | 706 | ||
717 | static int smc_setup(dev_link_t *link) | 707 | static int smc_setup(struct pcmcia_device *link) |
718 | { | 708 | { |
719 | client_handle_t handle = link->handle; | ||
720 | struct net_device *dev = link->priv; | 709 | struct net_device *dev = link->priv; |
721 | struct smc_cfg_mem *cfg_mem; | 710 | struct smc_cfg_mem *cfg_mem; |
722 | tuple_t *tuple; | 711 | tuple_t *tuple; |
@@ -739,11 +728,11 @@ static int smc_setup(dev_link_t *link) | |||
739 | 728 | ||
740 | /* Check for a LAN function extension tuple */ | 729 | /* Check for a LAN function extension tuple */ |
741 | tuple->DesiredTuple = CISTPL_FUNCE; | 730 | tuple->DesiredTuple = CISTPL_FUNCE; |
742 | i = first_tuple(handle, tuple, parse); | 731 | i = first_tuple(link, tuple, parse); |
743 | while (i == CS_SUCCESS) { | 732 | while (i == CS_SUCCESS) { |
744 | if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) | 733 | if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) |
745 | break; | 734 | break; |
746 | i = next_tuple(handle, tuple, parse); | 735 | i = next_tuple(link, tuple, parse); |
747 | } | 736 | } |
748 | if (i == CS_SUCCESS) { | 737 | if (i == CS_SUCCESS) { |
749 | node_id = (cistpl_lan_node_id_t *)parse->funce.data; | 738 | node_id = (cistpl_lan_node_id_t *)parse->funce.data; |
@@ -756,7 +745,7 @@ static int smc_setup(dev_link_t *link) | |||
756 | } | 745 | } |
757 | /* Try the third string in the Version 1 Version/ID tuple. */ | 746 | /* Try the third string in the Version 1 Version/ID tuple. */ |
758 | tuple->DesiredTuple = CISTPL_VERS_1; | 747 | tuple->DesiredTuple = CISTPL_VERS_1; |
759 | if (first_tuple(handle, tuple, parse) != CS_SUCCESS) { | 748 | if (first_tuple(link, tuple, parse) != CS_SUCCESS) { |
760 | rc = -1; | 749 | rc = -1; |
761 | goto free_cfg_mem; | 750 | goto free_cfg_mem; |
762 | } | 751 | } |
@@ -774,7 +763,7 @@ free_cfg_mem: | |||
774 | 763 | ||
775 | /*====================================================================*/ | 764 | /*====================================================================*/ |
776 | 765 | ||
777 | static int osi_config(dev_link_t *link) | 766 | static int osi_config(struct pcmcia_device *link) |
778 | { | 767 | { |
779 | struct net_device *dev = link->priv; | 768 | struct net_device *dev = link->priv; |
780 | static const kio_addr_t com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; | 769 | static const kio_addr_t com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; |
@@ -794,22 +783,21 @@ static int osi_config(dev_link_t *link) | |||
794 | 783 | ||
795 | for (i = j = 0; j < 4; j++) { | 784 | for (i = j = 0; j < 4; j++) { |
796 | link->io.BasePort2 = com[j]; | 785 | link->io.BasePort2 = com[j]; |
797 | i = pcmcia_request_io(link->handle, &link->io); | 786 | i = pcmcia_request_io(link, &link->io); |
798 | if (i == CS_SUCCESS) break; | 787 | if (i == CS_SUCCESS) break; |
799 | } | 788 | } |
800 | if (i != CS_SUCCESS) { | 789 | if (i != CS_SUCCESS) { |
801 | /* Fallback: turn off hard decode */ | 790 | /* Fallback: turn off hard decode */ |
802 | link->conf.ConfigIndex = 0x03; | 791 | link->conf.ConfigIndex = 0x03; |
803 | link->io.NumPorts2 = 0; | 792 | link->io.NumPorts2 = 0; |
804 | i = pcmcia_request_io(link->handle, &link->io); | 793 | i = pcmcia_request_io(link, &link->io); |
805 | } | 794 | } |
806 | dev->base_addr = link->io.BasePort1 + 0x10; | 795 | dev->base_addr = link->io.BasePort1 + 0x10; |
807 | return i; | 796 | return i; |
808 | } | 797 | } |
809 | 798 | ||
810 | static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid) | 799 | static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid) |
811 | { | 800 | { |
812 | client_handle_t handle = link->handle; | ||
813 | struct net_device *dev = link->priv; | 801 | struct net_device *dev = link->priv; |
814 | struct smc_cfg_mem *cfg_mem; | 802 | struct smc_cfg_mem *cfg_mem; |
815 | tuple_t *tuple; | 803 | tuple_t *tuple; |
@@ -830,12 +818,12 @@ static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid) | |||
830 | 818 | ||
831 | /* Read the station address from tuple 0x90, subtuple 0x04 */ | 819 | /* Read the station address from tuple 0x90, subtuple 0x04 */ |
832 | tuple->DesiredTuple = 0x90; | 820 | tuple->DesiredTuple = 0x90; |
833 | i = pcmcia_get_first_tuple(handle, tuple); | 821 | i = pcmcia_get_first_tuple(link, tuple); |
834 | while (i == CS_SUCCESS) { | 822 | while (i == CS_SUCCESS) { |
835 | i = pcmcia_get_tuple_data(handle, tuple); | 823 | i = pcmcia_get_tuple_data(link, tuple); |
836 | if ((i != CS_SUCCESS) || (buf[0] == 0x04)) | 824 | if ((i != CS_SUCCESS) || (buf[0] == 0x04)) |
837 | break; | 825 | break; |
838 | i = pcmcia_get_next_tuple(handle, tuple); | 826 | i = pcmcia_get_next_tuple(link, tuple); |
839 | } | 827 | } |
840 | if (i != CS_SUCCESS) { | 828 | if (i != CS_SUCCESS) { |
841 | rc = -1; | 829 | rc = -1; |
@@ -868,57 +856,47 @@ free_cfg_mem: | |||
868 | return rc; | 856 | return rc; |
869 | } | 857 | } |
870 | 858 | ||
871 | static int smc91c92_suspend(struct pcmcia_device *p_dev) | 859 | static int smc91c92_suspend(struct pcmcia_device *link) |
872 | { | 860 | { |
873 | dev_link_t *link = dev_to_instance(p_dev); | ||
874 | struct net_device *dev = link->priv; | 861 | struct net_device *dev = link->priv; |
875 | 862 | ||
876 | link->state |= DEV_SUSPEND; | 863 | if (link->open) |
877 | if (link->state & DEV_CONFIG) { | 864 | netif_device_detach(dev); |
878 | if (link->open) | ||
879 | netif_device_detach(dev); | ||
880 | pcmcia_release_configuration(link->handle); | ||
881 | } | ||
882 | 865 | ||
883 | return 0; | 866 | return 0; |
884 | } | 867 | } |
885 | 868 | ||
886 | static int smc91c92_resume(struct pcmcia_device *p_dev) | 869 | static int smc91c92_resume(struct pcmcia_device *link) |
887 | { | 870 | { |
888 | dev_link_t *link = dev_to_instance(p_dev); | ||
889 | struct net_device *dev = link->priv; | 871 | struct net_device *dev = link->priv; |
890 | struct smc_private *smc = netdev_priv(dev); | 872 | struct smc_private *smc = netdev_priv(dev); |
891 | int i; | 873 | int i; |
892 | 874 | ||
893 | link->state &= ~DEV_SUSPEND; | 875 | if ((smc->manfid == MANFID_MEGAHERTZ) && |
894 | if (link->state & DEV_CONFIG) { | 876 | (smc->cardid == PRODID_MEGAHERTZ_EM3288)) |
895 | if ((smc->manfid == MANFID_MEGAHERTZ) && | 877 | mhz_3288_power(link); |
896 | (smc->cardid == PRODID_MEGAHERTZ_EM3288)) | 878 | if (smc->manfid == MANFID_MOTOROLA) |
897 | mhz_3288_power(link); | 879 | mot_config(link); |
898 | pcmcia_request_configuration(link->handle, &link->conf); | 880 | if ((smc->manfid == MANFID_OSITECH) && |
899 | if (smc->manfid == MANFID_MOTOROLA) | 881 | (smc->cardid != PRODID_OSITECH_SEVEN)) { |
900 | mot_config(link); | 882 | /* Power up the card and enable interrupts */ |
901 | if ((smc->manfid == MANFID_OSITECH) && | 883 | set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); |
902 | (smc->cardid != PRODID_OSITECH_SEVEN)) { | 884 | set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); |
903 | /* Power up the card and enable interrupts */ | 885 | } |
904 | set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); | 886 | if (((smc->manfid == MANFID_OSITECH) && |
905 | set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); | 887 | (smc->cardid == PRODID_OSITECH_SEVEN)) || |
906 | } | 888 | ((smc->manfid == MANFID_PSION) && |
907 | if (((smc->manfid == MANFID_OSITECH) && | 889 | (smc->cardid == PRODID_PSION_NET100))) { |
908 | (smc->cardid == PRODID_OSITECH_SEVEN)) || | 890 | /* Download the Seven of Diamonds firmware */ |
909 | ((smc->manfid == MANFID_PSION) && | 891 | for (i = 0; i < sizeof(__Xilinx7OD); i++) { |
910 | (smc->cardid == PRODID_PSION_NET100))) { | 892 | outb(__Xilinx7OD[i], link->io.BasePort1+2); |
911 | /* Download the Seven of Diamonds firmware */ | 893 | udelay(50); |
912 | for (i = 0; i < sizeof(__Xilinx7OD); i++) { | ||
913 | outb(__Xilinx7OD[i], link->io.BasePort1+2); | ||
914 | udelay(50); | ||
915 | } | ||
916 | } | ||
917 | if (link->open) { | ||
918 | smc_reset(dev); | ||
919 | netif_device_attach(dev); | ||
920 | } | 894 | } |
921 | } | 895 | } |
896 | if (link->open) { | ||
897 | smc_reset(dev); | ||
898 | netif_device_attach(dev); | ||
899 | } | ||
922 | 900 | ||
923 | return 0; | 901 | return 0; |
924 | } | 902 | } |
@@ -931,7 +909,7 @@ static int smc91c92_resume(struct pcmcia_device *p_dev) | |||
931 | 909 | ||
932 | ======================================================================*/ | 910 | ======================================================================*/ |
933 | 911 | ||
934 | static int check_sig(dev_link_t *link) | 912 | static int check_sig(struct pcmcia_device *link) |
935 | { | 913 | { |
936 | struct net_device *dev = link->priv; | 914 | struct net_device *dev = link->priv; |
937 | kio_addr_t ioaddr = dev->base_addr; | 915 | kio_addr_t ioaddr = dev->base_addr; |
@@ -964,13 +942,15 @@ static int check_sig(dev_link_t *link) | |||
964 | } | 942 | } |
965 | 943 | ||
966 | if (width) { | 944 | if (width) { |
967 | printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); | 945 | modconf_t mod = { |
968 | smc91c92_suspend(link->handle); | 946 | .Attributes = CONF_IO_CHANGE_WIDTH, |
969 | pcmcia_release_io(link->handle, &link->io); | 947 | }; |
970 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 948 | printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); |
971 | pcmcia_request_io(link->handle, &link->io); | 949 | |
972 | smc91c92_resume(link->handle); | 950 | smc91c92_suspend(link); |
973 | return check_sig(link); | 951 | pcmcia_modify_configuration(link, &mod); |
952 | smc91c92_resume(link); | ||
953 | return check_sig(link); | ||
974 | } | 954 | } |
975 | return -ENODEV; | 955 | return -ENODEV; |
976 | } | 956 | } |
@@ -984,11 +964,10 @@ static int check_sig(dev_link_t *link) | |||
984 | ======================================================================*/ | 964 | ======================================================================*/ |
985 | 965 | ||
986 | #define CS_EXIT_TEST(ret, svc, label) \ | 966 | #define CS_EXIT_TEST(ret, svc, label) \ |
987 | if (ret != CS_SUCCESS) { cs_error(link->handle, svc, ret); goto label; } | 967 | if (ret != CS_SUCCESS) { cs_error(link, svc, ret); goto label; } |
988 | 968 | ||
989 | static void smc91c92_config(dev_link_t *link) | 969 | static int smc91c92_config(struct pcmcia_device *link) |
990 | { | 970 | { |
991 | client_handle_t handle = link->handle; | ||
992 | struct net_device *dev = link->priv; | 971 | struct net_device *dev = link->priv; |
993 | struct smc_private *smc = netdev_priv(dev); | 972 | struct smc_private *smc = netdev_priv(dev); |
994 | struct smc_cfg_mem *cfg_mem; | 973 | struct smc_cfg_mem *cfg_mem; |
@@ -1015,21 +994,18 @@ static void smc91c92_config(dev_link_t *link) | |||
1015 | tuple->TupleDataMax = 64; | 994 | tuple->TupleDataMax = 64; |
1016 | 995 | ||
1017 | tuple->DesiredTuple = CISTPL_CONFIG; | 996 | tuple->DesiredTuple = CISTPL_CONFIG; |
1018 | i = first_tuple(handle, tuple, parse); | 997 | i = first_tuple(link, tuple, parse); |
1019 | CS_EXIT_TEST(i, ParseTuple, config_failed); | 998 | CS_EXIT_TEST(i, ParseTuple, config_failed); |
1020 | link->conf.ConfigBase = parse->config.base; | 999 | link->conf.ConfigBase = parse->config.base; |
1021 | link->conf.Present = parse->config.rmask[0]; | 1000 | link->conf.Present = parse->config.rmask[0]; |
1022 | 1001 | ||
1023 | tuple->DesiredTuple = CISTPL_MANFID; | 1002 | tuple->DesiredTuple = CISTPL_MANFID; |
1024 | tuple->Attributes = TUPLE_RETURN_COMMON; | 1003 | tuple->Attributes = TUPLE_RETURN_COMMON; |
1025 | if (first_tuple(handle, tuple, parse) == CS_SUCCESS) { | 1004 | if (first_tuple(link, tuple, parse) == CS_SUCCESS) { |
1026 | smc->manfid = parse->manfid.manf; | 1005 | smc->manfid = parse->manfid.manf; |
1027 | smc->cardid = parse->manfid.card; | 1006 | smc->cardid = parse->manfid.card; |
1028 | } | 1007 | } |
1029 | 1008 | ||
1030 | /* Configure card */ | ||
1031 | link->state |= DEV_CONFIG; | ||
1032 | |||
1033 | if ((smc->manfid == MANFID_OSITECH) && | 1009 | if ((smc->manfid == MANFID_OSITECH) && |
1034 | (smc->cardid != PRODID_OSITECH_SEVEN)) { | 1010 | (smc->cardid != PRODID_OSITECH_SEVEN)) { |
1035 | i = osi_config(link); | 1011 | i = osi_config(link); |
@@ -1043,9 +1019,9 @@ static void smc91c92_config(dev_link_t *link) | |||
1043 | } | 1019 | } |
1044 | CS_EXIT_TEST(i, RequestIO, config_failed); | 1020 | CS_EXIT_TEST(i, RequestIO, config_failed); |
1045 | 1021 | ||
1046 | i = pcmcia_request_irq(link->handle, &link->irq); | 1022 | i = pcmcia_request_irq(link, &link->irq); |
1047 | CS_EXIT_TEST(i, RequestIRQ, config_failed); | 1023 | CS_EXIT_TEST(i, RequestIRQ, config_failed); |
1048 | i = pcmcia_request_configuration(link->handle, &link->conf); | 1024 | i = pcmcia_request_configuration(link, &link->conf); |
1049 | CS_EXIT_TEST(i, RequestConfiguration, config_failed); | 1025 | CS_EXIT_TEST(i, RequestConfiguration, config_failed); |
1050 | 1026 | ||
1051 | if (smc->manfid == MANFID_MOTOROLA) | 1027 | if (smc->manfid == MANFID_MOTOROLA) |
@@ -1124,13 +1100,12 @@ static void smc91c92_config(dev_link_t *link) | |||
1124 | SMC_SELECT_BANK(0); | 1100 | SMC_SELECT_BANK(0); |
1125 | } | 1101 | } |
1126 | 1102 | ||
1127 | link->dev = &smc->node; | 1103 | link->dev_node = &smc->node; |
1128 | link->state &= ~DEV_CONFIG_PENDING; | 1104 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
1129 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | ||
1130 | 1105 | ||
1131 | if (register_netdev(dev) != 0) { | 1106 | if (register_netdev(dev) != 0) { |
1132 | printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n"); | 1107 | printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n"); |
1133 | link->dev = NULL; | 1108 | link->dev_node = NULL; |
1134 | goto config_undo; | 1109 | goto config_undo; |
1135 | } | 1110 | } |
1136 | 1111 | ||
@@ -1160,15 +1135,14 @@ static void smc91c92_config(dev_link_t *link) | |||
1160 | } | 1135 | } |
1161 | } | 1136 | } |
1162 | kfree(cfg_mem); | 1137 | kfree(cfg_mem); |
1163 | return; | 1138 | return 0; |
1164 | 1139 | ||
1165 | config_undo: | 1140 | config_undo: |
1166 | unregister_netdev(dev); | 1141 | unregister_netdev(dev); |
1167 | config_failed: /* CS_EXIT_TEST() calls jump to here... */ | 1142 | config_failed: /* CS_EXIT_TEST() calls jump to here... */ |
1168 | smc91c92_release(link); | 1143 | smc91c92_release(link); |
1169 | link->state &= ~DEV_CONFIG_PENDING; | ||
1170 | kfree(cfg_mem); | 1144 | kfree(cfg_mem); |
1171 | 1145 | return -ENODEV; | |
1172 | } /* smc91c92_config */ | 1146 | } /* smc91c92_config */ |
1173 | 1147 | ||
1174 | /*====================================================================== | 1148 | /*====================================================================== |
@@ -1179,22 +1153,15 @@ config_failed: /* CS_EXIT_TEST() calls jump to here... */ | |||
1179 | 1153 | ||
1180 | ======================================================================*/ | 1154 | ======================================================================*/ |
1181 | 1155 | ||
1182 | static void smc91c92_release(dev_link_t *link) | 1156 | static void smc91c92_release(struct pcmcia_device *link) |
1183 | { | 1157 | { |
1184 | 1158 | DEBUG(0, "smc91c92_release(0x%p)\n", link); | |
1185 | DEBUG(0, "smc91c92_release(0x%p)\n", link); | 1159 | if (link->win) { |
1186 | 1160 | struct net_device *dev = link->priv; | |
1187 | pcmcia_release_configuration(link->handle); | 1161 | struct smc_private *smc = netdev_priv(dev); |
1188 | pcmcia_release_io(link->handle, &link->io); | 1162 | iounmap(smc->base); |
1189 | pcmcia_release_irq(link->handle, &link->irq); | 1163 | } |
1190 | if (link->win) { | 1164 | pcmcia_disable_device(link); |
1191 | struct net_device *dev = link->priv; | ||
1192 | struct smc_private *smc = netdev_priv(dev); | ||
1193 | iounmap(smc->base); | ||
1194 | pcmcia_release_window(link->win); | ||
1195 | } | ||
1196 | |||
1197 | link->state &= ~DEV_CONFIG; | ||
1198 | } | 1165 | } |
1199 | 1166 | ||
1200 | /*====================================================================== | 1167 | /*====================================================================== |
@@ -1283,7 +1250,7 @@ static void smc_dump(struct net_device *dev) | |||
1283 | static int smc_open(struct net_device *dev) | 1250 | static int smc_open(struct net_device *dev) |
1284 | { | 1251 | { |
1285 | struct smc_private *smc = netdev_priv(dev); | 1252 | struct smc_private *smc = netdev_priv(dev); |
1286 | dev_link_t *link = &smc->link; | 1253 | struct pcmcia_device *link = smc->p_dev; |
1287 | 1254 | ||
1288 | #ifdef PCMCIA_DEBUG | 1255 | #ifdef PCMCIA_DEBUG |
1289 | DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n", | 1256 | DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n", |
@@ -1292,7 +1259,7 @@ static int smc_open(struct net_device *dev) | |||
1292 | #endif | 1259 | #endif |
1293 | 1260 | ||
1294 | /* Check that the PCMCIA card is still here. */ | 1261 | /* Check that the PCMCIA card is still here. */ |
1295 | if (!DEV_OK(link)) | 1262 | if (!pcmcia_dev_present(link)) |
1296 | return -ENODEV; | 1263 | return -ENODEV; |
1297 | /* Physical device present signature. */ | 1264 | /* Physical device present signature. */ |
1298 | if (check_sig(link) < 0) { | 1265 | if (check_sig(link) < 0) { |
@@ -1320,7 +1287,7 @@ static int smc_open(struct net_device *dev) | |||
1320 | static int smc_close(struct net_device *dev) | 1287 | static int smc_close(struct net_device *dev) |
1321 | { | 1288 | { |
1322 | struct smc_private *smc = netdev_priv(dev); | 1289 | struct smc_private *smc = netdev_priv(dev); |
1323 | dev_link_t *link = &smc->link; | 1290 | struct pcmcia_device *link = smc->p_dev; |
1324 | kio_addr_t ioaddr = dev->base_addr; | 1291 | kio_addr_t ioaddr = dev->base_addr; |
1325 | 1292 | ||
1326 | DEBUG(0, "%s: smc_close(), status %4.4x.\n", | 1293 | DEBUG(0, "%s: smc_close(), status %4.4x.\n", |
@@ -2311,7 +2278,7 @@ static struct pcmcia_driver smc91c92_cs_driver = { | |||
2311 | .drv = { | 2278 | .drv = { |
2312 | .name = "smc91c92_cs", | 2279 | .name = "smc91c92_cs", |
2313 | }, | 2280 | }, |
2314 | .probe = smc91c92_attach, | 2281 | .probe = smc91c92_probe, |
2315 | .remove = smc91c92_detach, | 2282 | .remove = smc91c92_detach, |
2316 | .id_table = smc91c92_ids, | 2283 | .id_table = smc91c92_ids, |
2317 | .suspend = smc91c92_suspend, | 2284 | .suspend = smc91c92_suspend, |