summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-03-21 18:16:07 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-03-21 18:16:07 +0000
commite6e930942664682d11abe4ad7ccd0bada1afecfa (patch)
tree7ca4622e6ab89a32d5f1261e10b04f00c9411b09 /target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c
parenta27a0f0fe52cf674b810e01f9e888067fd8bad87 (diff)
ar71xx: change PHY select logic, and update phy_masks
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20358 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c')
-rw-r--r--target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c74
1 files changed, 30 insertions, 44 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c
index 4425b740e5..9c76544aff 100644
--- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c
+++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c
@@ -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,50 +110,39 @@ 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);
- }
+ return -ENODEV;
+ }
- /* mask with MAC supported features */
- if (pdata->has_gbit)
- phydev->supported &= PHY_GBIT_FEATURES;
- else
- phydev->supported &= PHY_BASIC_FEATURES;
+ ag->phy_dev = phy_connect(dev, dev_name(&phydev->dev),
+ &ag71xx_phy_link_adjust, 0,
+ pdata->phy_if_mode);
- phydev->advertising = phydev->supported;
+ 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);
+ }
- 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);
+ /* mask with MAC supported features */
+ if (pdata->has_gbit)
+ phydev->supported &= PHY_GBIT_FEATURES;
+ else
+ phydev->supported &= PHY_BASIC_FEATURES;
- ag->link = 0;
- ag->speed = 0;
- ag->duplex = -1;
- break;
+ phydev->advertising = phydev->supported;
- default:
- printk(KERN_DEBUG "%s: connected to %d PHYs\n",
- dev->name, phy_count);
- ret = ag71xx_phy_connect_fixed(ag);
- break;
- }
+ 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;
}