mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2024-11-20 07:24:36 +01:00
25b42557da
SVN-Revision: 17110
91 lines
2.8 KiB
Diff
91 lines
2.8 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
|
|
+++ b/drivers/net/cpmac.c
|
|
@@ -1096,7 +1096,7 @@ static int external_switch;
|
|
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;
|
|
@@ -1104,22 +1104,23 @@ static int __devinit cpmac_probe(struct
|
|
|
|
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;
|
|
}
|
|
|
|
dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
|
|
@@ -1160,8 +1161,10 @@ static int __devinit cpmac_probe(struct
|
|
priv->msg_enable = netif_msg_init(debug_level, 0xff);
|
|
memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
|
|
|
|
- priv->phy = phy_connect(dev, dev_name(&cpmac_mii->phy_map[phy_id]->dev),
|
|
- &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII);
|
|
+ snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
|
|
+
|
|
+ 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",
|
|
@@ -1235,11 +1238,11 @@ int __devinit cpmac_init(void)
|
|
|
|
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)) {
|
|
@@ -1248,7 +1251,7 @@ int __devinit cpmac_init(void)
|
|
}
|
|
|
|
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)
|