1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-05 12:30:38 +02:00
openwrt-xburst/target/linux/ar7/patches-2.6.27/910-cpmac_fixed_phy.patch
florian c87639a675 [ar7] add back the fixed PHY patches from #3124, until we move this to platform_data
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@17107 3c298f89-4303-0410-b956-a3cf2f4a3e73
2009-08-03 18:51:03 +00:00

93 lines
2.7 KiB
Diff

This is a hack to make cpmac work with the external switch on a DG834 v3; it
should also work on other similar routers. It has not been tested on hardware
with multiple cpmac devices or with no external switch. It may be safer to
move external_switch to pdata rather than trying to detect it, and to set
phy_mask correctly rather than moving the phy search loop.
--- a/drivers/net/cpmac.c 2008-11-11 06:18:24.000000000 +1100
+++ b/drivers/net/cpmac.c 2009-04-11 10:58:58.000000000 +1000
@@ -1124,8 +1124,8 @@
static int __devinit cpmac_probe(struct platform_device *pdev)
{
int rc, phy_id;
- char *mdio_bus_id = "0";
+ char mdio_bus_id[BUS_ID_SIZE];
struct resource *mem;
struct cpmac_priv *priv;
struct net_device *dev;
@@ -1134,22 +1134,23 @@
pdata = pdev->dev.platform_data;
- for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
- if (!(pdata->phy_mask & (1 << phy_id)))
- continue;
- if (!cpmac_mii.phy_map[phy_id])
- continue;
- break;
+ if (external_switch || dumb_switch) {
+ strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
+ phy_id = pdev->id;
+ } else {
+ for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
+ if (!(pdata->phy_mask & (1 << phy_id)))
+ continue;
+ if (!cpmac_mii.phy_map[phy_id])
+ continue;
+ strncpy(mdio_bus_id, cpmac_mii.id, BUS_ID_SIZE);
+ break;
+ }
}
if (phy_id == PHY_MAX_ADDR) {
- if (external_switch || dumb_switch) {
- mdio_bus_id = 0; /* fixed phys bus */
- phy_id = pdev->id;
- } else {
- dev_err(&pdev->dev, "no PHY present\n");
- return -ENODEV;
- }
+ dev_err(&pdev->dev, "no PHY present\n");
+ return -ENODEV;
}
#ifdef CONFIG_NETDEVICES_MULTIQUEUE
@@ -1189,9 +1190,11 @@
priv->ring_size = 64;
priv->msg_enable = netif_msg_init(debug_level, 0xff);
memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
+
+ snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
- priv->phy = phy_connect(dev, cpmac_mii.phy_map[phy_id]->dev.bus_id,
- &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII);
+ priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
+ PHY_INTERFACE_MODE_MII);
if (IS_ERR(priv->phy)) {
if (netif_msg_drv(priv))
printk(KERN_ERR "%s: Could not attach to PHY\n",
@@ -1250,11 +1253,11 @@
cpmac_mii.reset(&cpmac_mii);
- for (i = 0; i < 300000; i++)
+ for (i = 0; i < 300; i++)
if ((mask = cpmac_read(cpmac_mii.priv, CPMAC_MDIO_ALIVE)))
break;
else
- cpu_relax();
+ msleep(10);
mask &= 0x7fffffff;
if (mask & (mask - 1)) {
@@ -1267,7 +1270,7 @@
}
cpmac_mii.phy_mask = ~(mask | 0x80000000);
- snprintf(cpmac_mii.id, MII_BUS_ID_SIZE, "0");
+ snprintf(cpmac_mii.id, MII_BUS_ID_SIZE, "1");
res = mdiobus_register(&cpmac_mii);
if (res)