diff options
Diffstat (limited to 'drivers/net/pcmcia/nmclan_cs.c')
-rw-r--r-- | drivers/net/pcmcia/nmclan_cs.c | 126 |
1 files changed, 46 insertions, 80 deletions
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index 787176c57fd9..4260c2128f47 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c | |||
@@ -362,7 +362,7 @@ typedef struct _mace_statistics { | |||
362 | } mace_statistics; | 362 | } mace_statistics; |
363 | 363 | ||
364 | typedef struct _mace_private { | 364 | typedef struct _mace_private { |
365 | dev_link_t link; | 365 | struct pcmcia_device *p_dev; |
366 | dev_node_t node; | 366 | dev_node_t node; |
367 | struct net_device_stats linux_stats; /* Linux statistics counters */ | 367 | struct net_device_stats linux_stats; /* Linux statistics counters */ |
368 | mace_statistics mace_stats; /* MACE chip statistics counters */ | 368 | mace_statistics mace_stats; /* MACE chip statistics counters */ |
@@ -417,8 +417,8 @@ INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); | |||
417 | Function Prototypes | 417 | Function Prototypes |
418 | ---------------------------------------------------------------------------- */ | 418 | ---------------------------------------------------------------------------- */ |
419 | 419 | ||
420 | static void nmclan_config(dev_link_t *link); | 420 | static int nmclan_config(struct pcmcia_device *link); |
421 | static void nmclan_release(dev_link_t *link); | 421 | static void nmclan_release(struct pcmcia_device *link); |
422 | 422 | ||
423 | static void nmclan_reset(struct net_device *dev); | 423 | static void nmclan_reset(struct net_device *dev); |
424 | static int mace_config(struct net_device *dev, struct ifmap *map); | 424 | static int mace_config(struct net_device *dev, struct ifmap *map); |
@@ -443,10 +443,9 @@ nmclan_attach | |||
443 | Services. | 443 | Services. |
444 | ---------------------------------------------------------------------------- */ | 444 | ---------------------------------------------------------------------------- */ |
445 | 445 | ||
446 | static int nmclan_attach(struct pcmcia_device *p_dev) | 446 | static int nmclan_probe(struct pcmcia_device *link) |
447 | { | 447 | { |
448 | mace_private *lp; | 448 | mace_private *lp; |
449 | dev_link_t *link; | ||
450 | struct net_device *dev; | 449 | struct net_device *dev; |
451 | 450 | ||
452 | DEBUG(0, "nmclan_attach()\n"); | 451 | DEBUG(0, "nmclan_attach()\n"); |
@@ -457,7 +456,7 @@ static int nmclan_attach(struct pcmcia_device *p_dev) | |||
457 | if (!dev) | 456 | if (!dev) |
458 | return -ENOMEM; | 457 | return -ENOMEM; |
459 | lp = netdev_priv(dev); | 458 | lp = netdev_priv(dev); |
460 | link = &lp->link; | 459 | lp->p_dev = link; |
461 | link->priv = dev; | 460 | link->priv = dev; |
462 | 461 | ||
463 | spin_lock_init(&lp->bank_lock); | 462 | spin_lock_init(&lp->bank_lock); |
@@ -469,7 +468,6 @@ static int nmclan_attach(struct pcmcia_device *p_dev) | |||
469 | link->irq.Handler = &mace_interrupt; | 468 | link->irq.Handler = &mace_interrupt; |
470 | link->irq.Instance = dev; | 469 | link->irq.Instance = dev; |
471 | link->conf.Attributes = CONF_ENABLE_IRQ; | 470 | link->conf.Attributes = CONF_ENABLE_IRQ; |
472 | link->conf.Vcc = 50; | ||
473 | link->conf.IntType = INT_MEMORY_AND_IO; | 471 | link->conf.IntType = INT_MEMORY_AND_IO; |
474 | link->conf.ConfigIndex = 1; | 472 | link->conf.ConfigIndex = 1; |
475 | link->conf.Present = PRESENT_OPTION; | 473 | link->conf.Present = PRESENT_OPTION; |
@@ -489,13 +487,7 @@ static int nmclan_attach(struct pcmcia_device *p_dev) | |||
489 | dev->watchdog_timeo = TX_TIMEOUT; | 487 | dev->watchdog_timeo = TX_TIMEOUT; |
490 | #endif | 488 | #endif |
491 | 489 | ||
492 | link->handle = p_dev; | 490 | return nmclan_config(link); |
493 | p_dev->instance = link; | ||
494 | |||
495 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
496 | nmclan_config(link); | ||
497 | |||
498 | return 0; | ||
499 | } /* nmclan_attach */ | 491 | } /* nmclan_attach */ |
500 | 492 | ||
501 | /* ---------------------------------------------------------------------------- | 493 | /* ---------------------------------------------------------------------------- |
@@ -506,18 +498,16 @@ nmclan_detach | |||
506 | when the device is released. | 498 | when the device is released. |
507 | ---------------------------------------------------------------------------- */ | 499 | ---------------------------------------------------------------------------- */ |
508 | 500 | ||
509 | static void nmclan_detach(struct pcmcia_device *p_dev) | 501 | static void nmclan_detach(struct pcmcia_device *link) |
510 | { | 502 | { |
511 | dev_link_t *link = dev_to_instance(p_dev); | ||
512 | struct net_device *dev = link->priv; | 503 | struct net_device *dev = link->priv; |
513 | 504 | ||
514 | DEBUG(0, "nmclan_detach(0x%p)\n", link); | 505 | DEBUG(0, "nmclan_detach(0x%p)\n", link); |
515 | 506 | ||
516 | if (link->dev) | 507 | if (link->dev_node) |
517 | unregister_netdev(dev); | 508 | unregister_netdev(dev); |
518 | 509 | ||
519 | if (link->state & DEV_CONFIG) | 510 | nmclan_release(link); |
520 | nmclan_release(link); | ||
521 | 511 | ||
522 | free_netdev(dev); | 512 | free_netdev(dev); |
523 | } /* nmclan_detach */ | 513 | } /* nmclan_detach */ |
@@ -661,9 +651,8 @@ nmclan_config | |||
661 | #define CS_CHECK(fn, ret) \ | 651 | #define CS_CHECK(fn, ret) \ |
662 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 652 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
663 | 653 | ||
664 | static void nmclan_config(dev_link_t *link) | 654 | static int nmclan_config(struct pcmcia_device *link) |
665 | { | 655 | { |
666 | client_handle_t handle = link->handle; | ||
667 | struct net_device *dev = link->priv; | 656 | struct net_device *dev = link->priv; |
668 | mace_private *lp = netdev_priv(dev); | 657 | mace_private *lp = netdev_priv(dev); |
669 | tuple_t tuple; | 658 | tuple_t tuple; |
@@ -679,17 +668,14 @@ static void nmclan_config(dev_link_t *link) | |||
679 | tuple.TupleDataMax = 64; | 668 | tuple.TupleDataMax = 64; |
680 | tuple.TupleOffset = 0; | 669 | tuple.TupleOffset = 0; |
681 | tuple.DesiredTuple = CISTPL_CONFIG; | 670 | tuple.DesiredTuple = CISTPL_CONFIG; |
682 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 671 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
683 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 672 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
684 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 673 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
685 | link->conf.ConfigBase = parse.config.base; | 674 | link->conf.ConfigBase = parse.config.base; |
686 | 675 | ||
687 | /* Configure card */ | 676 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); |
688 | link->state |= DEV_CONFIG; | 677 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
689 | 678 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | |
690 | CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io)); | ||
691 | CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); | ||
692 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); | ||
693 | dev->irq = link->irq.AssignedIRQ; | 679 | dev->irq = link->irq.AssignedIRQ; |
694 | dev->base_addr = link->io.BasePort1; | 680 | dev->base_addr = link->io.BasePort1; |
695 | 681 | ||
@@ -700,8 +686,8 @@ static void nmclan_config(dev_link_t *link) | |||
700 | tuple.TupleData = buf; | 686 | tuple.TupleData = buf; |
701 | tuple.TupleDataMax = 64; | 687 | tuple.TupleDataMax = 64; |
702 | tuple.TupleOffset = 0; | 688 | tuple.TupleOffset = 0; |
703 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 689 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
704 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 690 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
705 | memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN); | 691 | memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN); |
706 | 692 | ||
707 | /* Verify configuration by reading the MACE ID. */ | 693 | /* Verify configuration by reading the MACE ID. */ |
@@ -716,8 +702,7 @@ static void nmclan_config(dev_link_t *link) | |||
716 | } else { | 702 | } else { |
717 | printk(KERN_NOTICE "nmclan_cs: mace id not found: %x %x should" | 703 | printk(KERN_NOTICE "nmclan_cs: mace id not found: %x %x should" |
718 | " be 0x40 0x?9\n", sig[0], sig[1]); | 704 | " be 0x40 0x?9\n", sig[0], sig[1]); |
719 | link->state &= ~DEV_CONFIG_PENDING; | 705 | return -ENODEV; |
720 | return; | ||
721 | } | 706 | } |
722 | } | 707 | } |
723 | 708 | ||
@@ -730,14 +715,13 @@ static void nmclan_config(dev_link_t *link) | |||
730 | else | 715 | else |
731 | printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n"); | 716 | printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n"); |
732 | 717 | ||
733 | link->dev = &lp->node; | 718 | link->dev_node = &lp->node; |
734 | link->state &= ~DEV_CONFIG_PENDING; | 719 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
735 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | ||
736 | 720 | ||
737 | i = register_netdev(dev); | 721 | i = register_netdev(dev); |
738 | if (i != 0) { | 722 | if (i != 0) { |
739 | printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n"); | 723 | printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n"); |
740 | link->dev = NULL; | 724 | link->dev_node = NULL; |
741 | goto failed; | 725 | goto failed; |
742 | } | 726 | } |
743 | 727 | ||
@@ -747,14 +731,13 @@ static void nmclan_config(dev_link_t *link) | |||
747 | dev->name, dev->base_addr, dev->irq, if_names[dev->if_port]); | 731 | dev->name, dev->base_addr, dev->irq, if_names[dev->if_port]); |
748 | for (i = 0; i < 6; i++) | 732 | for (i = 0; i < 6; i++) |
749 | printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); | 733 | printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); |
750 | return; | 734 | return 0; |
751 | 735 | ||
752 | cs_failed: | 736 | cs_failed: |
753 | cs_error(link->handle, last_fn, last_ret); | 737 | cs_error(link, last_fn, last_ret); |
754 | failed: | 738 | failed: |
755 | nmclan_release(link); | 739 | nmclan_release(link); |
756 | return; | 740 | return -ENODEV; |
757 | |||
758 | } /* nmclan_config */ | 741 | } /* nmclan_config */ |
759 | 742 | ||
760 | /* ---------------------------------------------------------------------------- | 743 | /* ---------------------------------------------------------------------------- |
@@ -763,46 +746,29 @@ nmclan_release | |||
763 | net device, and release the PCMCIA configuration. If the device | 746 | net device, and release the PCMCIA configuration. If the device |
764 | is still open, this will be postponed until it is closed. | 747 | is still open, this will be postponed until it is closed. |
765 | ---------------------------------------------------------------------------- */ | 748 | ---------------------------------------------------------------------------- */ |
766 | static void nmclan_release(dev_link_t *link) | 749 | static void nmclan_release(struct pcmcia_device *link) |
767 | { | 750 | { |
768 | 751 | DEBUG(0, "nmclan_release(0x%p)\n", link); | |
769 | DEBUG(0, "nmclan_release(0x%p)\n", link); | 752 | pcmcia_disable_device(link); |
770 | |||
771 | pcmcia_release_configuration(link->handle); | ||
772 | pcmcia_release_io(link->handle, &link->io); | ||
773 | pcmcia_release_irq(link->handle, &link->irq); | ||
774 | |||
775 | link->state &= ~DEV_CONFIG; | ||
776 | } | 753 | } |
777 | 754 | ||
778 | static int nmclan_suspend(struct pcmcia_device *p_dev) | 755 | static int nmclan_suspend(struct pcmcia_device *link) |
779 | { | 756 | { |
780 | dev_link_t *link = dev_to_instance(p_dev); | ||
781 | struct net_device *dev = link->priv; | 757 | struct net_device *dev = link->priv; |
782 | 758 | ||
783 | link->state |= DEV_SUSPEND; | 759 | if (link->open) |
784 | if (link->state & DEV_CONFIG) { | 760 | netif_device_detach(dev); |
785 | if (link->open) | ||
786 | netif_device_detach(dev); | ||
787 | pcmcia_release_configuration(link->handle); | ||
788 | } | ||
789 | |||
790 | 761 | ||
791 | return 0; | 762 | return 0; |
792 | } | 763 | } |
793 | 764 | ||
794 | static int nmclan_resume(struct pcmcia_device *p_dev) | 765 | static int nmclan_resume(struct pcmcia_device *link) |
795 | { | 766 | { |
796 | dev_link_t *link = dev_to_instance(p_dev); | ||
797 | struct net_device *dev = link->priv; | 767 | struct net_device *dev = link->priv; |
798 | 768 | ||
799 | link->state &= ~DEV_SUSPEND; | 769 | if (link->open) { |
800 | if (link->state & DEV_CONFIG) { | 770 | nmclan_reset(dev); |
801 | pcmcia_request_configuration(link->handle, &link->conf); | 771 | netif_device_attach(dev); |
802 | if (link->open) { | ||
803 | nmclan_reset(dev); | ||
804 | netif_device_attach(dev); | ||
805 | } | ||
806 | } | 772 | } |
807 | 773 | ||
808 | return 0; | 774 | return 0; |
@@ -818,7 +784,7 @@ static void nmclan_reset(struct net_device *dev) | |||
818 | mace_private *lp = netdev_priv(dev); | 784 | mace_private *lp = netdev_priv(dev); |
819 | 785 | ||
820 | #if RESET_XILINX | 786 | #if RESET_XILINX |
821 | dev_link_t *link = &lp->link; | 787 | struct pcmcia_device *link = &lp->link; |
822 | conf_reg_t reg; | 788 | conf_reg_t reg; |
823 | u_long OrigCorValue; | 789 | u_long OrigCorValue; |
824 | 790 | ||
@@ -827,7 +793,7 @@ static void nmclan_reset(struct net_device *dev) | |||
827 | reg.Action = CS_READ; | 793 | reg.Action = CS_READ; |
828 | reg.Offset = CISREG_COR; | 794 | reg.Offset = CISREG_COR; |
829 | reg.Value = 0; | 795 | reg.Value = 0; |
830 | pcmcia_access_configuration_register(link->handle, ®); | 796 | pcmcia_access_configuration_register(link, ®); |
831 | OrigCorValue = reg.Value; | 797 | OrigCorValue = reg.Value; |
832 | 798 | ||
833 | /* Reset Xilinx */ | 799 | /* Reset Xilinx */ |
@@ -836,12 +802,12 @@ static void nmclan_reset(struct net_device *dev) | |||
836 | DEBUG(1, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n", | 802 | DEBUG(1, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n", |
837 | OrigCorValue); | 803 | OrigCorValue); |
838 | reg.Value = COR_SOFT_RESET; | 804 | reg.Value = COR_SOFT_RESET; |
839 | pcmcia_access_configuration_register(link->handle, ®); | 805 | pcmcia_access_configuration_register(link, ®); |
840 | /* Need to wait for 20 ms for PCMCIA to finish reset. */ | 806 | /* Need to wait for 20 ms for PCMCIA to finish reset. */ |
841 | 807 | ||
842 | /* Restore original COR configuration index */ | 808 | /* Restore original COR configuration index */ |
843 | reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK); | 809 | reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK); |
844 | pcmcia_access_configuration_register(link->handle, ®); | 810 | pcmcia_access_configuration_register(link, ®); |
845 | /* Xilinx is now completely reset along with the MACE chip. */ | 811 | /* Xilinx is now completely reset along with the MACE chip. */ |
846 | lp->tx_free_frames=AM2150_MAX_TX_FRAMES; | 812 | lp->tx_free_frames=AM2150_MAX_TX_FRAMES; |
847 | 813 | ||
@@ -885,9 +851,9 @@ static int mace_open(struct net_device *dev) | |||
885 | { | 851 | { |
886 | kio_addr_t ioaddr = dev->base_addr; | 852 | kio_addr_t ioaddr = dev->base_addr; |
887 | mace_private *lp = netdev_priv(dev); | 853 | mace_private *lp = netdev_priv(dev); |
888 | dev_link_t *link = &lp->link; | 854 | struct pcmcia_device *link = lp->p_dev; |
889 | 855 | ||
890 | if (!DEV_OK(link)) | 856 | if (!pcmcia_dev_present(link)) |
891 | return -ENODEV; | 857 | return -ENODEV; |
892 | 858 | ||
893 | link->open++; | 859 | link->open++; |
@@ -908,7 +874,7 @@ static int mace_close(struct net_device *dev) | |||
908 | { | 874 | { |
909 | kio_addr_t ioaddr = dev->base_addr; | 875 | kio_addr_t ioaddr = dev->base_addr; |
910 | mace_private *lp = netdev_priv(dev); | 876 | mace_private *lp = netdev_priv(dev); |
911 | dev_link_t *link = &lp->link; | 877 | struct pcmcia_device *link = lp->p_dev; |
912 | 878 | ||
913 | DEBUG(2, "%s: shutting down ethercard.\n", dev->name); | 879 | DEBUG(2, "%s: shutting down ethercard.\n", dev->name); |
914 | 880 | ||
@@ -963,12 +929,12 @@ mace_start_xmit | |||
963 | static void mace_tx_timeout(struct net_device *dev) | 929 | static void mace_tx_timeout(struct net_device *dev) |
964 | { | 930 | { |
965 | mace_private *lp = netdev_priv(dev); | 931 | mace_private *lp = netdev_priv(dev); |
966 | dev_link_t *link = &lp->link; | 932 | struct pcmcia_device *link = lp->p_dev; |
967 | 933 | ||
968 | printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); | 934 | printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); |
969 | #if RESET_ON_TIMEOUT | 935 | #if RESET_ON_TIMEOUT |
970 | printk("resetting card\n"); | 936 | printk("resetting card\n"); |
971 | pcmcia_reset_card(link->handle, NULL); | 937 | pcmcia_reset_card(link, NULL); |
972 | #else /* #if RESET_ON_TIMEOUT */ | 938 | #else /* #if RESET_ON_TIMEOUT */ |
973 | printk("NOT resetting card\n"); | 939 | printk("NOT resetting card\n"); |
974 | #endif /* #if RESET_ON_TIMEOUT */ | 940 | #endif /* #if RESET_ON_TIMEOUT */ |
@@ -1635,7 +1601,7 @@ static struct pcmcia_driver nmclan_cs_driver = { | |||
1635 | .drv = { | 1601 | .drv = { |
1636 | .name = "nmclan_cs", | 1602 | .name = "nmclan_cs", |
1637 | }, | 1603 | }, |
1638 | .probe = nmclan_attach, | 1604 | .probe = nmclan_probe, |
1639 | .remove = nmclan_detach, | 1605 | .remove = nmclan_detach, |
1640 | .id_table = nmclan_ids, | 1606 | .id_table = nmclan_ids, |
1641 | .suspend = nmclan_suspend, | 1607 | .suspend = nmclan_suspend, |