aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2013-09-28 17:15:26 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-02 15:40:57 -0400
commitead2402cb40a023c22d93ff374eee31022e28c58 (patch)
tree655f9c949f0c9380343155b6ee42eee69320f8ca
parent4fbef95af4e62d4aada6c1728e04d3b1c828abe0 (diff)
tg3: add support a phy at an address different than 01
When phylib was in use tg3 only searched at address 01 on the mdio bus and did not work with any other address. On the BCM4705 SoCs the switch is connected as a PHY behind the MAC driven by tg3 and it is at PHY address 30 in most cases. This is a preparation patch to allow support for such switches. phy_addr is set to TG3_PHY_MII_ADDR for all devices, which are using phylib, so this should not change any behavior. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Acked-by: Nithin Nayak Sujir <nsujir@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 221a1815fd36..853a05e0691f 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -1375,7 +1375,7 @@ static int tg3_mdio_read(struct mii_bus *bp, int mii_id, int reg)
1375 1375
1376 spin_lock_bh(&tp->lock); 1376 spin_lock_bh(&tp->lock);
1377 1377
1378 if (tg3_readphy(tp, reg, &val)) 1378 if (__tg3_readphy(tp, mii_id, reg, &val))
1379 val = -EIO; 1379 val = -EIO;
1380 1380
1381 spin_unlock_bh(&tp->lock); 1381 spin_unlock_bh(&tp->lock);
@@ -1390,7 +1390,7 @@ static int tg3_mdio_write(struct mii_bus *bp, int mii_id, int reg, u16 val)
1390 1390
1391 spin_lock_bh(&tp->lock); 1391 spin_lock_bh(&tp->lock);
1392 1392
1393 if (tg3_writephy(tp, reg, val)) 1393 if (__tg3_writephy(tp, mii_id, reg, val))
1394 ret = -EIO; 1394 ret = -EIO;
1395 1395
1396 spin_unlock_bh(&tp->lock); 1396 spin_unlock_bh(&tp->lock);
@@ -1408,7 +1408,7 @@ static void tg3_mdio_config_5785(struct tg3 *tp)
1408 u32 val; 1408 u32 val;
1409 struct phy_device *phydev; 1409 struct phy_device *phydev;
1410 1410
1411 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 1411 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
1412 switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) { 1412 switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) {
1413 case PHY_ID_BCM50610: 1413 case PHY_ID_BCM50610:
1414 case PHY_ID_BCM50610M: 1414 case PHY_ID_BCM50610M:
@@ -1533,7 +1533,7 @@ static int tg3_mdio_init(struct tg3 *tp)
1533 tp->mdio_bus->read = &tg3_mdio_read; 1533 tp->mdio_bus->read = &tg3_mdio_read;
1534 tp->mdio_bus->write = &tg3_mdio_write; 1534 tp->mdio_bus->write = &tg3_mdio_write;
1535 tp->mdio_bus->reset = &tg3_mdio_reset; 1535 tp->mdio_bus->reset = &tg3_mdio_reset;
1536 tp->mdio_bus->phy_mask = ~(1 << TG3_PHY_MII_ADDR); 1536 tp->mdio_bus->phy_mask = ~(1 << tp->phy_addr);
1537 tp->mdio_bus->irq = &tp->mdio_irq[0]; 1537 tp->mdio_bus->irq = &tp->mdio_irq[0];
1538 1538
1539 for (i = 0; i < PHY_MAX_ADDR; i++) 1539 for (i = 0; i < PHY_MAX_ADDR; i++)
@@ -1554,7 +1554,7 @@ static int tg3_mdio_init(struct tg3 *tp)
1554 return i; 1554 return i;
1555 } 1555 }
1556 1556
1557 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 1557 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
1558 1558
1559 if (!phydev || !phydev->drv) { 1559 if (!phydev || !phydev->drv) {
1560 dev_warn(&tp->pdev->dev, "No PHY devices\n"); 1560 dev_warn(&tp->pdev->dev, "No PHY devices\n");
@@ -1964,7 +1964,7 @@ static void tg3_setup_flow_control(struct tg3 *tp, u32 lcladv, u32 rmtadv)
1964 u32 old_tx_mode = tp->tx_mode; 1964 u32 old_tx_mode = tp->tx_mode;
1965 1965
1966 if (tg3_flag(tp, USE_PHYLIB)) 1966 if (tg3_flag(tp, USE_PHYLIB))
1967 autoneg = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]->autoneg; 1967 autoneg = tp->mdio_bus->phy_map[tp->phy_addr]->autoneg;
1968 else 1968 else
1969 autoneg = tp->link_config.autoneg; 1969 autoneg = tp->link_config.autoneg;
1970 1970
@@ -2000,7 +2000,7 @@ static void tg3_adjust_link(struct net_device *dev)
2000 u8 oldflowctrl, linkmesg = 0; 2000 u8 oldflowctrl, linkmesg = 0;
2001 u32 mac_mode, lcl_adv, rmt_adv; 2001 u32 mac_mode, lcl_adv, rmt_adv;
2002 struct tg3 *tp = netdev_priv(dev); 2002 struct tg3 *tp = netdev_priv(dev);
2003 struct phy_device *phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 2003 struct phy_device *phydev = tp->mdio_bus->phy_map[tp->phy_addr];
2004 2004
2005 spin_lock_bh(&tp->lock); 2005 spin_lock_bh(&tp->lock);
2006 2006
@@ -2089,7 +2089,7 @@ static int tg3_phy_init(struct tg3 *tp)
2089 /* Bring the PHY back to a known state. */ 2089 /* Bring the PHY back to a known state. */
2090 tg3_bmcr_reset(tp); 2090 tg3_bmcr_reset(tp);
2091 2091
2092 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 2092 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
2093 2093
2094 /* Attach the MAC to the PHY. */ 2094 /* Attach the MAC to the PHY. */
2095 phydev = phy_connect(tp->dev, dev_name(&phydev->dev), 2095 phydev = phy_connect(tp->dev, dev_name(&phydev->dev),
@@ -2116,7 +2116,7 @@ static int tg3_phy_init(struct tg3 *tp)
2116 SUPPORTED_Asym_Pause); 2116 SUPPORTED_Asym_Pause);
2117 break; 2117 break;
2118 default: 2118 default:
2119 phy_disconnect(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]); 2119 phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]);
2120 return -EINVAL; 2120 return -EINVAL;
2121 } 2121 }
2122 2122
@@ -2134,7 +2134,7 @@ static void tg3_phy_start(struct tg3 *tp)
2134 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) 2134 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
2135 return; 2135 return;
2136 2136
2137 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 2137 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
2138 2138
2139 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) { 2139 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) {
2140 tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER; 2140 tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER;
@@ -2154,13 +2154,13 @@ static void tg3_phy_stop(struct tg3 *tp)
2154 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) 2154 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
2155 return; 2155 return;
2156 2156
2157 phy_stop(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]); 2157 phy_stop(tp->mdio_bus->phy_map[tp->phy_addr]);
2158} 2158}
2159 2159
2160static void tg3_phy_fini(struct tg3 *tp) 2160static void tg3_phy_fini(struct tg3 *tp)
2161{ 2161{
2162 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) { 2162 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) {
2163 phy_disconnect(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]); 2163 phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]);
2164 tp->phy_flags &= ~TG3_PHYFLG_IS_CONNECTED; 2164 tp->phy_flags &= ~TG3_PHYFLG_IS_CONNECTED;
2165 } 2165 }
2166} 2166}
@@ -4034,7 +4034,7 @@ static int tg3_power_down_prepare(struct tg3 *tp)
4034 struct phy_device *phydev; 4034 struct phy_device *phydev;
4035 u32 phyid, advertising; 4035 u32 phyid, advertising;
4036 4036
4037 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 4037 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
4038 4038
4039 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER; 4039 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER;
4040 4040
@@ -11922,7 +11922,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
11922 struct phy_device *phydev; 11922 struct phy_device *phydev;
11923 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) 11923 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
11924 return -EAGAIN; 11924 return -EAGAIN;
11925 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 11925 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
11926 return phy_ethtool_gset(phydev, cmd); 11926 return phy_ethtool_gset(phydev, cmd);
11927 } 11927 }
11928 11928
@@ -11989,7 +11989,7 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
11989 struct phy_device *phydev; 11989 struct phy_device *phydev;
11990 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) 11990 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
11991 return -EAGAIN; 11991 return -EAGAIN;
11992 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 11992 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
11993 return phy_ethtool_sset(phydev, cmd); 11993 return phy_ethtool_sset(phydev, cmd);
11994 } 11994 }
11995 11995
@@ -12144,7 +12144,7 @@ static int tg3_nway_reset(struct net_device *dev)
12144 if (tg3_flag(tp, USE_PHYLIB)) { 12144 if (tg3_flag(tp, USE_PHYLIB)) {
12145 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) 12145 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
12146 return -EAGAIN; 12146 return -EAGAIN;
12147 r = phy_start_aneg(tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]); 12147 r = phy_start_aneg(tp->mdio_bus->phy_map[tp->phy_addr]);
12148 } else { 12148 } else {
12149 u32 bmcr; 12149 u32 bmcr;
12150 12150
@@ -12260,7 +12260,7 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam
12260 u32 newadv; 12260 u32 newadv;
12261 struct phy_device *phydev; 12261 struct phy_device *phydev;
12262 12262
12263 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 12263 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
12264 12264
12265 if (!(phydev->supported & SUPPORTED_Pause) || 12265 if (!(phydev->supported & SUPPORTED_Pause) ||
12266 (!(phydev->supported & SUPPORTED_Asym_Pause) && 12266 (!(phydev->supported & SUPPORTED_Asym_Pause) &&
@@ -13696,7 +13696,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
13696 struct phy_device *phydev; 13696 struct phy_device *phydev;
13697 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) 13697 if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
13698 return -EAGAIN; 13698 return -EAGAIN;
13699 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 13699 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
13700 return phy_mii_ioctl(phydev, ifr, cmd); 13700 return phy_mii_ioctl(phydev, ifr, cmd);
13701 } 13701 }
13702 13702
@@ -17635,7 +17635,7 @@ static int tg3_init_one(struct pci_dev *pdev,
17635 17635
17636 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) { 17636 if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) {
17637 struct phy_device *phydev; 17637 struct phy_device *phydev;
17638 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 17638 phydev = tp->mdio_bus->phy_map[tp->phy_addr];
17639 netdev_info(dev, 17639 netdev_info(dev,
17640 "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n", 17640 "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
17641 phydev->drv->name, dev_name(&phydev->dev)); 17641 phydev->drv->name, dev_name(&phydev->dev));