[brcm-2.4] update kernel to version 2.4.37.9 and refresh patches
[openwrt.git] / target / linux / ar7 / patches-2.6.30 / 910-cpmac_fixed_phy.patch
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.
6
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)
11 {
12 int rc, phy_id;
13 - char *mdio_bus_id = "0";
14 + char mdio_bus_id[BUS_ID_SIZE];
15 struct resource *mem;
16 struct cpmac_priv *priv;
17 struct net_device *dev;
18 @@ -1104,22 +1104,23 @@ static int __devinit cpmac_probe(struct
19
20 pdata = pdev->dev.platform_data;
21
22 - for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
23 - if (!(pdata->phy_mask & (1 << phy_id)))
24 - continue;
25 - if (!cpmac_mii->phy_map[phy_id])
26 - continue;
27 - break;
28 + if (external_switch || dumb_switch) {
29 + strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
30 + phy_id = pdev->id;
31 + } else {
32 + for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
33 + if (!(pdata->phy_mask & (1 << phy_id)))
34 + continue;
35 + if (!cpmac_mii->phy_map[phy_id])
36 + continue;
37 + strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE);
38 + break;
39 + }
40 }
41
42 if (phy_id == PHY_MAX_ADDR) {
43 - if (external_switch || dumb_switch) {
44 - mdio_bus_id = 0; /* fixed phys bus */
45 - phy_id = pdev->id;
46 - } else {
47 - dev_err(&pdev->dev, "no PHY present\n");
48 - return -ENODEV;
49 - }
50 + dev_err(&pdev->dev, "no PHY present\n");
51 + return -ENODEV;
52 }
53
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));
58
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);
62 +
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)
69
70 cpmac_mii->reset(cpmac_mii);
71
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)))
75 break;
76 else
77 - cpu_relax();
78 + msleep(10);
79
80 mask &= 0x7fffffff;
81 if (mask & (mask - 1)) {
82 @@ -1248,7 +1251,7 @@ int __devinit cpmac_init(void)
83 }
84
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");
88
89 res = mdiobus_register(cpmac_mii);
90 if (res)
This page took 0.043417 seconds and 5 git commands to generate.