a9b3fa87c62690d5e355709dde602f69475c9fa5
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.10 / 201-b44-check-register-instead-of-PHY-address-to-detect-.patch
1 From d61941952d5e7d062c3884e6d81bd503a37702b4 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Fri, 20 Dec 2013 02:16:06 +0100
4 Subject: [PATCH 201/208] b44: check register instead of PHY address to detect
5 external PHY
6
7 The Ethernet core supported by b44 supports an internal PHY integrated
8 into the mac core, which is supported by the b44 driver and an external
9 PHY to which the mac core is connected. This external PHY could be a
10 switch connected through MII, which is often the case when this core is
11 used on home routers. The usage of an external PHY was assumed when the
12 PHY address 30 was used and an internal PHY was assumed when the PHY
13 address was different. To verify that b44_phy_reset() was called and
14 checked if it worked, otherwise PHY address 30 was assumed, an external
15 PHY. It is better to check the register which says which PHY is
16 connected to the MAC instead of checking the PHY address.
17 The interface to an external PHY was only activated when this register
18 was set.
19
20 This also changes B44_FLAG_INTERNAL_PHY to B44_FLAG_EXTERNAL_PHY, it is
21 easier to check.
22
23 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
24 Signed-off-by: David S. Miller <davem@davemloft.net>
25 ---
26 drivers/net/ethernet/broadcom/b44.c | 18 +++++++++---------
27 drivers/net/ethernet/broadcom/b44.h | 2 +-
28 2 files changed, 10 insertions(+), 10 deletions(-)
29
30 --- a/drivers/net/ethernet/broadcom/b44.c
31 +++ b/drivers/net/ethernet/broadcom/b44.c
32 @@ -284,7 +284,7 @@ static int __b44_writephy(struct b44 *bp
33
34 static inline int b44_readphy(struct b44 *bp, int reg, u32 *val)
35 {
36 - if (bp->phy_addr == B44_PHY_ADDR_NO_PHY)
37 + if (bp->flags & B44_FLAG_EXTERNAL_PHY)
38 return 0;
39
40 return __b44_readphy(bp, bp->phy_addr, reg, val);
41 @@ -292,7 +292,7 @@ static inline int b44_readphy(struct b44
42
43 static inline int b44_writephy(struct b44 *bp, int reg, u32 val)
44 {
45 - if (bp->phy_addr == B44_PHY_ADDR_NO_PHY)
46 + if (bp->flags & B44_FLAG_EXTERNAL_PHY)
47 return 0;
48
49 return __b44_writephy(bp, bp->phy_addr, reg, val);
50 @@ -321,7 +321,7 @@ static int b44_phy_reset(struct b44 *bp)
51 u32 val;
52 int err;
53
54 - if (bp->phy_addr == B44_PHY_ADDR_NO_PHY)
55 + if (bp->flags & B44_FLAG_EXTERNAL_PHY)
56 return 0;
57 err = b44_writephy(bp, MII_BMCR, BMCR_RESET);
58 if (err)
59 @@ -423,7 +423,7 @@ static int b44_setup_phy(struct b44 *bp)
60
61 b44_wap54g10_workaround(bp);
62
63 - if (bp->phy_addr == B44_PHY_ADDR_NO_PHY)
64 + if (bp->flags & B44_FLAG_EXTERNAL_PHY)
65 return 0;
66 if ((err = b44_readphy(bp, B44_MII_ALEDCTRL, &val)) != 0)
67 goto out;
68 @@ -521,7 +521,7 @@ static void b44_check_phy(struct b44 *bp
69 {
70 u32 bmsr, aux;
71
72 - if (bp->phy_addr == B44_PHY_ADDR_NO_PHY) {
73 + if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
74 bp->flags |= B44_FLAG_100_BASE_T;
75 bp->flags |= B44_FLAG_FULL_DUPLEX;
76 if (!netif_carrier_ok(bp->dev)) {
77 @@ -1315,7 +1315,7 @@ static void b44_chip_reset(struct b44 *b
78 if (!(br32(bp, B44_DEVCTRL) & DEVCTRL_IPP)) {
79 bw32(bp, B44_ENET_CTRL, ENET_CTRL_EPSEL);
80 br32(bp, B44_ENET_CTRL);
81 - bp->flags &= ~B44_FLAG_INTERNAL_PHY;
82 + bp->flags |= B44_FLAG_EXTERNAL_PHY;
83 } else {
84 u32 val = br32(bp, B44_DEVCTRL);
85
86 @@ -1324,7 +1324,7 @@ static void b44_chip_reset(struct b44 *b
87 br32(bp, B44_DEVCTRL);
88 udelay(100);
89 }
90 - bp->flags |= B44_FLAG_INTERNAL_PHY;
91 + bp->flags &= ~B44_FLAG_EXTERNAL_PHY;
92 }
93 }
94
95 @@ -1828,8 +1828,8 @@ static int b44_get_settings(struct net_d
96 DUPLEX_FULL : DUPLEX_HALF;
97 cmd->port = 0;
98 cmd->phy_address = bp->phy_addr;
99 - cmd->transceiver = (bp->flags & B44_FLAG_INTERNAL_PHY) ?
100 - XCVR_INTERNAL : XCVR_EXTERNAL;
101 + cmd->transceiver = (bp->flags & B44_FLAG_EXTERNAL_PHY) ?
102 + XCVR_EXTERNAL : XCVR_INTERNAL;
103 cmd->autoneg = (bp->flags & B44_FLAG_FORCE_LINK) ?
104 AUTONEG_DISABLE : AUTONEG_ENABLE;
105 if (cmd->autoneg == AUTONEG_ENABLE)
106 --- a/drivers/net/ethernet/broadcom/b44.h
107 +++ b/drivers/net/ethernet/broadcom/b44.h
108 @@ -376,7 +376,7 @@ struct b44 {
109 #define B44_FLAG_ADV_10FULL 0x02000000
110 #define B44_FLAG_ADV_100HALF 0x04000000
111 #define B44_FLAG_ADV_100FULL 0x08000000
112 -#define B44_FLAG_INTERNAL_PHY 0x10000000
113 +#define B44_FLAG_EXTERNAL_PHY 0x10000000
114 #define B44_FLAG_RX_RING_HACK 0x20000000
115 #define B44_FLAG_TX_RING_HACK 0x40000000
116 #define B44_FLAG_WOL_ENABLE 0x80000000