1 This is a hack to make cpmac work with the external switch on a DG834 v3; it
2 should also work on other similar routers. It has not been tested on hardware
3 with multiple cpmac devices or with no external switch. It may be safer to
4 move external_switch to pdata rather than trying to detect it, and to set
5 phy_mask correctly rather than moving the phy search loop.
7 --- a/drivers/net/cpmac.c
8 +++ b/drivers/net/cpmac.c
9 @@ -1096,7 +1096,7 @@ static int external_switch;
10 static int __devinit cpmac_probe(struct platform_device *pdev)
13 - char *mdio_bus_id = "0";
14 + char mdio_bus_id[BUS_ID_SIZE];
16 struct cpmac_priv *priv;
17 struct net_device *dev;
18 @@ -1104,22 +1104,23 @@ static int __devinit cpmac_probe(struct
20 pdata = pdev->dev.platform_data;
22 - for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
23 - if (!(pdata->phy_mask & (1 << phy_id)))
25 - if (!cpmac_mii->phy_map[phy_id])
28 + if (external_switch || dumb_switch) {
29 + strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
32 + for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
33 + if (!(pdata->phy_mask & (1 << phy_id)))
35 + if (!cpmac_mii->phy_map[phy_id])
37 + strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE);
42 if (phy_id == PHY_MAX_ADDR) {
43 - if (external_switch || dumb_switch) {
44 - mdio_bus_id = 0; /* fixed phys bus */
47 - dev_err(&pdev->dev, "no PHY present\n");
50 + dev_err(&pdev->dev, "no PHY present\n");
54 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
55 @@ -1160,8 +1161,10 @@ static int __devinit cpmac_probe(struct
56 priv->msg_enable = netif_msg_init(debug_level, 0xff);
57 memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
59 - priv->phy = phy_connect(dev, dev_name(&cpmac_mii->phy_map[phy_id]->dev),
60 - &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII);
61 + snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
63 + priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
64 + PHY_INTERFACE_MODE_MII);
65 if (IS_ERR(priv->phy)) {
66 if (netif_msg_drv(priv))
67 printk(KERN_ERR "%s: Could not attach to PHY\n",
68 @@ -1235,11 +1238,11 @@ int __devinit cpmac_init(void)
70 cpmac_mii->reset(cpmac_mii);
72 - for (i = 0; i < 300000; i++)
73 + for (i = 0; i < 300; i++)
74 if ((mask = cpmac_read(cpmac_mii->priv, CPMAC_MDIO_ALIVE)))
81 if (mask & (mask - 1)) {
82 @@ -1248,7 +1251,7 @@ int __devinit cpmac_init(void)
85 cpmac_mii->phy_mask = ~(mask | 0x80000000);
86 - snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "0");
87 + snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "1");
89 res = mdiobus_register(cpmac_mii);