Root/target/linux/atheros/patches-3.3/220-enet_micrel_workaround.patch

1--- a/drivers/net/ethernet/ar231x/ar231x.c
2+++ b/drivers/net/ethernet/ar231x/ar231x.c
3@@ -151,6 +151,7 @@ static int ar231x_mdiobus_write(struct m
4 static int ar231x_mdiobus_reset(struct mii_bus *bus);
5 static int ar231x_mdiobus_probe (struct net_device *dev);
6 static void ar231x_adjust_link(struct net_device *dev);
7+static bool no_phy = false;
8 
9 #ifndef ERR
10 #define ERR(fmt, args...) printk("%s: " fmt, __func__, ##args)
11@@ -300,6 +301,21 @@ int __devinit ar231x_probe(struct platfo
12 
13     mdiobus_register(sp->mii_bus);
14 
15+ /* Workaround for Micrel switch, which is only available on
16+ * one PHY and cannot be configured through MDIO */
17+ if (!no_phy) {
18+ u32 phy_id = 0;
19+ get_phy_id(sp->mii_bus, 1, &phy_id);
20+ if (phy_id == 0x00221450)
21+ no_phy = true;
22+ }
23+ if (no_phy) {
24+ sp->link = 1;
25+ netif_carrier_on(dev);
26+ return 0;
27+ }
28+ no_phy = true;
29+
30     if (ar231x_mdiobus_probe(dev) != 0) {
31         printk(KERN_ERR "%s: mdiobus_probe failed\n", dev->name);
32         rx_tasklet_cleanup(dev);
33@@ -356,8 +372,10 @@ static int __devexit ar231x_remove(struc
34     rx_tasklet_cleanup(dev);
35     ar231x_init_cleanup(dev);
36     unregister_netdev(dev);
37- mdiobus_unregister(sp->mii_bus);
38- mdiobus_free(sp->mii_bus);
39+ if (sp->mii_bus) {
40+ mdiobus_unregister(sp->mii_bus);
41+ mdiobus_free(sp->mii_bus);
42+ }
43     kfree(dev);
44     return 0;
45 }
46@@ -1133,6 +1151,9 @@ static int ar231x_ioctl(struct net_devic
47     struct ar231x_private *sp = netdev_priv(dev);
48     int ret;
49 
50+ if (!sp->phy_dev)
51+ return -ENODEV;
52+
53     switch (cmd) {
54 
55     case SIOCETHTOOL:
56

Archive Download this file



interactive