brcm47xx: refresh patches
[openwrt/openwrt.git] / target / linux / brcm47xx / patches-3.10 / 790-tg3-phylib.patch
1 --- a/drivers/net/ethernet/broadcom/tg3.c
2 +++ b/drivers/net/ethernet/broadcom/tg3.c
3 @@ -1367,7 +1367,7 @@ static int tg3_mdio_read(struct mii_bus
4
5 spin_lock_bh(&tp->lock);
6
7 - if (tg3_readphy(tp, reg, &val))
8 + if (__tg3_readphy(tp, mii_id, reg, &val))
9 val = -EIO;
10
11 spin_unlock_bh(&tp->lock);
12 @@ -1382,7 +1382,7 @@ static int tg3_mdio_write(struct mii_bus
13
14 spin_lock_bh(&tp->lock);
15
16 - if (tg3_writephy(tp, reg, val))
17 + if (__tg3_writephy(tp, mii_id, reg, val))
18 ret = -EIO;
19
20 spin_unlock_bh(&tp->lock);
21 @@ -1400,7 +1400,7 @@ static void tg3_mdio_config_5785(struct
22 u32 val;
23 struct phy_device *phydev;
24
25 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
26 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
27 switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) {
28 case PHY_ID_BCM50610:
29 case PHY_ID_BCM50610M:
30 @@ -1505,6 +1505,13 @@ static int tg3_mdio_init(struct tg3 *tp)
31 TG3_CPMU_PHY_STRAP_IS_SERDES;
32 if (is_serdes)
33 tp->phy_addr += 7;
34 + } else if (tg3_flag(tp, IS_SSB_CORE) && tg3_flag(tp, ROBOSWITCH)) {
35 + int addr;
36 +
37 + addr = ssb_gige_get_phyaddr(tp->pdev);
38 + if (addr < 0)
39 + return addr;
40 + tp->phy_addr = addr;
41 } else
42 tp->phy_addr = TG3_PHY_MII_ADDR;
43
44 @@ -1525,7 +1532,7 @@ static int tg3_mdio_init(struct tg3 *tp)
45 tp->mdio_bus->read = &tg3_mdio_read;
46 tp->mdio_bus->write = &tg3_mdio_write;
47 tp->mdio_bus->reset = &tg3_mdio_reset;
48 - tp->mdio_bus->phy_mask = ~(1 << TG3_PHY_MII_ADDR);
49 + tp->mdio_bus->phy_mask = ~(1 << tp->phy_addr);
50 tp->mdio_bus->irq = &tp->mdio_irq[0];
51
52 for (i = 0; i < PHY_MAX_ADDR; i++)
53 @@ -1546,7 +1553,7 @@ static int tg3_mdio_init(struct tg3 *tp)
54 return i;
55 }
56
57 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
58 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
59
60 if (!phydev || !phydev->drv) {
61 dev_warn(&tp->pdev->dev, "No PHY devices\n");
62 @@ -1963,7 +1970,7 @@ static void tg3_setup_flow_control(struc
63 u32 old_tx_mode = tp->tx_mode;
64
65 if (tg3_flag(tp, USE_PHYLIB))
66 - autoneg = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]->autoneg;
67 + autoneg = tp->mdio_bus->phy_map[tp->phy_addr]->autoneg;
68 else
69 autoneg = tp->link_config.autoneg;
70
71 @@ -1999,7 +2006,7 @@ static void tg3_adjust_link(struct net_d
72 u8 oldflowctrl, linkmesg = 0;
73 u32 mac_mode, lcl_adv, rmt_adv;
74 struct tg3 *tp = netdev_priv(dev);
75 - struct phy_device *phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
76 + struct phy_device *phydev = tp->mdio_bus->phy_map[tp->phy_addr];
77
78 spin_lock_bh(&tp->lock);
79
80 @@ -2088,7 +2095,7 @@ static int tg3_phy_init(struct tg3 *tp)
81 /* Bring the PHY back to a known state. */
82 tg3_bmcr_reset(tp);
83
84 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
85 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
86
87 /* Attach the MAC to the PHY. */
88 phydev = phy_connect(tp->dev, dev_name(&phydev->dev),
89 @@ -2115,7 +2122,7 @@ static int tg3_phy_init(struct tg3 *tp)
90 SUPPORTED_Asym_Pause);
91 break;
92 default:
93 - phy_disconnect(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]);
94 + phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]);
95 return -EINVAL;
96 }
97
98 @@ -2133,7 +2140,7 @@ static void tg3_phy_start(struct tg3 *tp
99 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
100 return;
101
102 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
103 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
104
105 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) {
106 tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER;
107 @@ -2153,13 +2160,13 @@ static void tg3_phy_stop(struct tg3 *tp)
108 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
109 return;
110
111 - phy_stop(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]);
112 + phy_stop(tp->mdio_bus->phy_map[tp->phy_addr]);
113 }
114
115 static void tg3_phy_fini(struct tg3 *tp)
116 {
117 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) {
118 - phy_disconnect(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]);
119 + phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]);
120 tp->phy_flags &= ~TG3_PHYFLG_IS_CONNECTED;
121 }
122 }
123 @@ -3999,7 +4006,7 @@ static int tg3_power_down_prepare(struct
124 struct phy_device *phydev;
125 u32 phyid, advertising;
126
127 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
128 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
129
130 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER;
131
132 @@ -11782,7 +11789,7 @@ static int tg3_get_settings(struct net_d
133 struct phy_device *phydev;
134 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
135 return -EAGAIN;
136 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
137 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
138 return phy_ethtool_gset(phydev, cmd);
139 }
140
141 @@ -11849,7 +11856,7 @@ static int tg3_set_settings(struct net_d
142 struct phy_device *phydev;
143 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
144 return -EAGAIN;
145 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
146 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
147 return phy_ethtool_sset(phydev, cmd);
148 }
149
150 @@ -12006,7 +12013,7 @@ static int tg3_nway_reset(struct net_dev
151 if (tg3_flag(tp, USE_PHYLIB)) {
152 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
153 return -EAGAIN;
154 - r = phy_start_aneg(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]);
155 + r = phy_start_aneg(tp->mdio_bus->phy_map[tp->phy_addr]);
156 } else {
157 u32 bmcr;
158
159 @@ -12124,7 +12131,7 @@ static int tg3_set_pauseparam(struct net
160 u32 newadv;
161 struct phy_device *phydev;
162
163 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
164 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
165
166 if (!(phydev->supported & SUPPORTED_Pause) ||
167 (!(phydev->supported & SUPPORTED_Asym_Pause) &&
168 @@ -13558,7 +13565,7 @@ static int tg3_ioctl(struct net_device *
169 struct phy_device *phydev;
170 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
171 return -EAGAIN;
172 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
173 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
174 return phy_mii_ioctl(phydev, ifr, cmd);
175 }
176
177 @@ -17194,8 +17201,10 @@ static int tg3_init_one(struct pci_dev *
178 tg3_flag_set(tp, FLUSH_POSTED_WRITES);
179 if (ssb_gige_one_dma_at_once(pdev))
180 tg3_flag_set(tp, ONE_DMA_AT_ONCE);
181 - if (ssb_gige_have_roboswitch(pdev))
182 + if (ssb_gige_have_roboswitch(pdev)) {
183 + tg3_flag_set(tp, USE_PHYLIB);
184 tg3_flag_set(tp, ROBOSWITCH);
185 + }
186 if (ssb_gige_is_rgmii(pdev))
187 tg3_flag_set(tp, RGMII_MODE);
188 }
189 @@ -17464,7 +17473,7 @@ static int tg3_init_one(struct pci_dev *
190
191 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) {
192 struct phy_device *phydev;
193 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
194 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
195 netdev_info(dev,
196 "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
197 phydev->drv->name, dev_name(&phydev->dev));