aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/tg3.c114
-rw-r--r--drivers/net/tg3.h33
2 files changed, 146 insertions, 1 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index afcc593108ce..f2d96ddd464e 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -1584,6 +1584,17 @@ static void tg3_phy_fini(struct tg3 *tp)
1584 } 1584 }
1585} 1585}
1586 1586
1587static int tg3_phydsp_read(struct tg3 *tp, u32 reg, u32 *val)
1588{
1589 int err;
1590
1591 err = tg3_writephy(tp, MII_TG3_DSP_ADDRESS, reg);
1592 if (!err)
1593 err = tg3_readphy(tp, MII_TG3_DSP_RW_PORT, val);
1594
1595 return err;
1596}
1597
1587static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val) 1598static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
1588{ 1599{
1589 int err; 1600 int err;
@@ -1747,6 +1758,42 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
1747 tg3_writephy(tp, MII_TG3_AUX_CTRL, phy); 1758 tg3_writephy(tp, MII_TG3_AUX_CTRL, phy);
1748} 1759}
1749 1760
1761static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
1762{
1763 u32 val;
1764
1765 if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP))
1766 return;
1767
1768 tp->setlpicnt = 0;
1769
1770 if (tp->link_config.autoneg == AUTONEG_ENABLE &&
1771 current_link_up == 1 &&
1772 (tp->link_config.active_speed == SPEED_1000 ||
1773 (tp->link_config.active_speed == SPEED_100 &&
1774 tp->link_config.active_duplex == DUPLEX_FULL))) {
1775 u32 eeectl;
1776
1777 if (tp->link_config.active_speed == SPEED_1000)
1778 eeectl = TG3_CPMU_EEE_CTRL_EXIT_16_5_US;
1779 else
1780 eeectl = TG3_CPMU_EEE_CTRL_EXIT_36_US;
1781
1782 tw32(TG3_CPMU_EEE_CTRL, eeectl);
1783
1784 tg3_phy_cl45_read(tp, 0x7, TG3_CL45_D7_EEERES_STAT, &val);
1785
1786 if (val == TG3_CL45_D7_EEERES_STAT_LP_1000T ||
1787 val == TG3_CL45_D7_EEERES_STAT_LP_100TX)
1788 tp->setlpicnt = 2;
1789 }
1790
1791 if (!tp->setlpicnt) {
1792 val = tr32(TG3_CPMU_EEE_MODE);
1793 tw32(TG3_CPMU_EEE_MODE, val & ~TG3_CPMU_EEEMD_LPI_ENABLE);
1794 }
1795}
1796
1750static int tg3_wait_macro_done(struct tg3 *tp) 1797static int tg3_wait_macro_done(struct tg3 *tp)
1751{ 1798{
1752 int limit = 100; 1799 int limit = 100;
@@ -2921,6 +2968,44 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
2921 tg3_writephy(tp, MII_TG3_CTRL, new_adv); 2968 tg3_writephy(tp, MII_TG3_CTRL, new_adv);
2922 } 2969 }
2923 2970
2971 if (tp->phy_flags & TG3_PHYFLG_EEE_CAP) {
2972 u32 val = 0;
2973
2974 tw32(TG3_CPMU_EEE_MODE,
2975 tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE);
2976
2977 /* Enable SM_DSP clock and tx 6dB coding. */
2978 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
2979 MII_TG3_AUXCTL_ACTL_SMDSP_ENA |
2980 MII_TG3_AUXCTL_ACTL_TX_6DB;
2981 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
2982
2983 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 ||
2984 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765) &&
2985 !tg3_phydsp_read(tp, MII_TG3_DSP_CH34TP2, &val))
2986 tg3_phydsp_write(tp, MII_TG3_DSP_CH34TP2,
2987 val | MII_TG3_DSP_CH34TP2_HIBW01);
2988
2989 if (tp->link_config.autoneg == AUTONEG_ENABLE) {
2990 /* Advertise 100-BaseTX EEE ability */
2991 if (tp->link_config.advertising &
2992 (ADVERTISED_100baseT_Half |
2993 ADVERTISED_100baseT_Full))
2994 val |= TG3_CL45_D7_EEEADV_CAP_100TX;
2995 /* Advertise 1000-BaseT EEE ability */
2996 if (tp->link_config.advertising &
2997 (ADVERTISED_1000baseT_Half |
2998 ADVERTISED_1000baseT_Full))
2999 val |= TG3_CL45_D7_EEEADV_CAP_1000T;
3000 }
3001 tg3_phy_cl45_write(tp, 0x7, TG3_CL45_D7_EEEADV_CAP, val);
3002
3003 /* Turn off SM_DSP clock. */
3004 val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL |
3005 MII_TG3_AUXCTL_ACTL_TX_6DB;
3006 tg3_writephy(tp, MII_TG3_AUX_CTRL, val);
3007 }
3008
2924 if (tp->link_config.autoneg == AUTONEG_DISABLE && 3009 if (tp->link_config.autoneg == AUTONEG_DISABLE &&
2925 tp->link_config.speed != SPEED_INVALID) { 3010 tp->link_config.speed != SPEED_INVALID) {
2926 u32 bmcr, orig_bmcr; 3011 u32 bmcr, orig_bmcr;
@@ -3282,6 +3367,8 @@ relink:
3282 tw32_f(MAC_MODE, tp->mac_mode); 3367 tw32_f(MAC_MODE, tp->mac_mode);
3283 udelay(40); 3368 udelay(40);
3284 3369
3370 tg3_phy_eee_adjust(tp, current_link_up);
3371
3285 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { 3372 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) {
3286 /* Polled via timer. */ 3373 /* Polled via timer. */
3287 tw32_f(MAC_EVENT, 0); 3374 tw32_f(MAC_EVENT, 0);
@@ -7790,6 +7877,22 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7790 tw32(TG3_CPMU_LSPD_10MB_CLK, val); 7877 tw32(TG3_CPMU_LSPD_10MB_CLK, val);
7791 } 7878 }
7792 7879
7880 /* Enable MAC control of LPI */
7881 if (tp->phy_flags & TG3_PHYFLG_EEE_CAP) {
7882 tw32_f(TG3_CPMU_EEE_LNKIDL_CTRL,
7883 TG3_CPMU_EEE_LNKIDL_PCIE_NL0 |
7884 TG3_CPMU_EEE_LNKIDL_UART_IDL);
7885
7886 tw32_f(TG3_CPMU_EEE_CTRL,
7887 TG3_CPMU_EEE_CTRL_EXIT_20_1_US);
7888
7889 tw32_f(TG3_CPMU_EEE_MODE,
7890 TG3_CPMU_EEEMD_ERLY_L1_XIT_DET |
7891 TG3_CPMU_EEEMD_LPI_IN_TX |
7892 TG3_CPMU_EEEMD_LPI_IN_RX |
7893 TG3_CPMU_EEEMD_EEE_ENABLE);
7894 }
7895
7793 /* This works around an issue with Athlon chipsets on 7896 /* This works around an issue with Athlon chipsets on
7794 * B3 tigon3 silicon. This bit has no effect on any 7897 * B3 tigon3 silicon. This bit has no effect on any
7795 * other revision. But do not set this on PCI Express 7898 * other revision. But do not set this on PCI Express
@@ -8598,6 +8701,12 @@ static void tg3_timer(unsigned long __opaque)
8598 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) 8701 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
8599 tg3_periodic_fetch_stats(tp); 8702 tg3_periodic_fetch_stats(tp);
8600 8703
8704 if (tp->setlpicnt && !--tp->setlpicnt) {
8705 u32 val = tr32(TG3_CPMU_EEE_MODE);
8706 tw32(TG3_CPMU_EEE_MODE,
8707 val | TG3_CPMU_EEEMD_LPI_ENABLE);
8708 }
8709
8601 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { 8710 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) {
8602 u32 mac_stat; 8711 u32 mac_stat;
8603 int phy_event; 8712 int phy_event;
@@ -12432,6 +12541,11 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
12432 } 12541 }
12433 } 12542 }
12434 12543
12544 if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 ||
12545 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 &&
12546 tp->pci_chip_rev_id != CHIPREV_ID_57765_A0))
12547 tp->phy_flags |= TG3_PHYFLG_EEE_CAP;
12548
12435 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) && 12549 if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) &&
12436 !(tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) && 12550 !(tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) &&
12437 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) { 12551 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 99fc30680217..8342190df0ff 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -1091,7 +1091,26 @@
1091#define CPMU_MUTEX_GNT_DRIVER 0x00001000 1091#define CPMU_MUTEX_GNT_DRIVER 0x00001000
1092#define TG3_CPMU_PHY_STRAP 0x00003664 1092#define TG3_CPMU_PHY_STRAP 0x00003664
1093#define TG3_CPMU_PHY_STRAP_IS_SERDES 0x00000020 1093#define TG3_CPMU_PHY_STRAP_IS_SERDES 0x00000020
1094/* 0x3664 --> 0x3800 unused */ 1094/* 0x3664 --> 0x36b0 unused */
1095
1096#define TG3_CPMU_EEE_MODE 0x000036b0
1097#define TG3_CPMU_EEEMD_ERLY_L1_XIT_DET 0x00000008
1098#define TG3_CPMU_EEEMD_LPI_ENABLE 0x00000080
1099#define TG3_CPMU_EEEMD_LPI_IN_TX 0x00000100
1100#define TG3_CPMU_EEEMD_LPI_IN_RX 0x00000200
1101#define TG3_CPMU_EEEMD_EEE_ENABLE 0x00100000
1102/* 0x36b4 --> 0x36b8 unused */
1103
1104#define TG3_CPMU_EEE_LNKIDL_CTRL 0x000036bc
1105#define TG3_CPMU_EEE_LNKIDL_PCIE_NL0 0x01000000
1106#define TG3_CPMU_EEE_LNKIDL_UART_IDL 0x00000004
1107/* 0x36c0 --> 0x36d0 unused */
1108
1109#define TG3_CPMU_EEE_CTRL 0x000036d0
1110#define TG3_CPMU_EEE_CTRL_EXIT_16_5_US 0x0000019d
1111#define TG3_CPMU_EEE_CTRL_EXIT_36_US 0x00000384
1112#define TG3_CPMU_EEE_CTRL_EXIT_20_1_US 0x000001f8
1113/* 0x36d4 --> 0x3800 unused */
1095 1114
1096/* Mbuf cluster free registers */ 1115/* Mbuf cluster free registers */
1097#define MBFREE_MODE 0x00003800 1116#define MBFREE_MODE 0x00003800
@@ -2082,6 +2101,8 @@
2082#define MII_TG3_DSP_TAP1 0x0001 2101#define MII_TG3_DSP_TAP1 0x0001
2083#define MII_TG3_DSP_TAP1_AGCTGT_DFLT 0x0007 2102#define MII_TG3_DSP_TAP1_AGCTGT_DFLT 0x0007
2084#define MII_TG3_DSP_AADJ1CH0 0x001f 2103#define MII_TG3_DSP_AADJ1CH0 0x001f
2104#define MII_TG3_DSP_CH34TP2 0x4022
2105#define MII_TG3_DSP_CH34TP2_HIBW01 0x0010
2085#define MII_TG3_DSP_AADJ1CH3 0x601f 2106#define MII_TG3_DSP_AADJ1CH3 0x601f
2086#define MII_TG3_DSP_AADJ1CH3_ADCCKADJ 0x0002 2107#define MII_TG3_DSP_AADJ1CH3_ADCCKADJ 0x0002
2087#define MII_TG3_DSP_EXP1_INT_STAT 0x0f01 2108#define MII_TG3_DSP_EXP1_INT_STAT 0x0f01
@@ -2148,6 +2169,14 @@
2148#define MII_TG3_TEST1_TRIM_EN 0x0010 2169#define MII_TG3_TEST1_TRIM_EN 0x0010
2149#define MII_TG3_TEST1_CRC_EN 0x8000 2170#define MII_TG3_TEST1_CRC_EN 0x8000
2150 2171
2172/* Clause 45 expansion registers */
2173#define TG3_CL45_D7_EEEADV_CAP 0x003c
2174#define TG3_CL45_D7_EEEADV_CAP_100TX 0x0002
2175#define TG3_CL45_D7_EEEADV_CAP_1000T 0x0004
2176#define TG3_CL45_D7_EEERES_STAT 0x803e
2177#define TG3_CL45_D7_EEERES_STAT_LP_100TX 0x0002
2178#define TG3_CL45_D7_EEERES_STAT_LP_1000T 0x0004
2179
2151 2180
2152/* Fast Ethernet Tranceiver definitions */ 2181/* Fast Ethernet Tranceiver definitions */
2153#define MII_TG3_FET_PTEST 0x17 2182#define MII_TG3_FET_PTEST 0x17
@@ -2992,9 +3021,11 @@ struct tg3 {
2992#define TG3_PHYFLG_BER_BUG 0x00008000 3021#define TG3_PHYFLG_BER_BUG 0x00008000
2993#define TG3_PHYFLG_SERDES_PREEMPHASIS 0x00010000 3022#define TG3_PHYFLG_SERDES_PREEMPHASIS 0x00010000
2994#define TG3_PHYFLG_PARALLEL_DETECT 0x00020000 3023#define TG3_PHYFLG_PARALLEL_DETECT 0x00020000
3024#define TG3_PHYFLG_EEE_CAP 0x00040000
2995 3025
2996 u32 led_ctrl; 3026 u32 led_ctrl;
2997 u32 phy_otp; 3027 u32 phy_otp;
3028 u32 setlpicnt;
2998 3029
2999#define TG3_BPN_SIZE 24 3030#define TG3_BPN_SIZE 24
3000 char board_part_number[TG3_BPN_SIZE]; 3031 char board_part_number[TG3_BPN_SIZE];