platform specific patches don't belong here - take #2
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-2.6.37 / 210-b44_phy_fix.patch
1 --- a/drivers/net/b44.c
2 +++ b/drivers/net/b44.c
3 @@ -411,10 +411,41 @@ static void b44_wap54g10_workaround(stru
4 error:
5 pr_warning("PHY: cannot reset MII transceiver isolate bit\n");
6 }
7 +
8 +static inline int startswith (const char *source, const char *cmp)
9 +{
10 + return !strncmp(source,cmp,strlen(cmp));
11 +}
12 +
13 +static inline void b44_bcm47xx_workarounds(struct b44 *bp)
14 +{
15 + char buf[20];
16 + /* Toshiba WRC-1000, Siemens SE505 v1, Askey RT-210W, RT-220W */
17 + if (nvram_getenv("boardnum", buf, sizeof(buf)) > 0)
18 + return;
19 + if (simple_strtoul(buf, NULL, 0) == 100) {
20 + bp->phy_addr = B44_PHY_ADDR_NO_PHY;
21 + } else {
22 + /* WL-HDD */
23 + struct ssb_device *sdev = bp->sdev;
24 + if (nvram_getenv("hardware_version", buf, sizeof(buf)) > 0)
25 + return;
26 + if (startswith(buf, "WL300-")) {
27 + if (sdev->bus->sprom.et0phyaddr == 0 &&
28 + sdev->bus->sprom.et1phyaddr == 1)
29 + bp->phy_addr = B44_PHY_ADDR_NO_PHY;
30 + }
31 + }
32 + return;
33 +}
34 #else
35 static inline void b44_wap54g10_workaround(struct b44 *bp)
36 {
37 }
38 +
39 +static inline void b44_bcm47xx_workarounds(struct b44 *bp)
40 +{
41 +}
42 #endif
43
44 static int b44_setup_phy(struct b44 *bp)
45 @@ -423,6 +454,7 @@ static int b44_setup_phy(struct b44 *bp)
46 int err;
47
48 b44_wap54g10_workaround(bp);
49 + b44_bcm47xx_workarounds(bp);
50
51 if (bp->phy_addr == B44_PHY_ADDR_NO_PHY)
52 return 0;
53 @@ -2088,6 +2120,8 @@ static int __devinit b44_get_invariants(
54 * valid PHY address. */
55 bp->phy_addr &= 0x1F;
56
57 + b44_bcm47xx_workarounds(bp);
58 +
59 memcpy(bp->dev->dev_addr, addr, 6);
60
61 if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){