aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-04-20 03:57:42 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-21 20:05:59 -0400
commit1d36ba450bf8c88eda57deb028370880d09a14bc (patch)
tree3a994c46a984d7d42e3d2b5277b07c826886953e /drivers/net/tg3.c
parentb4bd292933537e19107c3e151b27a15fefa5f8d0 (diff)
tg3: Add macro for SMDSP toggling
A common AUX CTRL operation in the driver is to enable and disable the SMDSP. This patch consolidates the code so that the details of the operation are in one place. This patch also adds code to make sure the SMDSP is enabled before executing code that relies on it. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c102
1 files changed, 46 insertions, 56 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 69cd7cfa276b..9ed6bfb8e697 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -970,6 +970,15 @@ static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
970 return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg); 970 return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg);
971} 971}
972 972
973#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp) \
974 tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL, \
975 MII_TG3_AUXCTL_ACTL_SMDSP_ENA | \
976 MII_TG3_AUXCTL_ACTL_TX_6DB)
977
978#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp) \
979 tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL, \
980 MII_TG3_AUXCTL_ACTL_TX_6DB);
981
973static int tg3_bmcr_reset(struct tg3 *tp) 982static int tg3_bmcr_reset(struct tg3 *tp)
974{ 983{
975 u32 phy_control; 984 u32 phy_control;
@@ -1738,11 +1747,8 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
1738 1747
1739 otp = tp->phy_otp; 1748 otp = tp->phy_otp;
1740 1749
1741 /* Enable SM_DSP clock and tx 6dB coding. */ 1750 if (TG3_PHY_AUXCTL_SMDSP_ENABLE(tp))
1742 phy = MII_TG3_AUXCTL_SHDWSEL_AUXCTL | 1751 return;
1743 MII_TG3_AUXCTL_ACTL_SMDSP_ENA |
1744 MII_TG3_AUXCTL_ACTL_TX_6DB;
1745 tg3_writephy(tp, MII_TG3_AUX_CTRL, phy);
1746 1752
1747 phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT); 1753 phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT);
1748 phy |= MII_TG3_DSP_TAP1_AGCTGT_DFLT; 1754 phy |= MII_TG3_DSP_TAP1_AGCTGT_DFLT;
@@ -1766,10 +1772,7 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
1766 ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT); 1772 ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT);
1767 tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy); 1773 tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy);
1768 1774
1769 /* Turn off SM_DSP clock. */ 1775 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp);
1770 phy = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
1771 MII_TG3_AUXCTL_ACTL_TX_6DB;
1772 tg3_writephy(tp, MII_TG3_AUX_CTRL, phy);
1773} 1776}
1774 1777
1775static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up) 1778static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
@@ -1804,18 +1807,11 @@ static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
1804 case ASIC_REV_5717: 1807 case ASIC_REV_5717:
1805 case ASIC_REV_5719: 1808 case ASIC_REV_5719:
1806 case ASIC_REV_57765: 1809 case ASIC_REV_57765:
1807 /* Enable SM_DSP clock and tx 6dB coding. */ 1810 if (!TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) {
1808 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL | 1811 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26,
1809 MII_TG3_AUXCTL_ACTL_SMDSP_ENA | 1812 0x0000);
1810 MII_TG3_AUXCTL_ACTL_TX_6DB; 1813 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp);
1811 tg3_writephy(tp, MII_TG3_AUX_CTRL, val); 1814 }
1812
1813 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, 0x0000);
1814
1815 /* Turn off SM_DSP clock. */
1816 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
1817 MII_TG3_AUXCTL_ACTL_TX_6DB;
1818 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
1819 } 1815 }
1820 /* Fallthrough */ 1816 /* Fallthrough */
1821 case TG3_CL45_D7_EEERES_STAT_LP_100TX: 1817 case TG3_CL45_D7_EEERES_STAT_LP_100TX:
@@ -1967,8 +1963,9 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
1967 (MII_TG3_CTRL_AS_MASTER | 1963 (MII_TG3_CTRL_AS_MASTER |
1968 MII_TG3_CTRL_ENABLE_AS_MASTER)); 1964 MII_TG3_CTRL_ENABLE_AS_MASTER));
1969 1965
1970 /* Enable SM_DSP_CLOCK and 6dB. */ 1966 err = TG3_PHY_AUXCTL_SMDSP_ENABLE(tp);
1971 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); 1967 if (err)
1968 return err;
1972 1969
1973 /* Block the PHY control access. */ 1970 /* Block the PHY control access. */
1974 tg3_phydsp_write(tp, 0x8005, 0x0800); 1971 tg3_phydsp_write(tp, 0x8005, 0x0800);
@@ -1987,13 +1984,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
1987 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200); 1984 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
1988 tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0000); 1985 tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0000);
1989 1986
1990 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 || 1987 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp);
1991 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
1992 /* Set Extended packet length bit for jumbo frames */
1993 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4400);
1994 } else {
1995 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
1996 }
1997 1988
1998 tg3_writephy(tp, MII_TG3_CTRL, phy9_orig); 1989 tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
1999 1990
@@ -2081,33 +2072,39 @@ static int tg3_phy_reset(struct tg3 *tp)
2081 tg3_phy_toggle_apd(tp, false); 2072 tg3_phy_toggle_apd(tp, false);
2082 2073
2083out: 2074out:
2084 if (tp->phy_flags & TG3_PHYFLG_ADC_BUG) { 2075 if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) &&
2085 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); 2076 !TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) {
2086 tg3_phydsp_write(tp, 0x201f, 0x2aaa); 2077 tg3_phydsp_write(tp, 0x201f, 0x2aaa);
2087 tg3_phydsp_write(tp, 0x000a, 0x0323); 2078 tg3_phydsp_write(tp, 0x000a, 0x0323);
2088 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); 2079 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp);
2089 } 2080 }
2081
2090 if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) { 2082 if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) {
2091 tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68); 2083 tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68);
2092 tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68); 2084 tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68);
2093 } 2085 }
2086
2094 if (tp->phy_flags & TG3_PHYFLG_BER_BUG) { 2087 if (tp->phy_flags & TG3_PHYFLG_BER_BUG) {
2095 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); 2088 if (!TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) {
2096 tg3_phydsp_write(tp, 0x000a, 0x310b); 2089 tg3_phydsp_write(tp, 0x000a, 0x310b);
2097 tg3_phydsp_write(tp, 0x201f, 0x9506); 2090 tg3_phydsp_write(tp, 0x201f, 0x9506);
2098 tg3_phydsp_write(tp, 0x401f, 0x14e2); 2091 tg3_phydsp_write(tp, 0x401f, 0x14e2);
2099 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); 2092 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp);
2093 }
2100 } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) { 2094 } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) {
2101 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); 2095 if (!TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) {
2102 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a); 2096 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a);
2103 if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) { 2097 if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) {
2104 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x110b); 2098 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x110b);
2105 tg3_writephy(tp, MII_TG3_TEST1, 2099 tg3_writephy(tp, MII_TG3_TEST1,
2106 MII_TG3_TEST1_TRIM_EN | 0x4); 2100 MII_TG3_TEST1_TRIM_EN | 0x4);
2107 } else 2101 } else
2108 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x010b); 2102 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x010b);
2109 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); 2103
2104 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp);
2105 }
2110 } 2106 }
2107
2111 /* Set Extended packet length bit (bit 14) on all chips that */ 2108 /* Set Extended packet length bit (bit 14) on all chips that */
2112 /* support jumbo frames */ 2109 /* support jumbo frames */
2113 if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) { 2110 if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) {
@@ -3011,11 +3008,7 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
3011 tw32(TG3_CPMU_EEE_MODE, 3008 tw32(TG3_CPMU_EEE_MODE,
3012 tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE); 3009 tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE);
3013 3010
3014 /* Enable SM_DSP clock and tx 6dB coding. */ 3011 TG3_PHY_AUXCTL_SMDSP_ENABLE(tp);
3015 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
3016 MII_TG3_AUXCTL_ACTL_SMDSP_ENA |
3017 MII_TG3_AUXCTL_ACTL_TX_6DB;
3018 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
3019 3012
3020 switch (GET_ASIC_REV(tp->pci_chip_rev_id)) { 3013 switch (GET_ASIC_REV(tp->pci_chip_rev_id)) {
3021 case ASIC_REV_5717: 3014 case ASIC_REV_5717:
@@ -3044,10 +3037,7 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
3044 } 3037 }
3045 tg3_phy_cl45_write(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV, val); 3038 tg3_phy_cl45_write(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV, val);
3046 3039
3047 /* Turn off SM_DSP clock. */ 3040 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp);
3048 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
3049 MII_TG3_AUXCTL_ACTL_TX_6DB;
3050 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
3051 } 3041 }
3052 3042
3053 if (tp->link_config.autoneg == AUTONEG_DISABLE && 3043 if (tp->link_config.autoneg == AUTONEG_DISABLE &&