brcm47xx: fix ethernet link state (closes #7056)
[librecmc/librecmc.git] / target / linux / brcm47xx / patches-2.6.34 / 210-b44_phy_fix.patch
1 --- drivers/net/b44.c.orig      2010-04-18 08:40:30.000000000 +0300
2 +++ drivers/net/b44.c   2010-04-18 10:53:47.000000000 +0300
3 @@ -384,7 +384,7 @@
4         __b44_set_flow_ctrl(bp, pause_enab);
5  }
6  
7 -#ifdef SSB_DRIVER_MIPS
8 +#ifdef CONFIG_SSB_DRIVER_MIPS
9  extern char *nvram_get(char *name);
10  static void b44_wap54g10_workaround(struct b44 *bp)
11  {
12 @@ -397,6 +397,7 @@
13          * see https://dev.openwrt.org/ticket/146
14          * check and reset bit "isolate"
15          */
16 +
17         str = nvram_get("boardnum");
18         if (!str)
19                 return;
20 @@ -421,12 +422,49 @@
21  }
22  #endif
23  
24 +#ifdef CONFIG_SSB_DRIVER_MIPS
25 +static inline int startswith (const char *source, const char *cmp) 
26 +{ 
27 +       return !strncmp(source,cmp,strlen(cmp)); 
28 +}
29 +
30 +#define getvar(str) (nvram_get(str) ? : "")
31 +
32 +static inline void b44_bcm47xx_workarounds(struct b44 *bp)
33 +{
34 +       /*
35 +        * workaround for physical wiring in Linksys WRSL54GS
36 +        * see https://dev.openwrt.org/ticket/2662 and 3903
37 +        * eth1 PHY is probably on BCM5325 switch accessed via eth0
38 +        */
39 +
40 +       if (simple_strtoul(getvar("boardnum"), NULL, 0) == 42) {
41 +               bp->phy_addr = B44_PHY_ADDR_NO_PHY;
42 +       } else {
43 +               /* WL-HDD */
44 +               struct ssb_device *sdev = bp->sdev;
45 +               if (startswith(getvar("hardware_version"), "WL300-")) {
46 +                       if (sdev->bus->sprom.et0phyaddr == 0 &&
47 +                           sdev->bus->sprom.et1phyaddr == 1)
48 +                               bp->phy_addr = B44_PHY_ADDR_NO_PHY;
49 +               }
50 +       }
51 +       return;
52 +}
53 +
54 +#else
55 +static inline void b44_bcm47xx_workarounds(struct b44 *bp) 
56 +{ 
57 +}
58 +#endif
59 +
60  static int b44_setup_phy(struct b44 *bp)
61  {
62         u32 val;
63         int err;
64  
65         b44_wap54g10_workaround(bp);
66 +       b44_bcm47xx_workarounds(bp);
67  
68         if (bp->phy_addr == B44_PHY_ADDR_NO_PHY)
69                 return 0;
70 @@ -2089,6 +2127,8 @@
71          * valid PHY address. */
72         bp->phy_addr &= 0x1F;
73  
74 +       b44_bcm47xx_workarounds(bp);
75 +
76         memcpy(bp->dev->dev_addr, addr, 6);
77  
78         if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){