aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2010-08-02 07:26:06 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-02 18:46:32 -0400
commit80096068bc21420ba4d690341a3c70c49017d167 (patch)
treecee83745cb3eb158fa48f34a371262cf11b51247 /drivers/net/tg3.c
parentf08aa1a8b8ff0738d42936c3ac8c5516848bca02 (diff)
tg3: Create phy_flags and migrate phy_is_low_power
This patch deletes the link_config.phy_is_low_power flag and creates a new phy_flags device member to store all phy related settings. All the code is converted accordingly. Reviewed-by: Benjamin Li <benli@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 281cd7aff8fe..e0ff49bb8d01 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -1543,8 +1543,8 @@ static void tg3_phy_start(struct tg3 *tp)
1543 1543
1544 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 1544 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
1545 1545
1546 if (tp->link_config.phy_is_low_power) { 1546 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) {
1547 tp->link_config.phy_is_low_power = 0; 1547 tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER;
1548 phydev->speed = tp->link_config.orig_speed; 1548 phydev->speed = tp->link_config.orig_speed;
1549 phydev->duplex = tp->link_config.orig_duplex; 1549 phydev->duplex = tp->link_config.orig_duplex;
1550 phydev->autoneg = tp->link_config.orig_autoneg; 1550 phydev->autoneg = tp->link_config.orig_autoneg;
@@ -2559,13 +2559,13 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2559 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) { 2559 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) {
2560 do_low_power = false; 2560 do_low_power = false;
2561 if ((tp->tg3_flags3 & TG3_FLG3_PHY_CONNECTED) && 2561 if ((tp->tg3_flags3 & TG3_FLG3_PHY_CONNECTED) &&
2562 !tp->link_config.phy_is_low_power) { 2562 !(tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) {
2563 struct phy_device *phydev; 2563 struct phy_device *phydev;
2564 u32 phyid, advertising; 2564 u32 phyid, advertising;
2565 2565
2566 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 2566 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
2567 2567
2568 tp->link_config.phy_is_low_power = 1; 2568 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER;
2569 2569
2570 tp->link_config.orig_speed = phydev->speed; 2570 tp->link_config.orig_speed = phydev->speed;
2571 tp->link_config.orig_duplex = phydev->duplex; 2571 tp->link_config.orig_duplex = phydev->duplex;
@@ -2604,8 +2604,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
2604 } else { 2604 } else {
2605 do_low_power = true; 2605 do_low_power = true;
2606 2606
2607 if (tp->link_config.phy_is_low_power == 0) { 2607 if (!(tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) {
2608 tp->link_config.phy_is_low_power = 1; 2608 tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER;
2609 tp->link_config.orig_speed = tp->link_config.speed; 2609 tp->link_config.orig_speed = tp->link_config.speed;
2610 tp->link_config.orig_duplex = tp->link_config.duplex; 2610 tp->link_config.orig_duplex = tp->link_config.duplex;
2611 tp->link_config.orig_autoneg = tp->link_config.autoneg; 2611 tp->link_config.orig_autoneg = tp->link_config.autoneg;
@@ -2836,7 +2836,7 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
2836 u32 new_adv; 2836 u32 new_adv;
2837 int i; 2837 int i;
2838 2838
2839 if (tp->link_config.phy_is_low_power) { 2839 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) {
2840 /* Entering low power mode. Disable gigabit and 2840 /* Entering low power mode. Disable gigabit and
2841 * 100baseT advertisements. 2841 * 100baseT advertisements.
2842 */ 2842 */
@@ -3237,7 +3237,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
3237 } 3237 }
3238 3238
3239relink: 3239relink:
3240 if (current_link_up == 0 || tp->link_config.phy_is_low_power) { 3240 if (current_link_up == 0 || (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) {
3241 u32 tmp; 3241 u32 tmp;
3242 3242
3243 tg3_phy_copper_begin(tp); 3243 tg3_phy_copper_begin(tp);
@@ -8320,8 +8320,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
8320 } 8320 }
8321 8321
8322 if (!(tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB)) { 8322 if (!(tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB)) {
8323 if (tp->link_config.phy_is_low_power) { 8323 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) {
8324 tp->link_config.phy_is_low_power = 0; 8324 tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER;
8325 tp->link_config.speed = tp->link_config.orig_speed; 8325 tp->link_config.speed = tp->link_config.orig_speed;
8326 tp->link_config.duplex = tp->link_config.orig_duplex; 8326 tp->link_config.duplex = tp->link_config.orig_duplex;
8327 tp->link_config.autoneg = tp->link_config.orig_autoneg; 8327 tp->link_config.autoneg = tp->link_config.orig_autoneg;
@@ -9368,7 +9368,7 @@ static void tg3_get_regs(struct net_device *dev,
9368 9368
9369 memset(p, 0, TG3_REGDUMP_LEN); 9369 memset(p, 0, TG3_REGDUMP_LEN);
9370 9370
9371 if (tp->link_config.phy_is_low_power) 9371 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
9372 return; 9372 return;
9373 9373
9374 tg3_full_lock(tp, 0); 9374 tg3_full_lock(tp, 0);
@@ -9447,7 +9447,7 @@ static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
9447 if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) 9447 if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM)
9448 return -EINVAL; 9448 return -EINVAL;
9449 9449
9450 if (tp->link_config.phy_is_low_power) 9450 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
9451 return -EAGAIN; 9451 return -EAGAIN;
9452 9452
9453 offset = eeprom->offset; 9453 offset = eeprom->offset;
@@ -9509,7 +9509,7 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
9509 u8 *buf; 9509 u8 *buf;
9510 __be32 start, end; 9510 __be32 start, end;
9511 9511
9512 if (tp->link_config.phy_is_low_power) 9512 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
9513 return -EAGAIN; 9513 return -EAGAIN;
9514 9514
9515 if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) || 9515 if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) ||
@@ -10849,7 +10849,7 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
10849{ 10849{
10850 struct tg3 *tp = netdev_priv(dev); 10850 struct tg3 *tp = netdev_priv(dev);
10851 10851
10852 if (tp->link_config.phy_is_low_power) 10852 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
10853 tg3_set_power_state(tp, PCI_D0); 10853 tg3_set_power_state(tp, PCI_D0);
10854 10854
10855 memset(data, 0, sizeof(u64) * TG3_NUM_TEST); 10855 memset(data, 0, sizeof(u64) * TG3_NUM_TEST);
@@ -10917,7 +10917,7 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
10917 if (irq_sync && !err2) 10917 if (irq_sync && !err2)
10918 tg3_phy_start(tp); 10918 tg3_phy_start(tp);
10919 } 10919 }
10920 if (tp->link_config.phy_is_low_power) 10920 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
10921 tg3_set_power_state(tp, PCI_D3hot); 10921 tg3_set_power_state(tp, PCI_D3hot);
10922 10922
10923} 10923}
@@ -10947,7 +10947,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
10947 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 10947 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
10948 break; /* We have no PHY */ 10948 break; /* We have no PHY */
10949 10949
10950 if (tp->link_config.phy_is_low_power) 10950 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
10951 return -EAGAIN; 10951 return -EAGAIN;
10952 10952
10953 spin_lock_bh(&tp->lock); 10953 spin_lock_bh(&tp->lock);
@@ -10963,7 +10963,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
10963 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 10963 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
10964 break; /* We have no PHY */ 10964 break; /* We have no PHY */
10965 10965
10966 if (tp->link_config.phy_is_low_power) 10966 if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
10967 return -EAGAIN; 10967 return -EAGAIN;
10968 10968
10969 spin_lock_bh(&tp->lock); 10969 spin_lock_bh(&tp->lock);
@@ -14109,7 +14109,6 @@ static void __devinit tg3_init_link_config(struct tg3 *tp)
14109 tp->link_config.autoneg = AUTONEG_ENABLE; 14109 tp->link_config.autoneg = AUTONEG_ENABLE;
14110 tp->link_config.active_speed = SPEED_INVALID; 14110 tp->link_config.active_speed = SPEED_INVALID;
14111 tp->link_config.active_duplex = DUPLEX_INVALID; 14111 tp->link_config.active_duplex = DUPLEX_INVALID;
14112 tp->link_config.phy_is_low_power = 0;
14113 tp->link_config.orig_speed = SPEED_INVALID; 14112 tp->link_config.orig_speed = SPEED_INVALID;
14114 tp->link_config.orig_duplex = DUPLEX_INVALID; 14113 tp->link_config.orig_duplex = DUPLEX_INVALID;
14115 tp->link_config.orig_autoneg = AUTONEG_INVALID; 14114 tp->link_config.orig_autoneg = AUTONEG_INVALID;