aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bfin_mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bfin_mac.c')
-rw-r--r--drivers/net/bfin_mac.c296
1 files changed, 170 insertions, 126 deletions
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 4fec8581bfd7..89c0018132ec 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -27,6 +27,7 @@
27#include <linux/phy.h> 27#include <linux/phy.h>
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
29#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
30#include <linux/ethtool.h>
30#include <linux/skbuff.h> 31#include <linux/skbuff.h>
31#include <linux/platform_device.h> 32#include <linux/platform_device.h>
32 33
@@ -42,7 +43,7 @@
42#define DRV_NAME "bfin_mac" 43#define DRV_NAME "bfin_mac"
43#define DRV_VERSION "1.1" 44#define DRV_VERSION "1.1"
44#define DRV_AUTHOR "Bryan Wu, Luke Yang" 45#define DRV_AUTHOR "Bryan Wu, Luke Yang"
45#define DRV_DESC "Blackfin BF53[67] BF527 on-chip Ethernet MAC driver" 46#define DRV_DESC "Blackfin on-chip Ethernet MAC driver"
46 47
47MODULE_AUTHOR(DRV_AUTHOR); 48MODULE_AUTHOR(DRV_AUTHOR);
48MODULE_LICENSE("GPL"); 49MODULE_LICENSE("GPL");
@@ -73,8 +74,14 @@ static struct net_dma_desc_tx *current_tx_ptr;
73static struct net_dma_desc_tx *tx_desc; 74static struct net_dma_desc_tx *tx_desc;
74static struct net_dma_desc_rx *rx_desc; 75static struct net_dma_desc_rx *rx_desc;
75 76
76static void bf537mac_disable(void); 77#if defined(CONFIG_BFIN_MAC_RMII)
77static void bf537mac_enable(void); 78static u16 pin_req[] = P_RMII0;
79#else
80static u16 pin_req[] = P_MII0;
81#endif
82
83static void bfin_mac_disable(void);
84static void bfin_mac_enable(void);
78 85
79static void desc_list_free(void) 86static void desc_list_free(void)
80{ 87{
@@ -243,27 +250,6 @@ init_error:
243 250
244/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/ 251/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/
245 252
246/* Set FER regs to MUX in Ethernet pins */
247static 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/* 253/*
268 * MII operations 254 * MII operations
269 */ 255 */
@@ -322,9 +308,9 @@ static int mdiobus_reset(struct mii_bus *bus)
322 return 0; 308 return 0;
323} 309}
324 310
325static void bf537_adjust_link(struct net_device *dev) 311static void bfin_mac_adjust_link(struct net_device *dev)
326{ 312{
327 struct bf537mac_local *lp = netdev_priv(dev); 313 struct bfin_mac_local *lp = netdev_priv(dev);
328 struct phy_device *phydev = lp->phydev; 314 struct phy_device *phydev = lp->phydev;
329 unsigned long flags; 315 unsigned long flags;
330 int new_state = 0; 316 int new_state = 0;
@@ -395,7 +381,7 @@ static void bf537_adjust_link(struct net_device *dev)
395 381
396static int mii_probe(struct net_device *dev) 382static int mii_probe(struct net_device *dev)
397{ 383{
398 struct bf537mac_local *lp = netdev_priv(dev); 384 struct bfin_mac_local *lp = netdev_priv(dev);
399 struct phy_device *phydev = NULL; 385 struct phy_device *phydev = NULL;
400 unsigned short sysctl; 386 unsigned short sysctl;
401 int i; 387 int i;
@@ -431,10 +417,10 @@ static int mii_probe(struct net_device *dev)
431 } 417 }
432 418
433#if defined(CONFIG_BFIN_MAC_RMII) 419#if defined(CONFIG_BFIN_MAC_RMII)
434 phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0, 420 phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0,
435 PHY_INTERFACE_MODE_RMII); 421 PHY_INTERFACE_MODE_RMII);
436#else 422#else
437 phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0, 423 phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0,
438 PHY_INTERFACE_MODE_MII); 424 PHY_INTERFACE_MODE_MII);
439#endif 425#endif
440 426
@@ -469,6 +455,51 @@ static int mii_probe(struct net_device *dev)
469 return 0; 455 return 0;
470} 456}
471 457
458/*
459 * Ethtool support
460 */
461
462static int
463bfin_mac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
464{
465 struct bfin_mac_local *lp = netdev_priv(dev);
466
467 if (lp->phydev)
468 return phy_ethtool_gset(lp->phydev, cmd);
469
470 return -EINVAL;
471}
472
473static int
474bfin_mac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
475{
476 struct bfin_mac_local *lp = netdev_priv(dev);
477
478 if (!capable(CAP_NET_ADMIN))
479 return -EPERM;
480
481 if (lp->phydev)
482 return phy_ethtool_sset(lp->phydev, cmd);
483
484 return -EINVAL;
485}
486
487static void bfin_mac_ethtool_getdrvinfo(struct net_device *dev,
488 struct ethtool_drvinfo *info)
489{
490 strcpy(info->driver, DRV_NAME);
491 strcpy(info->version, DRV_VERSION);
492 strcpy(info->fw_version, "N/A");
493 strcpy(info->bus_info, dev->dev.bus_id);
494}
495
496static struct ethtool_ops bfin_mac_ethtool_ops = {
497 .get_settings = bfin_mac_ethtool_getsettings,
498 .set_settings = bfin_mac_ethtool_setsettings,
499 .get_link = ethtool_op_get_link,
500 .get_drvinfo = bfin_mac_ethtool_getdrvinfo,
501};
502
472/**************************************************************************/ 503/**************************************************************************/
473void setup_system_regs(struct net_device *dev) 504void setup_system_regs(struct net_device *dev)
474{ 505{
@@ -511,7 +542,7 @@ static void setup_mac_addr(u8 *mac_addr)
511 bfin_write_EMAC_ADDRHI(addr_hi); 542 bfin_write_EMAC_ADDRHI(addr_hi);
512} 543}
513 544
514static int bf537mac_set_mac_address(struct net_device *dev, void *p) 545static int bfin_mac_set_mac_address(struct net_device *dev, void *p)
515{ 546{
516 struct sockaddr *addr = p; 547 struct sockaddr *addr = p;
517 if (netif_running(dev)) 548 if (netif_running(dev))
@@ -573,7 +604,7 @@ adjust_head:
573 604
574} 605}
575 606
576static int bf537mac_hard_start_xmit(struct sk_buff *skb, 607static int bfin_mac_hard_start_xmit(struct sk_buff *skb,
577 struct net_device *dev) 608 struct net_device *dev)
578{ 609{
579 unsigned int data; 610 unsigned int data;
@@ -631,7 +662,7 @@ out:
631 return 0; 662 return 0;
632} 663}
633 664
634static void bf537mac_rx(struct net_device *dev) 665static void bfin_mac_rx(struct net_device *dev)
635{ 666{
636 struct sk_buff *skb, *new_skb; 667 struct sk_buff *skb, *new_skb;
637 unsigned short len; 668 unsigned short len;
@@ -680,7 +711,7 @@ out:
680} 711}
681 712
682/* interrupt routine to handle rx and error signal */ 713/* interrupt routine to handle rx and error signal */
683static irqreturn_t bf537mac_interrupt(int irq, void *dev_id) 714static irqreturn_t bfin_mac_interrupt(int irq, void *dev_id)
684{ 715{
685 struct net_device *dev = dev_id; 716 struct net_device *dev = dev_id;
686 int number = 0; 717 int number = 0;
@@ -700,21 +731,21 @@ get_one_packet:
700 } 731 }
701 732
702real_rx: 733real_rx:
703 bf537mac_rx(dev); 734 bfin_mac_rx(dev);
704 number++; 735 number++;
705 goto get_one_packet; 736 goto get_one_packet;
706} 737}
707 738
708#ifdef CONFIG_NET_POLL_CONTROLLER 739#ifdef CONFIG_NET_POLL_CONTROLLER
709static void bf537mac_poll(struct net_device *dev) 740static void bfin_mac_poll(struct net_device *dev)
710{ 741{
711 disable_irq(IRQ_MAC_RX); 742 disable_irq(IRQ_MAC_RX);
712 bf537mac_interrupt(IRQ_MAC_RX, dev); 743 bfin_mac_interrupt(IRQ_MAC_RX, dev);
713 enable_irq(IRQ_MAC_RX); 744 enable_irq(IRQ_MAC_RX);
714} 745}
715#endif /* CONFIG_NET_POLL_CONTROLLER */ 746#endif /* CONFIG_NET_POLL_CONTROLLER */
716 747
717static void bf537mac_disable(void) 748static void bfin_mac_disable(void)
718{ 749{
719 unsigned int opmode; 750 unsigned int opmode;
720 751
@@ -728,7 +759,7 @@ static void bf537mac_disable(void)
728/* 759/*
729 * Enable Interrupts, Receive, and Transmit 760 * Enable Interrupts, Receive, and Transmit
730 */ 761 */
731static void bf537mac_enable(void) 762static void bfin_mac_enable(void)
732{ 763{
733 u32 opmode; 764 u32 opmode;
734 765
@@ -766,23 +797,23 @@ static void bf537mac_enable(void)
766} 797}
767 798
768/* Our watchdog timed out. Called by the networking layer */ 799/* Our watchdog timed out. Called by the networking layer */
769static void bf537mac_timeout(struct net_device *dev) 800static void bfin_mac_timeout(struct net_device *dev)
770{ 801{
771 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 802 pr_debug("%s: %s\n", dev->name, __FUNCTION__);
772 803
773 bf537mac_disable(); 804 bfin_mac_disable();
774 805
775 /* reset tx queue */ 806 /* reset tx queue */
776 tx_list_tail = tx_list_head->next; 807 tx_list_tail = tx_list_head->next;
777 808
778 bf537mac_enable(); 809 bfin_mac_enable();
779 810
780 /* We can accept TX packets again */ 811 /* We can accept TX packets again */
781 dev->trans_start = jiffies; 812 dev->trans_start = jiffies;
782 netif_wake_queue(dev); 813 netif_wake_queue(dev);
783} 814}
784 815
785static void bf537mac_multicast_hash(struct net_device *dev) 816static void bfin_mac_multicast_hash(struct net_device *dev)
786{ 817{
787 u32 emac_hashhi, emac_hashlo; 818 u32 emac_hashhi, emac_hashlo;
788 struct dev_mc_list *dmi = dev->mc_list; 819 struct dev_mc_list *dmi = dev->mc_list;
@@ -821,7 +852,7 @@ static void bf537mac_multicast_hash(struct net_device *dev)
821 * promiscuous mode (for TCPDUMP and cousins) or accept 852 * promiscuous mode (for TCPDUMP and cousins) or accept
822 * a select set of multicast packets 853 * a select set of multicast packets
823 */ 854 */
824static void bf537mac_set_multicast_list(struct net_device *dev) 855static void bfin_mac_set_multicast_list(struct net_device *dev)
825{ 856{
826 u32 sysctl; 857 u32 sysctl;
827 858
@@ -840,7 +871,7 @@ static void bf537mac_set_multicast_list(struct net_device *dev)
840 sysctl = bfin_read_EMAC_OPMODE(); 871 sysctl = bfin_read_EMAC_OPMODE();
841 sysctl |= HM; 872 sysctl |= HM;
842 bfin_write_EMAC_OPMODE(sysctl); 873 bfin_write_EMAC_OPMODE(sysctl);
843 bf537mac_multicast_hash(dev); 874 bfin_mac_multicast_hash(dev);
844 } else { 875 } else {
845 /* clear promisc or multicast mode */ 876 /* clear promisc or multicast mode */
846 sysctl = bfin_read_EMAC_OPMODE(); 877 sysctl = bfin_read_EMAC_OPMODE();
@@ -852,7 +883,7 @@ static void bf537mac_set_multicast_list(struct net_device *dev)
852/* 883/*
853 * this puts the device in an inactive state 884 * this puts the device in an inactive state
854 */ 885 */
855static void bf537mac_shutdown(struct net_device *dev) 886static void bfin_mac_shutdown(struct net_device *dev)
856{ 887{
857 /* Turn off the EMAC */ 888 /* Turn off the EMAC */
858 bfin_write_EMAC_OPMODE(0x00000000); 889 bfin_write_EMAC_OPMODE(0x00000000);
@@ -866,9 +897,9 @@ static void bf537mac_shutdown(struct net_device *dev)
866 * 897 *
867 * Set up everything, reset the card, etc.. 898 * Set up everything, reset the card, etc..
868 */ 899 */
869static int bf537mac_open(struct net_device *dev) 900static int bfin_mac_open(struct net_device *dev)
870{ 901{
871 struct bf537mac_local *lp = netdev_priv(dev); 902 struct bfin_mac_local *lp = netdev_priv(dev);
872 int retval; 903 int retval;
873 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 904 pr_debug("%s: %s\n", dev->name, __FUNCTION__);
874 905
@@ -891,8 +922,8 @@ static int bf537mac_open(struct net_device *dev)
891 phy_start(lp->phydev); 922 phy_start(lp->phydev);
892 phy_write(lp->phydev, MII_BMCR, BMCR_RESET); 923 phy_write(lp->phydev, MII_BMCR, BMCR_RESET);
893 setup_system_regs(dev); 924 setup_system_regs(dev);
894 bf537mac_disable(); 925 bfin_mac_disable();
895 bf537mac_enable(); 926 bfin_mac_enable();
896 pr_debug("hardware init finished\n"); 927 pr_debug("hardware init finished\n");
897 netif_start_queue(dev); 928 netif_start_queue(dev);
898 netif_carrier_on(dev); 929 netif_carrier_on(dev);
@@ -906,9 +937,9 @@ static int bf537mac_open(struct net_device *dev)
906 * and not talk to the outside world. Caused by 937 * and not talk to the outside world. Caused by
907 * an 'ifconfig ethX down' 938 * an 'ifconfig ethX down'
908 */ 939 */
909static int bf537mac_close(struct net_device *dev) 940static int bfin_mac_close(struct net_device *dev)
910{ 941{
911 struct bf537mac_local *lp = netdev_priv(dev); 942 struct bfin_mac_local *lp = netdev_priv(dev);
912 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 943 pr_debug("%s: %s\n", dev->name, __FUNCTION__);
913 944
914 netif_stop_queue(dev); 945 netif_stop_queue(dev);
@@ -918,7 +949,7 @@ static int bf537mac_close(struct net_device *dev)
918 phy_write(lp->phydev, MII_BMCR, BMCR_PDOWN); 949 phy_write(lp->phydev, MII_BMCR, BMCR_PDOWN);
919 950
920 /* clear everything */ 951 /* clear everything */
921 bf537mac_shutdown(dev); 952 bfin_mac_shutdown(dev);
922 953
923 /* free the rx/tx buffers */ 954 /* free the rx/tx buffers */
924 desc_list_free(); 955 desc_list_free();
@@ -926,46 +957,59 @@ static int bf537mac_close(struct net_device *dev)
926 return 0; 957 return 0;
927} 958}
928 959
929static int __init bf537mac_probe(struct net_device *dev) 960static int __init bfin_mac_probe(struct platform_device *pdev)
930{ 961{
931 struct bf537mac_local *lp = netdev_priv(dev); 962 struct net_device *ndev;
932 int retval; 963 struct bfin_mac_local *lp;
933 int i; 964 int rc, i;
965
966 ndev = alloc_etherdev(sizeof(struct bfin_mac_local));
967 if (!ndev) {
968 dev_err(&pdev->dev, "Cannot allocate net device!\n");
969 return -ENOMEM;
970 }
971
972 SET_NETDEV_DEV(ndev, &pdev->dev);
973 platform_set_drvdata(pdev, ndev);
974 lp = netdev_priv(ndev);
934 975
935 /* Grab the MAC address in the MAC */ 976 /* Grab the MAC address in the MAC */
936 *(__le32 *) (&(dev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO()); 977 *(__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()); 978 *(__le16 *) (&(ndev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI());
938 979
939 /* probe mac */ 980 /* probe mac */
940 /*todo: how to proble? which is revision_register */ 981 /*todo: how to proble? which is revision_register */
941 bfin_write_EMAC_ADDRLO(0x12345678); 982 bfin_write_EMAC_ADDRLO(0x12345678);
942 if (bfin_read_EMAC_ADDRLO() != 0x12345678) { 983 if (bfin_read_EMAC_ADDRLO() != 0x12345678) {
943 pr_debug("can't detect bf537 mac!\n"); 984 dev_err(&pdev->dev, "Cannot detect Blackfin on-chip ethernet MAC controller!\n");
944 retval = -ENODEV; 985 rc = -ENODEV;
945 goto err_out; 986 goto out_err_probe_mac;
946 } 987 }
947 988
948 /* set the GPIO pins to Ethernet mode */ 989 /* set the GPIO pins to Ethernet mode */
949 retval = setup_pin_mux(1); 990 rc = peripheral_request_list(pin_req, DRV_NAME);
950 if (retval) 991 if (rc) {
951 return retval; 992 dev_err(&pdev->dev, "Requesting peripherals failed!\n");
952 993 rc = -EFAULT;
953 /*Is it valid? (Did bootloader initialize it?) */ 994 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 } 995 }
959 996
997 /*
998 * Is it valid? (Did bootloader initialize it?)
999 * Grab the MAC from the board somehow
1000 * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c
1001 */
1002 if (!is_valid_ether_addr(ndev->dev_addr))
1003 bfin_get_ether_addr(ndev->dev_addr);
1004
960 /* If still not valid, get a random one */ 1005 /* If still not valid, get a random one */
961 if (!is_valid_ether_addr(dev->dev_addr)) { 1006 if (!is_valid_ether_addr(ndev->dev_addr))
962 random_ether_addr(dev->dev_addr); 1007 random_ether_addr(ndev->dev_addr);
963 }
964 1008
965 setup_mac_addr(dev->dev_addr); 1009 setup_mac_addr(ndev->dev_addr);
966 1010
967 /* MDIO bus initial */ 1011 /* MDIO bus initial */
968 lp->mii_bus.priv = dev; 1012 lp->mii_bus.priv = ndev;
969 lp->mii_bus.read = mdiobus_read; 1013 lp->mii_bus.read = mdiobus_read;
970 lp->mii_bus.write = mdiobus_write; 1014 lp->mii_bus.write = mdiobus_write;
971 lp->mii_bus.reset = mdiobus_reset; 1015 lp->mii_bus.reset = mdiobus_reset;
@@ -975,86 +1019,86 @@ static int __init bf537mac_probe(struct net_device *dev)
975 for (i = 0; i < PHY_MAX_ADDR; ++i) 1019 for (i = 0; i < PHY_MAX_ADDR; ++i)
976 lp->mii_bus.irq[i] = PHY_POLL; 1020 lp->mii_bus.irq[i] = PHY_POLL;
977 1021
978 mdiobus_register(&lp->mii_bus); 1022 rc = mdiobus_register(&lp->mii_bus);
1023 if (rc) {
1024 dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
1025 goto out_err_mdiobus_register;
1026 }
979 1027
980 retval = mii_probe(dev); 1028 rc = mii_probe(ndev);
981 if (retval) 1029 if (rc) {
982 return retval; 1030 dev_err(&pdev->dev, "MII Probe failed!\n");
1031 goto out_err_mii_probe;
1032 }
983 1033
984 /* Fill in the fields of the device structure with ethernet values. */ 1034 /* Fill in the fields of the device structure with ethernet values. */
985 ether_setup(dev); 1035 ether_setup(ndev);
986 1036
987 dev->open = bf537mac_open; 1037 ndev->open = bfin_mac_open;
988 dev->stop = bf537mac_close; 1038 ndev->stop = bfin_mac_close;
989 dev->hard_start_xmit = bf537mac_hard_start_xmit; 1039 ndev->hard_start_xmit = bfin_mac_hard_start_xmit;
990 dev->set_mac_address = bf537mac_set_mac_address; 1040 ndev->set_mac_address = bfin_mac_set_mac_address;
991 dev->tx_timeout = bf537mac_timeout; 1041 ndev->tx_timeout = bfin_mac_timeout;
992 dev->set_multicast_list = bf537mac_set_multicast_list; 1042 ndev->set_multicast_list = bfin_mac_set_multicast_list;
993#ifdef CONFIG_NET_POLL_CONTROLLER 1043#ifdef CONFIG_NET_POLL_CONTROLLER
994 dev->poll_controller = bf537mac_poll; 1044 ndev->poll_controller = bfin_mac_poll;
995#endif 1045#endif
1046 ndev->ethtool_ops = &bfin_mac_ethtool_ops;
996 1047
997 spin_lock_init(&lp->lock); 1048 spin_lock_init(&lp->lock);
998 1049
999 /* now, enable interrupts */ 1050 /* now, enable interrupts */
1000 /* register irq handler */ 1051 /* register irq handler */
1001 if (request_irq 1052 rc = request_irq(IRQ_MAC_RX, bfin_mac_interrupt,
1002 (IRQ_MAC_RX, bf537mac_interrupt, IRQF_DISABLED | IRQF_SHARED, 1053 IRQF_DISABLED | IRQF_SHARED, "EMAC_RX", ndev);
1003 "EMAC_RX", dev)) { 1054 if (rc) {
1004 printk(KERN_WARNING DRV_NAME 1055 dev_err(&pdev->dev, "Cannot request Blackfin MAC RX IRQ!\n");
1005 ": Unable to attach BlackFin MAC RX interrupt\n"); 1056 rc = -EBUSY;
1006 return -EBUSY; 1057 goto out_err_request_irq;
1007 } 1058 }
1008 1059
1009 1060 rc = register_netdev(ndev);
1010 retval = register_netdev(dev); 1061 if (rc) {
1011 if (retval == 0) { 1062 dev_err(&pdev->dev, "Cannot register net device!\n");
1012 /* now, print out the card info, in a short format.. */ 1063 goto out_err_reg_ndev;
1013 printk(KERN_INFO "%s: Version %s, %s\n",
1014 DRV_NAME, DRV_VERSION, DRV_DESC);
1015 }
1016
1017err_out:
1018 return retval;
1019}
1020
1021static 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 } 1064 }
1030 1065
1031 SET_NETDEV_DEV(ndev, &pdev->dev); 1066 /* now, print out the card info, in a short format.. */
1067 dev_info(&pdev->dev, "%s, Version %s\n", DRV_DESC, DRV_VERSION);
1032 1068
1033 platform_set_drvdata(pdev, ndev); 1069 return 0;
1034 1070
1035 if (bf537mac_probe(ndev) != 0) { 1071out_err_reg_ndev:
1036 platform_set_drvdata(pdev, NULL); 1072 free_irq(IRQ_MAC_RX, ndev);
1037 free_netdev(ndev); 1073out_err_request_irq:
1038 printk(KERN_WARNING DRV_NAME ": not found\n"); 1074out_err_mii_probe:
1039 return -ENODEV; 1075 mdiobus_unregister(&lp->mii_bus);
1040 } 1076out_err_mdiobus_register:
1077 peripheral_free_list(pin_req);
1078out_err_setup_pin_mux:
1079out_err_probe_mac:
1080 platform_set_drvdata(pdev, NULL);
1081 free_netdev(ndev);
1041 1082
1042 return 0; 1083 return rc;
1043} 1084}
1044 1085
1045static int bfin_mac_remove(struct platform_device *pdev) 1086static int bfin_mac_remove(struct platform_device *pdev)
1046{ 1087{
1047 struct net_device *ndev = platform_get_drvdata(pdev); 1088 struct net_device *ndev = platform_get_drvdata(pdev);
1089 struct bfin_mac_local *lp = netdev_priv(ndev);
1048 1090
1049 platform_set_drvdata(pdev, NULL); 1091 platform_set_drvdata(pdev, NULL);
1050 1092
1093 mdiobus_unregister(&lp->mii_bus);
1094
1051 unregister_netdev(ndev); 1095 unregister_netdev(ndev);
1052 1096
1053 free_irq(IRQ_MAC_RX, ndev); 1097 free_irq(IRQ_MAC_RX, ndev);
1054 1098
1055 free_netdev(ndev); 1099 free_netdev(ndev);
1056 1100
1057 setup_pin_mux(0); 1101 peripheral_free_list(pin_req);
1058 1102
1059 return 0; 1103 return 0;
1060} 1104}
@@ -1065,7 +1109,7 @@ static int bfin_mac_suspend(struct platform_device *pdev, pm_message_t mesg)
1065 struct net_device *net_dev = platform_get_drvdata(pdev); 1109 struct net_device *net_dev = platform_get_drvdata(pdev);
1066 1110
1067 if (netif_running(net_dev)) 1111 if (netif_running(net_dev))
1068 bf537mac_close(net_dev); 1112 bfin_mac_close(net_dev);
1069 1113
1070 return 0; 1114 return 0;
1071} 1115}
@@ -1075,7 +1119,7 @@ static int bfin_mac_resume(struct platform_device *pdev)
1075 struct net_device *net_dev = platform_get_drvdata(pdev); 1119 struct net_device *net_dev = platform_get_drvdata(pdev);
1076 1120
1077 if (netif_running(net_dev)) 1121 if (netif_running(net_dev))
1078 bf537mac_open(net_dev); 1122 bfin_mac_open(net_dev);
1079 1123
1080 return 0; 1124 return 0;
1081} 1125}