ar71xx: change PHY select logic, and update phy_masks

SVN-Revision: 20358
This commit is contained in:
Gabor Juhos
2010-03-21 18:16:07 +00:00
parent 479ff12fae
commit 9a1031ce6d
22 changed files with 41 additions and 82 deletions

View File

@@ -38,7 +38,7 @@
#define ETH_FCS_LEN 4
#define AG71XX_DRV_NAME "ag71xx"
#define AG71XX_DRV_VERSION "0.5.32"
#define AG71XX_DRV_VERSION "0.5.33"
#define AG71XX_NAPI_WEIGHT 64
#define AG71XX_OOM_REFILL (1 + HZ/10)

View File

@@ -47,10 +47,6 @@ void ag71xx_phy_start(struct ag71xx *ag)
if (ag->phy_dev) {
phy_start(ag->phy_dev);
} else {
struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
ag->duplex = pdata->duplex;
ag->speed = pdata->speed;
ag->link = 1;
ag71xx_link_adjust(ag);
}
@@ -61,9 +57,7 @@ void ag71xx_phy_stop(struct ag71xx *ag)
if (ag->phy_dev) {
phy_stop(ag->phy_dev);
} else {
ag->duplex = -1;
ag->link = 0;
ag->speed = 0;
ag71xx_link_adjust(ag);
}
}
@@ -81,12 +75,16 @@ static int ag71xx_phy_connect_fixed(struct ag71xx *ag)
case SPEED_1000:
break;
default:
printk(KERN_ERR "%s: invalid speed specified\n",
dev->name);
printk(KERN_ERR "%s: invalid speed specified\n", dev->name);
ret = -EINVAL;
break;
}
printk(KERN_DEBUG "%s: using fixed link parameters\n", dev->name);
ag->duplex = pdata->duplex;
ag->speed = pdata->speed;
return ret;
}
@@ -95,7 +93,6 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
struct net_device *dev = ag->dev;
struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
struct phy_device *phydev = NULL;
int phy_count = 0;
int phy_addr;
int ret = 0;
@@ -113,51 +110,40 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
if (phydev == NULL)
phydev = ag->mii_bus->phy_map[phy_addr];
phy_count++;
}
switch (phy_count) {
case 0:
if (!phydev) {
printk(KERN_ERR "%s: no PHY found with phy_mask=%08x\n",
dev->name, pdata->phy_mask);
ret = -ENODEV;
break;
case 1:
ag->phy_dev = phy_connect(dev, dev_name(&phydev->dev),
&ag71xx_phy_link_adjust, 0, pdata->phy_if_mode);
if (IS_ERR(ag->phy_dev)) {
printk(KERN_ERR "%s: could not connect to PHY at %s\n",
dev->name, dev_name(&phydev->dev));
return PTR_ERR(ag->phy_dev);
}
/* mask with MAC supported features */
if (pdata->has_gbit)
phydev->supported &= PHY_GBIT_FEATURES;
else
phydev->supported &= PHY_BASIC_FEATURES;
phydev->advertising = phydev->supported;
printk(KERN_DEBUG "%s: connected to PHY at %s "
"[uid=%08x, driver=%s]\n",
dev->name, dev_name(&phydev->dev),
phydev->phy_id, phydev->drv->name);
ag->link = 0;
ag->speed = 0;
ag->duplex = -1;
break;
default:
printk(KERN_DEBUG "%s: connected to %d PHYs\n",
dev->name, phy_count);
ret = ag71xx_phy_connect_fixed(ag);
break;
return -ENODEV;
}
ag->phy_dev = phy_connect(dev, dev_name(&phydev->dev),
&ag71xx_phy_link_adjust, 0,
pdata->phy_if_mode);
if (IS_ERR(ag->phy_dev)) {
printk(KERN_ERR "%s: could not connect to PHY at %s\n",
dev->name, dev_name(&phydev->dev));
return PTR_ERR(ag->phy_dev);
}
/* mask with MAC supported features */
if (pdata->has_gbit)
phydev->supported &= PHY_GBIT_FEATURES;
else
phydev->supported &= PHY_BASIC_FEATURES;
phydev->advertising = phydev->supported;
printk(KERN_DEBUG "%s: connected to PHY at %s [uid=%08x, driver=%s]\n",
dev->name, dev_name(&phydev->dev),
phydev->phy_id, phydev->drv->name);
ag->link = 0;
ag->speed = 0;
ag->duplex = -1;
return ret;
}