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
5 spin_lock_bh(&tp->lock);
7 - if (tg3_readphy(tp, reg, &val))
8 + if (__tg3_readphy(tp, mii_id, reg, &val))
11 spin_unlock_bh(&tp->lock);
12 @@ -1382,7 +1382,7 @@ static int tg3_mdio_write(struct mii_bus
14 spin_lock_bh(&tp->lock);
16 - if (tg3_writephy(tp, reg, val))
17 + if (__tg3_writephy(tp, mii_id, reg, val))
20 spin_unlock_bh(&tp->lock);
21 @@ -1400,7 +1400,7 @@ static void tg3_mdio_config_5785(struct
23 struct phy_device *phydev;
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) {
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;
34 + } else if (tg3_flag(tp, IS_SSB_CORE)) {
37 + addr = ssb_gige_get_phyaddr(tp->pdev);
40 + tp->phy_addr = addr;
42 tp->phy_addr = TG3_PHY_MII_ADDR;
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];
52 for (i = 0; i < PHY_MAX_ADDR; i++)
53 @@ -1546,7 +1553,7 @@ static int tg3_mdio_init(struct tg3 *tp)
57 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
58 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
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;
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;
69 autoneg = tp->link_config.autoneg;
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];
78 spin_lock_bh(&tp->lock);
80 @@ -2088,7 +2095,7 @@ static int tg3_phy_init(struct tg3 *tp)
81 /* Bring the PHY back to a known state. */
84 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
85 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
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);
93 - phy_disconnect(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]);
94 + phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]);
98 @@ -2133,7 +2140,7 @@ static void tg3_phy_start(struct tg3 *tp
99 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
102 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
103 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
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))
111 - phy_stop(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]);
112 + phy_stop(tp->mdio_bus->phy_map[tp->phy_addr]);
115 static void tg3_phy_fini(struct tg3 *tp)
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;
123 @@ -3999,7 +4006,7 @@ static int tg3_power_down_prepare(struct
124 struct phy_device *phydev;
125 u32 phyid, advertising;
127 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
128 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
130 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER;
132 @@ -11783,7 +11790,7 @@ static int tg3_get_settings(struct net_d
133 struct phy_device *phydev;
134 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
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);
141 @@ -11850,7 +11857,7 @@ static int tg3_set_settings(struct net_d
142 struct phy_device *phydev;
143 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
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);
150 @@ -12007,7 +12014,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))
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]);
159 @@ -12123,7 +12130,7 @@ static int tg3_set_pauseparam(struct net
161 struct phy_device *phydev;
163 - phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
164 + phydev = tp->mdio_bus->phy_map[tp->phy_addr];
166 if (!(phydev->supported & SUPPORTED_Pause) ||
167 (!(phydev->supported & SUPPORTED_Asym_Pause) &&
168 @@ -13557,7 +13564,7 @@ static int tg3_ioctl(struct net_device *
169 struct phy_device *phydev;
170 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
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);
177 @@ -17190,8 +17197,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);
186 if (ssb_gige_is_rgmii(pdev))
187 tg3_flag_set(tp, RGMII_MODE);
189 @@ -17461,7 +17470,7 @@ static int tg3_init_one(struct pci_dev *
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];
196 "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
197 phydev->drv->name, dev_name(&phydev->dev));
198 --- a/include/linux/ssb/ssb_driver_gige.h
199 +++ b/include/linux/ssb/ssb_driver_gige.h
200 @@ -108,6 +108,16 @@ static inline int ssb_gige_get_macaddr(s
204 +/* Get the device phy address */
205 +static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
207 + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
211 + return dev->dev->bus->sprom.et0phyaddr;
214 extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
215 struct pci_dev *pdev);
216 extern int ssb_gige_map_irq(struct ssb_device *sdev,
217 @@ -174,6 +184,10 @@ static inline int ssb_gige_get_macaddr(s
221 +static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
226 #endif /* CONFIG_SSB_DRIVER_GIGE */
227 #endif /* LINUX_SSB_DRIVER_GIGE_H_ */