diff options
Diffstat (limited to 'drivers/net/au1000_eth.c')
-rw-r--r-- | drivers/net/au1000_eth.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index 92c16c37ff23..7b92201a7b50 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -290,7 +290,7 @@ static int mii_probe (struct net_device *dev) | |||
290 | 290 | ||
291 | if(aup->mac_id == 0) { /* get PHY0 */ | 291 | if(aup->mac_id == 0) { /* get PHY0 */ |
292 | # if defined(AU1XXX_PHY0_ADDR) | 292 | # if defined(AU1XXX_PHY0_ADDR) |
293 | phydev = au_macs[AU1XXX_PHY0_BUSID]->mii_bus.phy_map[AU1XXX_PHY0_ADDR]; | 293 | phydev = au_macs[AU1XXX_PHY0_BUSID]->mii_bus->phy_map[AU1XXX_PHY0_ADDR]; |
294 | # else | 294 | # else |
295 | printk (KERN_INFO DRV_NAME ":%s: using PHY-less setup\n", | 295 | printk (KERN_INFO DRV_NAME ":%s: using PHY-less setup\n", |
296 | dev->name); | 296 | dev->name); |
@@ -298,7 +298,7 @@ static int mii_probe (struct net_device *dev) | |||
298 | # endif /* defined(AU1XXX_PHY0_ADDR) */ | 298 | # endif /* defined(AU1XXX_PHY0_ADDR) */ |
299 | } else if (aup->mac_id == 1) { /* get PHY1 */ | 299 | } else if (aup->mac_id == 1) { /* get PHY1 */ |
300 | # if defined(AU1XXX_PHY1_ADDR) | 300 | # if defined(AU1XXX_PHY1_ADDR) |
301 | phydev = au_macs[AU1XXX_PHY1_BUSID]->mii_bus.phy_map[AU1XXX_PHY1_ADDR]; | 301 | phydev = au_macs[AU1XXX_PHY1_BUSID]->mii_bus->phy_map[AU1XXX_PHY1_ADDR]; |
302 | # else | 302 | # else |
303 | printk (KERN_INFO DRV_NAME ":%s: using PHY-less setup\n", | 303 | printk (KERN_INFO DRV_NAME ":%s: using PHY-less setup\n", |
304 | dev->name); | 304 | dev->name); |
@@ -311,8 +311,8 @@ static int mii_probe (struct net_device *dev) | |||
311 | 311 | ||
312 | /* find the first (lowest address) PHY on the current MAC's MII bus */ | 312 | /* find the first (lowest address) PHY on the current MAC's MII bus */ |
313 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) | 313 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) |
314 | if (aup->mii_bus.phy_map[phy_addr]) { | 314 | if (aup->mii_bus->phy_map[phy_addr]) { |
315 | phydev = aup->mii_bus.phy_map[phy_addr]; | 315 | phydev = aup->mii_bus->phy_map[phy_addr]; |
316 | # if !defined(AU1XXX_PHY_SEARCH_HIGHEST_ADDR) | 316 | # if !defined(AU1XXX_PHY_SEARCH_HIGHEST_ADDR) |
317 | break; /* break out with first one found */ | 317 | break; /* break out with first one found */ |
318 | # endif | 318 | # endif |
@@ -331,7 +331,7 @@ static int mii_probe (struct net_device *dev) | |||
331 | * the MAC0 MII bus */ | 331 | * the MAC0 MII bus */ |
332 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { | 332 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { |
333 | struct phy_device *const tmp_phydev = | 333 | struct phy_device *const tmp_phydev = |
334 | au_macs[0]->mii_bus.phy_map[phy_addr]; | 334 | au_macs[0]->mii_bus->phy_map[phy_addr]; |
335 | 335 | ||
336 | if (!tmp_phydev) | 336 | if (!tmp_phydev) |
337 | continue; /* no PHY here... */ | 337 | continue; /* no PHY here... */ |
@@ -698,28 +698,32 @@ static struct net_device * au1000_probe(int port_num) | |||
698 | *aup->enable = 0; | 698 | *aup->enable = 0; |
699 | aup->mac_enabled = 0; | 699 | aup->mac_enabled = 0; |
700 | 700 | ||
701 | aup->mii_bus.priv = dev; | 701 | aup->mii_bus = mdiobus_alloc(); |
702 | aup->mii_bus.read = mdiobus_read; | 702 | if (aup->mii_bus == NULL) |
703 | aup->mii_bus.write = mdiobus_write; | 703 | goto err_out; |
704 | aup->mii_bus.reset = mdiobus_reset; | 704 | |
705 | aup->mii_bus.name = "au1000_eth_mii"; | 705 | aup->mii_bus->priv = dev; |
706 | snprintf(aup->mii_bus.id, MII_BUS_ID_SIZE, "%x", aup->mac_id); | 706 | aup->mii_bus->read = mdiobus_read; |
707 | aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); | 707 | aup->mii_bus->write = mdiobus_write; |
708 | aup->mii_bus->reset = mdiobus_reset; | ||
709 | aup->mii_bus->name = "au1000_eth_mii"; | ||
710 | snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%x", aup->mac_id); | ||
711 | aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); | ||
708 | for(i = 0; i < PHY_MAX_ADDR; ++i) | 712 | for(i = 0; i < PHY_MAX_ADDR; ++i) |
709 | aup->mii_bus.irq[i] = PHY_POLL; | 713 | aup->mii_bus->irq[i] = PHY_POLL; |
710 | 714 | ||
711 | /* if known, set corresponding PHY IRQs */ | 715 | /* if known, set corresponding PHY IRQs */ |
712 | #if defined(AU1XXX_PHY_STATIC_CONFIG) | 716 | #if defined(AU1XXX_PHY_STATIC_CONFIG) |
713 | # if defined(AU1XXX_PHY0_IRQ) | 717 | # if defined(AU1XXX_PHY0_IRQ) |
714 | if (AU1XXX_PHY0_BUSID == aup->mac_id) | 718 | if (AU1XXX_PHY0_BUSID == aup->mac_id) |
715 | aup->mii_bus.irq[AU1XXX_PHY0_ADDR] = AU1XXX_PHY0_IRQ; | 719 | aup->mii_bus->irq[AU1XXX_PHY0_ADDR] = AU1XXX_PHY0_IRQ; |
716 | # endif | 720 | # endif |
717 | # if defined(AU1XXX_PHY1_IRQ) | 721 | # if defined(AU1XXX_PHY1_IRQ) |
718 | if (AU1XXX_PHY1_BUSID == aup->mac_id) | 722 | if (AU1XXX_PHY1_BUSID == aup->mac_id) |
719 | aup->mii_bus.irq[AU1XXX_PHY1_ADDR] = AU1XXX_PHY1_IRQ; | 723 | aup->mii_bus->irq[AU1XXX_PHY1_ADDR] = AU1XXX_PHY1_IRQ; |
720 | # endif | 724 | # endif |
721 | #endif | 725 | #endif |
722 | mdiobus_register(&aup->mii_bus); | 726 | mdiobus_register(aup->mii_bus); |
723 | 727 | ||
724 | if (mii_probe(dev) != 0) { | 728 | if (mii_probe(dev) != 0) { |
725 | goto err_out; | 729 | goto err_out; |
@@ -775,6 +779,11 @@ static struct net_device * au1000_probe(int port_num) | |||
775 | return dev; | 779 | return dev; |
776 | 780 | ||
777 | err_out: | 781 | err_out: |
782 | if (aup->mii_bus != NULL) { | ||
783 | mdiobus_unregister(aup->mii_bus); | ||
784 | mdiobus_free(aup->mii_bus); | ||
785 | } | ||
786 | |||
778 | /* here we should have a valid dev plus aup-> register addresses | 787 | /* here we should have a valid dev plus aup-> register addresses |
779 | * so we can reset the mac properly.*/ | 788 | * so we can reset the mac properly.*/ |
780 | reset_mac(dev); | 789 | reset_mac(dev); |
@@ -1005,6 +1014,8 @@ static void __exit au1000_cleanup_module(void) | |||
1005 | if (dev) { | 1014 | if (dev) { |
1006 | aup = (struct au1000_private *) dev->priv; | 1015 | aup = (struct au1000_private *) dev->priv; |
1007 | unregister_netdev(dev); | 1016 | unregister_netdev(dev); |
1017 | mdiobus_unregister(aup->mii_bus); | ||
1018 | mdiobus_free(aup->mii_bus); | ||
1008 | for (j = 0; j < NUM_RX_DMA; j++) | 1019 | for (j = 0; j < NUM_RX_DMA; j++) |
1009 | if (aup->rx_db_inuse[j]) | 1020 | if (aup->rx_db_inuse[j]) |
1010 | ReleaseDB(aup, aup->rx_db_inuse[j]); | 1021 | ReleaseDB(aup, aup->rx_db_inuse[j]); |