atheros: 2.6.32 support
[openwrt/staging/chunkeey.git] / target / linux / atheros / patches-2.6.32 / 220-enet_micrel_workaround.patch
1 Index: linux-2.6.32.7/drivers/net/ar231x.c
2 ===================================================================
3 --- linux-2.6.32.7.orig/drivers/net/ar231x.c 2010-02-03 17:02:28.998430523 +0100
4 +++ linux-2.6.32.7/drivers/net/ar231x.c 2010-02-03 17:03:01.346429245 +0100
5 @@ -148,6 +148,7 @@
6 static int ar231x_mdiobus_reset(struct mii_bus *bus);
7 static int ar231x_mdiobus_probe (struct net_device *dev);
8 static void ar231x_adjust_link(struct net_device *dev);
9 +static bool no_phy = false;
10
11 #ifndef ERR
12 #define ERR(fmt, args...) printk("%s: " fmt, __func__, ##args)
13 @@ -278,6 +279,21 @@
14
15 mdiobus_register(sp->mii_bus);
16
17 + /* Workaround for Micrel switch, which is only available on
18 + * one PHY and cannot be configured through MDIO */
19 + if (!no_phy) {
20 + u32 phy_id = 0;
21 + get_phy_id(sp->mii_bus, 1, &phy_id);
22 + if (phy_id == 0x00221450)
23 + no_phy = true;
24 + }
25 + if (no_phy) {
26 + sp->link = 1;
27 + netif_carrier_on(dev);
28 + return 0;
29 + }
30 + no_phy = true;
31 +
32 if (ar231x_mdiobus_probe(dev) != 0) {
33 printk(KERN_ERR "%s: mdiobus_probe failed\n", dev->name);
34 rx_tasklet_cleanup(dev);
35 @@ -334,8 +350,10 @@
36 rx_tasklet_cleanup(dev);
37 ar231x_init_cleanup(dev);
38 unregister_netdev(dev);
39 - mdiobus_unregister(sp->mii_bus);
40 - mdiobus_free(sp->mii_bus);
41 + if (sp->mii_bus) {
42 + mdiobus_unregister(sp->mii_bus);
43 + mdiobus_free(sp->mii_bus);
44 + }
45 kfree(dev);
46 return 0;
47 }
48 @@ -836,7 +854,12 @@
49 dev->stats.rx_bytes += skb->len;
50
51 /* pass the packet to upper layers */
52 - sp->rx(skb);
53 + if (sp->rx) {
54 + sp->rx(skb);
55 + } else {
56 + skb->protocol = eth_type_trans(skb, skb->dev);
57 + netif_rx(skb);
58 + }
59 skb_new->dev = dev;
60
61 /* 16 bit align */
62 @@ -1123,6 +1146,9 @@
63 struct ar231x_private *sp = netdev_priv(dev);
64 int ret;
65
66 + if (!sp->phy_dev)
67 + return -ENODEV;
68 +
69 switch (cmd) {
70
71 case SIOCETHTOOL: