diff options
author | Bryan Wu <cooloney@kernel.org> | 2008-04-24 23:53:10 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-29 01:56:14 -0400 |
commit | 7ef0a7ee2f9ac7ee8e2a597821adb2a78b882791 (patch) | |
tree | 71511e805b73a2cf0e705fbc994646e9dfa83513 /drivers/net/bfin_mac.c | |
parent | 4e5b864e7cac67f06f18147b1980cb6b8fb213ec (diff) |
Blackfin EMAC Driver: code cleanup
- replace specific "bf537" function or data structure name to "bfin_mac"
- cleanup bfin_mac_probe with error checking
- punt set_pin_mux function, call peripheral request/free list functions directly
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/bfin_mac.c')
-rw-r--r-- | drivers/net/bfin_mac.c | 249 |
1 files changed, 123 insertions, 126 deletions
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c index 4fec8581bfd7..609748b84e83 100644 --- a/drivers/net/bfin_mac.c +++ b/drivers/net/bfin_mac.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #define DRV_NAME "bfin_mac" | 42 | #define DRV_NAME "bfin_mac" |
43 | #define DRV_VERSION "1.1" | 43 | #define DRV_VERSION "1.1" |
44 | #define DRV_AUTHOR "Bryan Wu, Luke Yang" | 44 | #define DRV_AUTHOR "Bryan Wu, Luke Yang" |
45 | #define DRV_DESC "Blackfin BF53[67] BF527 on-chip Ethernet MAC driver" | 45 | #define DRV_DESC "Blackfin on-chip Ethernet MAC driver" |
46 | 46 | ||
47 | MODULE_AUTHOR(DRV_AUTHOR); | 47 | MODULE_AUTHOR(DRV_AUTHOR); |
48 | MODULE_LICENSE("GPL"); | 48 | MODULE_LICENSE("GPL"); |
@@ -73,8 +73,14 @@ static struct net_dma_desc_tx *current_tx_ptr; | |||
73 | static struct net_dma_desc_tx *tx_desc; | 73 | static struct net_dma_desc_tx *tx_desc; |
74 | static struct net_dma_desc_rx *rx_desc; | 74 | static struct net_dma_desc_rx *rx_desc; |
75 | 75 | ||
76 | static void bf537mac_disable(void); | 76 | #if defined(CONFIG_BFIN_MAC_RMII) |
77 | static void bf537mac_enable(void); | 77 | static u16 pin_req[] = P_RMII0; |
78 | #else | ||
79 | static u16 pin_req[] = P_MII0; | ||
80 | #endif | ||
81 | |||
82 | static void bfin_mac_disable(void); | ||
83 | static void bfin_mac_enable(void); | ||
78 | 84 | ||
79 | static void desc_list_free(void) | 85 | static void desc_list_free(void) |
80 | { | 86 | { |
@@ -243,27 +249,6 @@ init_error: | |||
243 | 249 | ||
244 | /*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/ | 250 | /*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/ |
245 | 251 | ||
246 | /* Set FER regs to MUX in Ethernet pins */ | ||
247 | static int setup_pin_mux(int action) | ||
248 | { | ||
249 | #if defined(CONFIG_BFIN_MAC_RMII) | ||
250 | u16 pin_req[] = P_RMII0; | ||
251 | #else | ||
252 | u16 pin_req[] = P_MII0; | ||
253 | #endif | ||
254 | |||
255 | if (action) { | ||
256 | if (peripheral_request_list(pin_req, DRV_NAME)) { | ||
257 | printk(KERN_ERR DRV_NAME | ||
258 | ": Requesting Peripherals failed\n"); | ||
259 | return -EFAULT; | ||
260 | } | ||
261 | } else | ||
262 | peripheral_free_list(pin_req); | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | /* | 252 | /* |
268 | * MII operations | 253 | * MII operations |
269 | */ | 254 | */ |
@@ -322,9 +307,9 @@ static int mdiobus_reset(struct mii_bus *bus) | |||
322 | return 0; | 307 | return 0; |
323 | } | 308 | } |
324 | 309 | ||
325 | static void bf537_adjust_link(struct net_device *dev) | 310 | static void bfin_mac_adjust_link(struct net_device *dev) |
326 | { | 311 | { |
327 | struct bf537mac_local *lp = netdev_priv(dev); | 312 | struct bfin_mac_local *lp = netdev_priv(dev); |
328 | struct phy_device *phydev = lp->phydev; | 313 | struct phy_device *phydev = lp->phydev; |
329 | unsigned long flags; | 314 | unsigned long flags; |
330 | int new_state = 0; | 315 | int new_state = 0; |
@@ -395,7 +380,7 @@ static void bf537_adjust_link(struct net_device *dev) | |||
395 | 380 | ||
396 | static int mii_probe(struct net_device *dev) | 381 | static int mii_probe(struct net_device *dev) |
397 | { | 382 | { |
398 | struct bf537mac_local *lp = netdev_priv(dev); | 383 | struct bfin_mac_local *lp = netdev_priv(dev); |
399 | struct phy_device *phydev = NULL; | 384 | struct phy_device *phydev = NULL; |
400 | unsigned short sysctl; | 385 | unsigned short sysctl; |
401 | int i; | 386 | int i; |
@@ -431,10 +416,10 @@ static int mii_probe(struct net_device *dev) | |||
431 | } | 416 | } |
432 | 417 | ||
433 | #if defined(CONFIG_BFIN_MAC_RMII) | 418 | #if defined(CONFIG_BFIN_MAC_RMII) |
434 | phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0, | 419 | phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0, |
435 | PHY_INTERFACE_MODE_RMII); | 420 | PHY_INTERFACE_MODE_RMII); |
436 | #else | 421 | #else |
437 | phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0, | 422 | phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0, |
438 | PHY_INTERFACE_MODE_MII); | 423 | PHY_INTERFACE_MODE_MII); |
439 | #endif | 424 | #endif |
440 | 425 | ||
@@ -511,7 +496,7 @@ static void setup_mac_addr(u8 *mac_addr) | |||
511 | bfin_write_EMAC_ADDRHI(addr_hi); | 496 | bfin_write_EMAC_ADDRHI(addr_hi); |
512 | } | 497 | } |
513 | 498 | ||
514 | static int bf537mac_set_mac_address(struct net_device *dev, void *p) | 499 | static int bfin_mac_set_mac_address(struct net_device *dev, void *p) |
515 | { | 500 | { |
516 | struct sockaddr *addr = p; | 501 | struct sockaddr *addr = p; |
517 | if (netif_running(dev)) | 502 | if (netif_running(dev)) |
@@ -573,7 +558,7 @@ adjust_head: | |||
573 | 558 | ||
574 | } | 559 | } |
575 | 560 | ||
576 | static int bf537mac_hard_start_xmit(struct sk_buff *skb, | 561 | static int bfin_mac_hard_start_xmit(struct sk_buff *skb, |
577 | struct net_device *dev) | 562 | struct net_device *dev) |
578 | { | 563 | { |
579 | unsigned int data; | 564 | unsigned int data; |
@@ -631,7 +616,7 @@ out: | |||
631 | return 0; | 616 | return 0; |
632 | } | 617 | } |
633 | 618 | ||
634 | static void bf537mac_rx(struct net_device *dev) | 619 | static void bfin_mac_rx(struct net_device *dev) |
635 | { | 620 | { |
636 | struct sk_buff *skb, *new_skb; | 621 | struct sk_buff *skb, *new_skb; |
637 | unsigned short len; | 622 | unsigned short len; |
@@ -680,7 +665,7 @@ out: | |||
680 | } | 665 | } |
681 | 666 | ||
682 | /* interrupt routine to handle rx and error signal */ | 667 | /* interrupt routine to handle rx and error signal */ |
683 | static irqreturn_t bf537mac_interrupt(int irq, void *dev_id) | 668 | static irqreturn_t bfin_mac_interrupt(int irq, void *dev_id) |
684 | { | 669 | { |
685 | struct net_device *dev = dev_id; | 670 | struct net_device *dev = dev_id; |
686 | int number = 0; | 671 | int number = 0; |
@@ -700,21 +685,21 @@ get_one_packet: | |||
700 | } | 685 | } |
701 | 686 | ||
702 | real_rx: | 687 | real_rx: |
703 | bf537mac_rx(dev); | 688 | bfin_mac_rx(dev); |
704 | number++; | 689 | number++; |
705 | goto get_one_packet; | 690 | goto get_one_packet; |
706 | } | 691 | } |
707 | 692 | ||
708 | #ifdef CONFIG_NET_POLL_CONTROLLER | 693 | #ifdef CONFIG_NET_POLL_CONTROLLER |
709 | static void bf537mac_poll(struct net_device *dev) | 694 | static void bfin_mac_poll(struct net_device *dev) |
710 | { | 695 | { |
711 | disable_irq(IRQ_MAC_RX); | 696 | disable_irq(IRQ_MAC_RX); |
712 | bf537mac_interrupt(IRQ_MAC_RX, dev); | 697 | bfin_mac_interrupt(IRQ_MAC_RX, dev); |
713 | enable_irq(IRQ_MAC_RX); | 698 | enable_irq(IRQ_MAC_RX); |
714 | } | 699 | } |
715 | #endif /* CONFIG_NET_POLL_CONTROLLER */ | 700 | #endif /* CONFIG_NET_POLL_CONTROLLER */ |
716 | 701 | ||
717 | static void bf537mac_disable(void) | 702 | static void bfin_mac_disable(void) |
718 | { | 703 | { |
719 | unsigned int opmode; | 704 | unsigned int opmode; |
720 | 705 | ||
@@ -728,7 +713,7 @@ static void bf537mac_disable(void) | |||
728 | /* | 713 | /* |
729 | * Enable Interrupts, Receive, and Transmit | 714 | * Enable Interrupts, Receive, and Transmit |
730 | */ | 715 | */ |
731 | static void bf537mac_enable(void) | 716 | static void bfin_mac_enable(void) |
732 | { | 717 | { |
733 | u32 opmode; | 718 | u32 opmode; |
734 | 719 | ||
@@ -766,23 +751,23 @@ static void bf537mac_enable(void) | |||
766 | } | 751 | } |
767 | 752 | ||
768 | /* Our watchdog timed out. Called by the networking layer */ | 753 | /* Our watchdog timed out. Called by the networking layer */ |
769 | static void bf537mac_timeout(struct net_device *dev) | 754 | static void bfin_mac_timeout(struct net_device *dev) |
770 | { | 755 | { |
771 | pr_debug("%s: %s\n", dev->name, __FUNCTION__); | 756 | pr_debug("%s: %s\n", dev->name, __FUNCTION__); |
772 | 757 | ||
773 | bf537mac_disable(); | 758 | bfin_mac_disable(); |
774 | 759 | ||
775 | /* reset tx queue */ | 760 | /* reset tx queue */ |
776 | tx_list_tail = tx_list_head->next; | 761 | tx_list_tail = tx_list_head->next; |
777 | 762 | ||
778 | bf537mac_enable(); | 763 | bfin_mac_enable(); |
779 | 764 | ||
780 | /* We can accept TX packets again */ | 765 | /* We can accept TX packets again */ |
781 | dev->trans_start = jiffies; | 766 | dev->trans_start = jiffies; |
782 | netif_wake_queue(dev); | 767 | netif_wake_queue(dev); |
783 | } | 768 | } |
784 | 769 | ||
785 | static void bf537mac_multicast_hash(struct net_device *dev) | 770 | static void bfin_mac_multicast_hash(struct net_device *dev) |
786 | { | 771 | { |
787 | u32 emac_hashhi, emac_hashlo; | 772 | u32 emac_hashhi, emac_hashlo; |
788 | struct dev_mc_list *dmi = dev->mc_list; | 773 | struct dev_mc_list *dmi = dev->mc_list; |
@@ -821,7 +806,7 @@ static void bf537mac_multicast_hash(struct net_device *dev) | |||
821 | * promiscuous mode (for TCPDUMP and cousins) or accept | 806 | * promiscuous mode (for TCPDUMP and cousins) or accept |
822 | * a select set of multicast packets | 807 | * a select set of multicast packets |
823 | */ | 808 | */ |
824 | static void bf537mac_set_multicast_list(struct net_device *dev) | 809 | static void bfin_mac_set_multicast_list(struct net_device *dev) |
825 | { | 810 | { |
826 | u32 sysctl; | 811 | u32 sysctl; |
827 | 812 | ||
@@ -840,7 +825,7 @@ static void bf537mac_set_multicast_list(struct net_device *dev) | |||
840 | sysctl = bfin_read_EMAC_OPMODE(); | 825 | sysctl = bfin_read_EMAC_OPMODE(); |
841 | sysctl |= HM; | 826 | sysctl |= HM; |
842 | bfin_write_EMAC_OPMODE(sysctl); | 827 | bfin_write_EMAC_OPMODE(sysctl); |
843 | bf537mac_multicast_hash(dev); | 828 | bfin_mac_multicast_hash(dev); |
844 | } else { | 829 | } else { |
845 | /* clear promisc or multicast mode */ | 830 | /* clear promisc or multicast mode */ |
846 | sysctl = bfin_read_EMAC_OPMODE(); | 831 | sysctl = bfin_read_EMAC_OPMODE(); |
@@ -852,7 +837,7 @@ static void bf537mac_set_multicast_list(struct net_device *dev) | |||
852 | /* | 837 | /* |
853 | * this puts the device in an inactive state | 838 | * this puts the device in an inactive state |
854 | */ | 839 | */ |
855 | static void bf537mac_shutdown(struct net_device *dev) | 840 | static void bfin_mac_shutdown(struct net_device *dev) |
856 | { | 841 | { |
857 | /* Turn off the EMAC */ | 842 | /* Turn off the EMAC */ |
858 | bfin_write_EMAC_OPMODE(0x00000000); | 843 | bfin_write_EMAC_OPMODE(0x00000000); |
@@ -866,9 +851,9 @@ static void bf537mac_shutdown(struct net_device *dev) | |||
866 | * | 851 | * |
867 | * Set up everything, reset the card, etc.. | 852 | * Set up everything, reset the card, etc.. |
868 | */ | 853 | */ |
869 | static int bf537mac_open(struct net_device *dev) | 854 | static int bfin_mac_open(struct net_device *dev) |
870 | { | 855 | { |
871 | struct bf537mac_local *lp = netdev_priv(dev); | 856 | struct bfin_mac_local *lp = netdev_priv(dev); |
872 | int retval; | 857 | int retval; |
873 | pr_debug("%s: %s\n", dev->name, __FUNCTION__); | 858 | pr_debug("%s: %s\n", dev->name, __FUNCTION__); |
874 | 859 | ||
@@ -891,8 +876,8 @@ static int bf537mac_open(struct net_device *dev) | |||
891 | phy_start(lp->phydev); | 876 | phy_start(lp->phydev); |
892 | phy_write(lp->phydev, MII_BMCR, BMCR_RESET); | 877 | phy_write(lp->phydev, MII_BMCR, BMCR_RESET); |
893 | setup_system_regs(dev); | 878 | setup_system_regs(dev); |
894 | bf537mac_disable(); | 879 | bfin_mac_disable(); |
895 | bf537mac_enable(); | 880 | bfin_mac_enable(); |
896 | pr_debug("hardware init finished\n"); | 881 | pr_debug("hardware init finished\n"); |
897 | netif_start_queue(dev); | 882 | netif_start_queue(dev); |
898 | netif_carrier_on(dev); | 883 | netif_carrier_on(dev); |
@@ -906,9 +891,9 @@ static int bf537mac_open(struct net_device *dev) | |||
906 | * and not talk to the outside world. Caused by | 891 | * and not talk to the outside world. Caused by |
907 | * an 'ifconfig ethX down' | 892 | * an 'ifconfig ethX down' |
908 | */ | 893 | */ |
909 | static int bf537mac_close(struct net_device *dev) | 894 | static int bfin_mac_close(struct net_device *dev) |
910 | { | 895 | { |
911 | struct bf537mac_local *lp = netdev_priv(dev); | 896 | struct bfin_mac_local *lp = netdev_priv(dev); |
912 | pr_debug("%s: %s\n", dev->name, __FUNCTION__); | 897 | pr_debug("%s: %s\n", dev->name, __FUNCTION__); |
913 | 898 | ||
914 | netif_stop_queue(dev); | 899 | netif_stop_queue(dev); |
@@ -918,7 +903,7 @@ static int bf537mac_close(struct net_device *dev) | |||
918 | phy_write(lp->phydev, MII_BMCR, BMCR_PDOWN); | 903 | phy_write(lp->phydev, MII_BMCR, BMCR_PDOWN); |
919 | 904 | ||
920 | /* clear everything */ | 905 | /* clear everything */ |
921 | bf537mac_shutdown(dev); | 906 | bfin_mac_shutdown(dev); |
922 | 907 | ||
923 | /* free the rx/tx buffers */ | 908 | /* free the rx/tx buffers */ |
924 | desc_list_free(); | 909 | desc_list_free(); |
@@ -926,46 +911,59 @@ static int bf537mac_close(struct net_device *dev) | |||
926 | return 0; | 911 | return 0; |
927 | } | 912 | } |
928 | 913 | ||
929 | static int __init bf537mac_probe(struct net_device *dev) | 914 | static int __init bfin_mac_probe(struct platform_device *pdev) |
930 | { | 915 | { |
931 | struct bf537mac_local *lp = netdev_priv(dev); | 916 | struct net_device *ndev; |
932 | int retval; | 917 | struct bfin_mac_local *lp; |
933 | int i; | 918 | int rc, i; |
919 | |||
920 | ndev = alloc_etherdev(sizeof(struct bfin_mac_local)); | ||
921 | if (!ndev) { | ||
922 | dev_err(&pdev->dev, "Cannot allocate net device!\n"); | ||
923 | return -ENOMEM; | ||
924 | } | ||
925 | |||
926 | SET_NETDEV_DEV(ndev, &pdev->dev); | ||
927 | platform_set_drvdata(pdev, ndev); | ||
928 | lp = netdev_priv(ndev); | ||
934 | 929 | ||
935 | /* Grab the MAC address in the MAC */ | 930 | /* Grab the MAC address in the MAC */ |
936 | *(__le32 *) (&(dev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO()); | 931 | *(__le32 *) (&(ndev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO()); |
937 | *(__le16 *) (&(dev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI()); | 932 | *(__le16 *) (&(ndev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI()); |
938 | 933 | ||
939 | /* probe mac */ | 934 | /* probe mac */ |
940 | /*todo: how to proble? which is revision_register */ | 935 | /*todo: how to proble? which is revision_register */ |
941 | bfin_write_EMAC_ADDRLO(0x12345678); | 936 | bfin_write_EMAC_ADDRLO(0x12345678); |
942 | if (bfin_read_EMAC_ADDRLO() != 0x12345678) { | 937 | if (bfin_read_EMAC_ADDRLO() != 0x12345678) { |
943 | pr_debug("can't detect bf537 mac!\n"); | 938 | dev_err(&pdev->dev, "Cannot detect Blackfin on-chip ethernet MAC controller!\n"); |
944 | retval = -ENODEV; | 939 | rc = -ENODEV; |
945 | goto err_out; | 940 | goto out_err_probe_mac; |
946 | } | 941 | } |
947 | 942 | ||
948 | /* set the GPIO pins to Ethernet mode */ | 943 | /* set the GPIO pins to Ethernet mode */ |
949 | retval = setup_pin_mux(1); | 944 | rc = peripheral_request_list(pin_req, DRV_NAME); |
950 | if (retval) | 945 | if (rc) { |
951 | return retval; | 946 | dev_err(&pdev->dev, "Requesting peripherals failed!\n"); |
952 | 947 | rc = -EFAULT; | |
953 | /*Is it valid? (Did bootloader initialize it?) */ | 948 | goto out_err_setup_pin_mux; |
954 | if (!is_valid_ether_addr(dev->dev_addr)) { | ||
955 | /* Grab the MAC from the board somehow - this is done in the | ||
956 | arch/blackfin/mach-bf537/boards/eth_mac.c */ | ||
957 | bfin_get_ether_addr(dev->dev_addr); | ||
958 | } | 949 | } |
959 | 950 | ||
951 | /* | ||
952 | * Is it valid? (Did bootloader initialize it?) | ||
953 | * Grab the MAC from the board somehow | ||
954 | * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c | ||
955 | */ | ||
956 | if (!is_valid_ether_addr(ndev->dev_addr)) | ||
957 | bfin_get_ether_addr(ndev->dev_addr); | ||
958 | |||
960 | /* If still not valid, get a random one */ | 959 | /* If still not valid, get a random one */ |
961 | if (!is_valid_ether_addr(dev->dev_addr)) { | 960 | if (!is_valid_ether_addr(ndev->dev_addr)) |
962 | random_ether_addr(dev->dev_addr); | 961 | random_ether_addr(ndev->dev_addr); |
963 | } | ||
964 | 962 | ||
965 | setup_mac_addr(dev->dev_addr); | 963 | setup_mac_addr(ndev->dev_addr); |
966 | 964 | ||
967 | /* MDIO bus initial */ | 965 | /* MDIO bus initial */ |
968 | lp->mii_bus.priv = dev; | 966 | lp->mii_bus.priv = ndev; |
969 | lp->mii_bus.read = mdiobus_read; | 967 | lp->mii_bus.read = mdiobus_read; |
970 | lp->mii_bus.write = mdiobus_write; | 968 | lp->mii_bus.write = mdiobus_write; |
971 | lp->mii_bus.reset = mdiobus_reset; | 969 | lp->mii_bus.reset = mdiobus_reset; |
@@ -975,86 +973,85 @@ static int __init bf537mac_probe(struct net_device *dev) | |||
975 | for (i = 0; i < PHY_MAX_ADDR; ++i) | 973 | for (i = 0; i < PHY_MAX_ADDR; ++i) |
976 | lp->mii_bus.irq[i] = PHY_POLL; | 974 | lp->mii_bus.irq[i] = PHY_POLL; |
977 | 975 | ||
978 | mdiobus_register(&lp->mii_bus); | 976 | rc = mdiobus_register(&lp->mii_bus); |
977 | if (rc) { | ||
978 | dev_err(&pdev->dev, "Cannot register MDIO bus!\n"); | ||
979 | goto out_err_mdiobus_register; | ||
980 | } | ||
979 | 981 | ||
980 | retval = mii_probe(dev); | 982 | rc = mii_probe(ndev); |
981 | if (retval) | 983 | if (rc) { |
982 | return retval; | 984 | dev_err(&pdev->dev, "MII Probe failed!\n"); |
985 | goto out_err_mii_probe; | ||
986 | } | ||
983 | 987 | ||
984 | /* Fill in the fields of the device structure with ethernet values. */ | 988 | /* Fill in the fields of the device structure with ethernet values. */ |
985 | ether_setup(dev); | 989 | ether_setup(ndev); |
986 | 990 | ||
987 | dev->open = bf537mac_open; | 991 | ndev->open = bfin_mac_open; |
988 | dev->stop = bf537mac_close; | 992 | ndev->stop = bfin_mac_close; |
989 | dev->hard_start_xmit = bf537mac_hard_start_xmit; | 993 | ndev->hard_start_xmit = bfin_mac_hard_start_xmit; |
990 | dev->set_mac_address = bf537mac_set_mac_address; | 994 | ndev->set_mac_address = bfin_mac_set_mac_address; |
991 | dev->tx_timeout = bf537mac_timeout; | 995 | ndev->tx_timeout = bfin_mac_timeout; |
992 | dev->set_multicast_list = bf537mac_set_multicast_list; | 996 | ndev->set_multicast_list = bfin_mac_set_multicast_list; |
993 | #ifdef CONFIG_NET_POLL_CONTROLLER | 997 | #ifdef CONFIG_NET_POLL_CONTROLLER |
994 | dev->poll_controller = bf537mac_poll; | 998 | ndev->poll_controller = bfin_mac_poll; |
995 | #endif | 999 | #endif |
996 | 1000 | ||
997 | spin_lock_init(&lp->lock); | 1001 | spin_lock_init(&lp->lock); |
998 | 1002 | ||
999 | /* now, enable interrupts */ | 1003 | /* now, enable interrupts */ |
1000 | /* register irq handler */ | 1004 | /* register irq handler */ |
1001 | if (request_irq | 1005 | rc = request_irq(IRQ_MAC_RX, bfin_mac_interrupt, |
1002 | (IRQ_MAC_RX, bf537mac_interrupt, IRQF_DISABLED | IRQF_SHARED, | 1006 | IRQF_DISABLED | IRQF_SHARED, "EMAC_RX", ndev); |
1003 | "EMAC_RX", dev)) { | 1007 | if (rc) { |
1004 | printk(KERN_WARNING DRV_NAME | 1008 | dev_err(&pdev->dev, "Cannot request Blackfin MAC RX IRQ!\n"); |
1005 | ": Unable to attach BlackFin MAC RX interrupt\n"); | 1009 | rc = -EBUSY; |
1006 | return -EBUSY; | 1010 | goto out_err_request_irq; |
1007 | } | 1011 | } |
1008 | 1012 | ||
1009 | 1013 | rc = register_netdev(ndev); | |
1010 | retval = register_netdev(dev); | 1014 | if (rc) { |
1011 | if (retval == 0) { | 1015 | dev_err(&pdev->dev, "Cannot register net device!\n"); |
1012 | /* now, print out the card info, in a short format.. */ | 1016 | goto out_err_reg_ndev; |
1013 | printk(KERN_INFO "%s: Version %s, %s\n", | ||
1014 | DRV_NAME, DRV_VERSION, DRV_DESC); | ||
1015 | } | ||
1016 | |||
1017 | err_out: | ||
1018 | return retval; | ||
1019 | } | ||
1020 | |||
1021 | static int bfin_mac_probe(struct platform_device *pdev) | ||
1022 | { | ||
1023 | struct net_device *ndev; | ||
1024 | |||
1025 | ndev = alloc_etherdev(sizeof(struct bf537mac_local)); | ||
1026 | if (!ndev) { | ||
1027 | printk(KERN_WARNING DRV_NAME ": could not allocate device\n"); | ||
1028 | return -ENOMEM; | ||
1029 | } | 1017 | } |
1030 | 1018 | ||
1031 | SET_NETDEV_DEV(ndev, &pdev->dev); | 1019 | /* now, print out the card info, in a short format.. */ |
1020 | dev_info(&pdev->dev, "%s, Version %s\n", DRV_DESC, DRV_VERSION); | ||
1032 | 1021 | ||
1033 | platform_set_drvdata(pdev, ndev); | 1022 | return 0; |
1034 | 1023 | ||
1035 | if (bf537mac_probe(ndev) != 0) { | 1024 | out_err_reg_ndev: |
1036 | platform_set_drvdata(pdev, NULL); | 1025 | free_irq(IRQ_MAC_RX, ndev); |
1037 | free_netdev(ndev); | 1026 | out_err_request_irq: |
1038 | printk(KERN_WARNING DRV_NAME ": not found\n"); | 1027 | out_err_mii_probe: |
1039 | return -ENODEV; | 1028 | mdiobus_unregister(&lp->mii_bus); |
1040 | } | 1029 | out_err_mdiobus_register: |
1030 | peripheral_free_list(pin_req); | ||
1031 | out_err_setup_pin_mux: | ||
1032 | out_err_probe_mac: | ||
1033 | platform_set_drvdata(pdev, NULL); | ||
1034 | free_netdev(ndev); | ||
1041 | 1035 | ||
1042 | return 0; | 1036 | return rc; |
1043 | } | 1037 | } |
1044 | 1038 | ||
1045 | static int bfin_mac_remove(struct platform_device *pdev) | 1039 | static int bfin_mac_remove(struct platform_device *pdev) |
1046 | { | 1040 | { |
1047 | struct net_device *ndev = platform_get_drvdata(pdev); | 1041 | struct net_device *ndev = platform_get_drvdata(pdev); |
1042 | struct bfin_mac_local *lp = netdev_priv(ndev); | ||
1048 | 1043 | ||
1049 | platform_set_drvdata(pdev, NULL); | 1044 | platform_set_drvdata(pdev, NULL); |
1050 | 1045 | ||
1046 | mdiobus_unregister(&lp->mii_bus); | ||
1047 | |||
1051 | unregister_netdev(ndev); | 1048 | unregister_netdev(ndev); |
1052 | 1049 | ||
1053 | free_irq(IRQ_MAC_RX, ndev); | 1050 | free_irq(IRQ_MAC_RX, ndev); |
1054 | 1051 | ||
1055 | free_netdev(ndev); | 1052 | free_netdev(ndev); |
1056 | 1053 | ||
1057 | setup_pin_mux(0); | 1054 | peripheral_free_list(pin_req); |
1058 | 1055 | ||
1059 | return 0; | 1056 | return 0; |
1060 | } | 1057 | } |
@@ -1065,7 +1062,7 @@ static int bfin_mac_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1065 | struct net_device *net_dev = platform_get_drvdata(pdev); | 1062 | struct net_device *net_dev = platform_get_drvdata(pdev); |
1066 | 1063 | ||
1067 | if (netif_running(net_dev)) | 1064 | if (netif_running(net_dev)) |
1068 | bf537mac_close(net_dev); | 1065 | bfin_mac_close(net_dev); |
1069 | 1066 | ||
1070 | return 0; | 1067 | return 0; |
1071 | } | 1068 | } |
@@ -1075,7 +1072,7 @@ static int bfin_mac_resume(struct platform_device *pdev) | |||
1075 | struct net_device *net_dev = platform_get_drvdata(pdev); | 1072 | struct net_device *net_dev = platform_get_drvdata(pdev); |
1076 | 1073 | ||
1077 | if (netif_running(net_dev)) | 1074 | if (netif_running(net_dev)) |
1078 | bf537mac_open(net_dev); | 1075 | bfin_mac_open(net_dev); |
1079 | 1076 | ||
1080 | return 0; | 1077 | return 0; |
1081 | } | 1078 | } |