aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/tg3.c
diff options
context:
space:
mode:
authorNithin Sujir <nsujir@broadcom.com>2013-05-18 02:26:53 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-20 03:13:47 -0400
commit400dfbaa8d444a29056b051a3d7082dc611e3b12 (patch)
tree369d29f3656fe30ecf203a92658258ec7a404802 /drivers/net/ethernet/broadcom/tg3.c
parent9e2ecbeb250dee67f4bd06a18637c120b48a4865 (diff)
tg3: Add tg3_eee_pull_config() function
Add tg3_eee_pull_config() to pull the settings from the hardware and populate the eee structure. If Link Flap Avoidance is enabled, we pull the eee settings from the hw so as not to cause a phy reset on eee config mismatch later. This requires moving down tg3_setup_eee() below the tg3_pull_config() to not trample existing settings. Reviewed-by: Ben Li <benli@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Nithin Nayak Sujir <nsujir@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/tg3.c')
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c56
1 files changed, 47 insertions, 9 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 26804db1f884..3e7bc3837ef9 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -2320,6 +2320,46 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
2320 tg3_phy_toggle_auxctl_smdsp(tp, false); 2320 tg3_phy_toggle_auxctl_smdsp(tp, false);
2321} 2321}
2322 2322
2323static void tg3_eee_pull_config(struct tg3 *tp, struct ethtool_eee *eee)
2324{
2325 u32 val;
2326 struct ethtool_eee *dest = &tp->eee;
2327
2328 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP))
2329 return;
2330
2331 if (eee)
2332 dest = eee;
2333
2334 if (tg3_phy_cl45_read(tp, MDIO_MMD_AN, TG3_CL45_D7_EEERES_STAT, &val))
2335 return;
2336
2337 /* Pull eee_active */
2338 if (val == TG3_CL45_D7_EEERES_STAT_LP_1000T ||
2339 val == TG3_CL45_D7_EEERES_STAT_LP_100TX) {
2340 dest->eee_active = 1;
2341 } else
2342 dest->eee_active = 0;
2343
2344 /* Pull lp advertised settings */
2345 if (tg3_phy_cl45_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE, &val))
2346 return;
2347 dest->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val);
2348
2349 /* Pull advertised and eee_enabled settings */
2350 if (tg3_phy_cl45_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV, &val))
2351 return;
2352 dest->eee_enabled = !!val;
2353 dest->advertised = mmd_eee_adv_to_ethtool_adv_t(val);
2354
2355 /* Pull tx_lpi_enabled */
2356 val = tr32(TG3_CPMU_EEE_MODE);
2357 dest->tx_lpi_enabled = !!(val & TG3_CPMU_EEEMD_LPI_IN_TX);
2358
2359 /* Pull lpi timer value */
2360 dest->tx_lpi_timer = tr32(TG3_CPMU_EEE_DBTMR1) & 0xffff;
2361}
2362
2323static void tg3_phy_eee_adjust(struct tg3 *tp, bool current_link_up) 2363static void tg3_phy_eee_adjust(struct tg3 *tp, bool current_link_up)
2324{ 2364{
2325 u32 val; 2365 u32 val;
@@ -2343,11 +2383,8 @@ static void tg3_phy_eee_adjust(struct tg3 *tp, bool current_link_up)
2343 2383
2344 tw32(TG3_CPMU_EEE_CTRL, eeectl); 2384 tw32(TG3_CPMU_EEE_CTRL, eeectl);
2345 2385
2346 tg3_phy_cl45_read(tp, MDIO_MMD_AN, 2386 tg3_eee_pull_config(tp, NULL);
2347 TG3_CL45_D7_EEERES_STAT, &val); 2387 if (tp->eee.eee_active)
2348
2349 if (val == TG3_CL45_D7_EEERES_STAT_LP_1000T ||
2350 val == TG3_CL45_D7_EEERES_STAT_LP_100TX)
2351 tp->setlpicnt = 2; 2388 tp->setlpicnt = 2;
2352 } 2389 }
2353 2390
@@ -9493,16 +9530,17 @@ static int tg3_reset_hw(struct tg3 *tp, bool reset_phy)
9493 if (tg3_flag(tp, INIT_COMPLETE)) 9530 if (tg3_flag(tp, INIT_COMPLETE))
9494 tg3_abort_hw(tp, 1); 9531 tg3_abort_hw(tp, 1);
9495 9532
9496 /* Enable MAC control of LPI */
9497 if (tp->phy_flags & TG3_PHYFLG_EEE_CAP)
9498 tg3_setup_eee(tp);
9499
9500 if ((tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN) && 9533 if ((tp->phy_flags & TG3_PHYFLG_KEEP_LINK_ON_PWRDN) &&
9501 !(tp->phy_flags & TG3_PHYFLG_USER_CONFIGURED)) { 9534 !(tp->phy_flags & TG3_PHYFLG_USER_CONFIGURED)) {
9502 tg3_phy_pull_config(tp); 9535 tg3_phy_pull_config(tp);
9536 tg3_eee_pull_config(tp, NULL);
9503 tp->phy_flags |= TG3_PHYFLG_USER_CONFIGURED; 9537 tp->phy_flags |= TG3_PHYFLG_USER_CONFIGURED;
9504 } 9538 }
9505 9539
9540 /* Enable MAC control of LPI */
9541 if (tp->phy_flags & TG3_PHYFLG_EEE_CAP)
9542 tg3_setup_eee(tp);
9543
9506 if (reset_phy) 9544 if (reset_phy)
9507 tg3_phy_reset(tp); 9545 tg3_phy_reset(tp);
9508 9546