diff options
Diffstat (limited to 'drivers/net/au1000_eth.c')
-rw-r--r-- | drivers/net/au1000_eth.c | 103 |
1 files changed, 57 insertions, 46 deletions
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index df3eee11cd95..a2d86cf62760 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -357,6 +357,7 @@ static int au1000_mii_probe(struct net_device *dev) | |||
357 | { | 357 | { |
358 | struct au1000_private *const aup = netdev_priv(dev); | 358 | struct au1000_private *const aup = netdev_priv(dev); |
359 | struct phy_device *phydev = NULL; | 359 | struct phy_device *phydev = NULL; |
360 | int phy_addr; | ||
360 | 361 | ||
361 | if (aup->phy_static_config) { | 362 | if (aup->phy_static_config) { |
362 | BUG_ON(aup->mac_id < 0 || aup->mac_id > 1); | 363 | BUG_ON(aup->mac_id < 0 || aup->mac_id > 1); |
@@ -366,42 +367,45 @@ static int au1000_mii_probe(struct net_device *dev) | |||
366 | else | 367 | else |
367 | netdev_info(dev, "using PHY-less setup\n"); | 368 | netdev_info(dev, "using PHY-less setup\n"); |
368 | return 0; | 369 | return 0; |
369 | } else { | 370 | } |
370 | int phy_addr; | ||
371 | |||
372 | /* find the first (lowest address) PHY on the current MAC's MII bus */ | ||
373 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) | ||
374 | if (aup->mii_bus->phy_map[phy_addr]) { | ||
375 | phydev = aup->mii_bus->phy_map[phy_addr]; | ||
376 | if (!aup->phy_search_highest_addr) | ||
377 | break; /* break out with first one found */ | ||
378 | } | ||
379 | |||
380 | if (aup->phy1_search_mac0) { | ||
381 | /* try harder to find a PHY */ | ||
382 | if (!phydev && (aup->mac_id == 1)) { | ||
383 | /* no PHY found, maybe we have a dual PHY? */ | ||
384 | dev_info(&dev->dev, ": no PHY found on MAC1, " | ||
385 | "let's see if it's attached to MAC0...\n"); | ||
386 | |||
387 | /* find the first (lowest address) non-attached PHY on | ||
388 | * the MAC0 MII bus */ | ||
389 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { | ||
390 | struct phy_device *const tmp_phydev = | ||
391 | aup->mii_bus->phy_map[phy_addr]; | ||
392 | |||
393 | if (aup->mac_id == 1) | ||
394 | break; | ||
395 | |||
396 | if (!tmp_phydev) | ||
397 | continue; /* no PHY here... */ | ||
398 | 371 | ||
399 | if (tmp_phydev->attached_dev) | 372 | /* find the first (lowest address) PHY |
400 | continue; /* already claimed by MAC0 */ | 373 | * on the current MAC's MII bus */ |
374 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) | ||
375 | if (aup->mii_bus->phy_map[phy_addr]) { | ||
376 | phydev = aup->mii_bus->phy_map[phy_addr]; | ||
377 | if (!aup->phy_search_highest_addr) | ||
378 | /* break out with first one found */ | ||
379 | break; | ||
380 | } | ||
401 | 381 | ||
402 | phydev = tmp_phydev; | 382 | if (aup->phy1_search_mac0) { |
403 | break; /* found it */ | 383 | /* try harder to find a PHY */ |
404 | } | 384 | if (!phydev && (aup->mac_id == 1)) { |
385 | /* no PHY found, maybe we have a dual PHY? */ | ||
386 | dev_info(&dev->dev, ": no PHY found on MAC1, " | ||
387 | "let's see if it's attached to MAC0...\n"); | ||
388 | |||
389 | /* find the first (lowest address) non-attached | ||
390 | * PHY on the MAC0 MII bus | ||
391 | */ | ||
392 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { | ||
393 | struct phy_device *const tmp_phydev = | ||
394 | aup->mii_bus->phy_map[phy_addr]; | ||
395 | |||
396 | if (aup->mac_id == 1) | ||
397 | break; | ||
398 | |||
399 | /* no PHY here... */ | ||
400 | if (!tmp_phydev) | ||
401 | continue; | ||
402 | |||
403 | /* already claimed by MAC0 */ | ||
404 | if (tmp_phydev->attached_dev) | ||
405 | continue; | ||
406 | |||
407 | phydev = tmp_phydev; | ||
408 | break; /* found it */ | ||
405 | } | 409 | } |
406 | } | 410 | } |
407 | } | 411 | } |
@@ -524,11 +528,13 @@ au1000_setup_hw_rings(struct au1000_private *aup, u32 rx_base, u32 tx_base) | |||
524 | 528 | ||
525 | for (i = 0; i < NUM_RX_DMA; i++) { | 529 | for (i = 0; i < NUM_RX_DMA; i++) { |
526 | aup->rx_dma_ring[i] = | 530 | aup->rx_dma_ring[i] = |
527 | (volatile struct rx_dma *) (rx_base + sizeof(struct rx_dma)*i); | 531 | (volatile struct rx_dma *) |
532 | (rx_base + sizeof(struct rx_dma)*i); | ||
528 | } | 533 | } |
529 | for (i = 0; i < NUM_TX_DMA; i++) { | 534 | for (i = 0; i < NUM_TX_DMA; i++) { |
530 | aup->tx_dma_ring[i] = | 535 | aup->tx_dma_ring[i] = |
531 | (volatile struct tx_dma *) (tx_base + sizeof(struct tx_dma)*i); | 536 | (volatile struct tx_dma *) |
537 | (tx_base + sizeof(struct tx_dma)*i); | ||
532 | } | 538 | } |
533 | } | 539 | } |
534 | 540 | ||
@@ -625,6 +631,7 @@ static int au1000_init(struct net_device *dev) | |||
625 | aup->mac->mac_addr_low = dev->dev_addr[3]<<24 | dev->dev_addr[2]<<16 | | 631 | aup->mac->mac_addr_low = dev->dev_addr[3]<<24 | dev->dev_addr[2]<<16 | |
626 | dev->dev_addr[1]<<8 | dev->dev_addr[0]; | 632 | dev->dev_addr[1]<<8 | dev->dev_addr[0]; |
627 | 633 | ||
634 | |||
628 | for (i = 0; i < NUM_RX_DMA; i++) | 635 | for (i = 0; i < NUM_RX_DMA; i++) |
629 | aup->rx_dma_ring[i]->buff_stat |= RX_DMA_ENABLE; | 636 | aup->rx_dma_ring[i]->buff_stat |= RX_DMA_ENABLE; |
630 | 637 | ||
@@ -936,8 +943,7 @@ static void au1000_multicast_list(struct net_device *dev) | |||
936 | { | 943 | { |
937 | struct au1000_private *aup = netdev_priv(dev); | 944 | struct au1000_private *aup = netdev_priv(dev); |
938 | 945 | ||
939 | netif_dbg(aup, drv, dev, "au1000_multicast_list: flags=%x\n", dev->flags); | 946 | netif_dbg(aup, drv, dev, "%s: flags=%x\n", __func__, dev->flags); |
940 | |||
941 | if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ | 947 | if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ |
942 | aup->mac->control |= MAC_PROMISCUOUS; | 948 | aup->mac->control |= MAC_PROMISCUOUS; |
943 | } else if ((dev->flags & IFF_ALLMULTI) || | 949 | } else if ((dev->flags & IFF_ALLMULTI) || |
@@ -1016,13 +1022,15 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1016 | goto out; | 1022 | goto out; |
1017 | } | 1023 | } |
1018 | 1024 | ||
1019 | if (!request_mem_region(base->start, resource_size(base), pdev->name)) { | 1025 | if (!request_mem_region(base->start, resource_size(base), |
1026 | pdev->name)) { | ||
1020 | dev_err(&pdev->dev, "failed to request memory region for base registers\n"); | 1027 | dev_err(&pdev->dev, "failed to request memory region for base registers\n"); |
1021 | err = -ENXIO; | 1028 | err = -ENXIO; |
1022 | goto out; | 1029 | goto out; |
1023 | } | 1030 | } |
1024 | 1031 | ||
1025 | if (!request_mem_region(macen->start, resource_size(macen), pdev->name)) { | 1032 | if (!request_mem_region(macen->start, resource_size(macen), |
1033 | pdev->name)) { | ||
1026 | dev_err(&pdev->dev, "failed to request memory region for MAC enable register\n"); | 1034 | dev_err(&pdev->dev, "failed to request memory region for MAC enable register\n"); |
1027 | err = -ENXIO; | 1035 | err = -ENXIO; |
1028 | goto err_request; | 1036 | goto err_request; |
@@ -1040,7 +1048,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1040 | aup = netdev_priv(dev); | 1048 | aup = netdev_priv(dev); |
1041 | 1049 | ||
1042 | spin_lock_init(&aup->lock); | 1050 | spin_lock_init(&aup->lock); |
1043 | aup->msg_enable = (au1000_debug < 4 ? AU1000_DEF_MSG_ENABLE : au1000_debug); | 1051 | aup->msg_enable = (au1000_debug < 4 ? |
1052 | AU1000_DEF_MSG_ENABLE : au1000_debug); | ||
1044 | 1053 | ||
1045 | /* Allocate the data buffers */ | 1054 | /* Allocate the data buffers */ |
1046 | /* Snooping works fine with eth on all au1xxx */ | 1055 | /* Snooping works fine with eth on all au1xxx */ |
@@ -1054,7 +1063,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1054 | } | 1063 | } |
1055 | 1064 | ||
1056 | /* aup->mac is the base address of the MAC's registers */ | 1065 | /* aup->mac is the base address of the MAC's registers */ |
1057 | aup->mac = (volatile struct mac_reg *)ioremap_nocache(base->start, resource_size(base)); | 1066 | aup->mac = (volatile struct mac_reg *) |
1067 | ioremap_nocache(base->start, resource_size(base)); | ||
1058 | if (!aup->mac) { | 1068 | if (!aup->mac) { |
1059 | dev_err(&pdev->dev, "failed to ioremap MAC registers\n"); | 1069 | dev_err(&pdev->dev, "failed to ioremap MAC registers\n"); |
1060 | err = -ENXIO; | 1070 | err = -ENXIO; |
@@ -1062,7 +1072,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1062 | } | 1072 | } |
1063 | 1073 | ||
1064 | /* Setup some variables for quick register address access */ | 1074 | /* Setup some variables for quick register address access */ |
1065 | aup->enable = (volatile u32 *)ioremap_nocache(macen->start, resource_size(macen)); | 1075 | aup->enable = (volatile u32 *)ioremap_nocache(macen->start, |
1076 | resource_size(macen)); | ||
1066 | if (!aup->enable) { | 1077 | if (!aup->enable) { |
1067 | dev_err(&pdev->dev, "failed to ioremap MAC enable register\n"); | 1078 | dev_err(&pdev->dev, "failed to ioremap MAC enable register\n"); |
1068 | err = -ENXIO; | 1079 | err = -ENXIO; |
@@ -1083,7 +1094,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1083 | 1094 | ||
1084 | pd = pdev->dev.platform_data; | 1095 | pd = pdev->dev.platform_data; |
1085 | if (!pd) { | 1096 | if (!pd) { |
1086 | dev_info(&pdev->dev, "no platform_data passed, PHY search on MAC0\n"); | 1097 | dev_info(&pdev->dev, "no platform_data passed," |
1098 | " PHY search on MAC0\n"); | ||
1087 | aup->phy1_search_mac0 = 1; | 1099 | aup->phy1_search_mac0 = 1; |
1088 | } else { | 1100 | } else { |
1089 | if (is_valid_ether_addr(pd->mac)) | 1101 | if (is_valid_ether_addr(pd->mac)) |
@@ -1098,8 +1110,7 @@ static int __devinit au1000_probe(struct platform_device *pdev) | |||
1098 | } | 1110 | } |
1099 | 1111 | ||
1100 | if (aup->phy_busid && aup->phy_busid > 0) { | 1112 | if (aup->phy_busid && aup->phy_busid > 0) { |
1101 | dev_err(&pdev->dev, "MAC0-associated PHY attached 2nd MACs MII" | 1113 | dev_err(&pdev->dev, "MAC0-associated PHY attached 2nd MACs MII bus not supported yet\n"); |
1102 | "bus not supported yet\n"); | ||
1103 | err = -ENODEV; | 1114 | err = -ENODEV; |
1104 | goto err_mdiobus_alloc; | 1115 | goto err_mdiobus_alloc; |
1105 | } | 1116 | } |