diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2008-11-21 20:18:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-21 20:18:59 -0500 |
commit | 6833c043f9fc03696fde623914c4a0277df2a0bc (patch) | |
tree | 2b8dbe4348da2182c7832a61ccac90512a819e36 | |
parent | 5e7dfd0fb94abed04f59481d1ce0cc06a892048a (diff) |
tg3: Enable GPHY APD on select devices
GPHY Autopowerdown (APD) is a way to save power when energy is not
detected on the wire. At the moment, only the 5784 and 5761 are
capable of enabling this mode.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/tg3.c | 52 | ||||
-rw-r--r-- | drivers/net/tg3.h | 2 |
2 files changed, 48 insertions, 6 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 659fb9978195..6972fe5ccbf6 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -1474,6 +1474,34 @@ static void tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val) | |||
1474 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, val); | 1474 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, val); |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | static void tg3_phy_toggle_apd(struct tg3 *tp, bool enable) | ||
1478 | { | ||
1479 | u32 reg; | ||
1480 | |||
1481 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) | ||
1482 | return; | ||
1483 | |||
1484 | reg = MII_TG3_MISC_SHDW_WREN | | ||
1485 | MII_TG3_MISC_SHDW_SCR5_SEL | | ||
1486 | MII_TG3_MISC_SHDW_SCR5_LPED | | ||
1487 | MII_TG3_MISC_SHDW_SCR5_DLPTLM | | ||
1488 | MII_TG3_MISC_SHDW_SCR5_SDTL | | ||
1489 | MII_TG3_MISC_SHDW_SCR5_C125OE; | ||
1490 | if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5784 || !enable) | ||
1491 | reg |= MII_TG3_MISC_SHDW_SCR5_DLLAPD; | ||
1492 | |||
1493 | tg3_writephy(tp, MII_TG3_MISC_SHDW, reg); | ||
1494 | |||
1495 | |||
1496 | reg = MII_TG3_MISC_SHDW_WREN | | ||
1497 | MII_TG3_MISC_SHDW_APD_SEL | | ||
1498 | MII_TG3_MISC_SHDW_APD_WKTM_84MS; | ||
1499 | if (enable) | ||
1500 | reg |= MII_TG3_MISC_SHDW_APD_ENABLE; | ||
1501 | |||
1502 | tg3_writephy(tp, MII_TG3_MISC_SHDW, reg); | ||
1503 | } | ||
1504 | |||
1477 | static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable) | 1505 | static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable) |
1478 | { | 1506 | { |
1479 | u32 phy; | 1507 | u32 phy; |
@@ -1816,16 +1844,15 @@ static int tg3_phy_reset(struct tg3 *tp) | |||
1816 | udelay(40); | 1844 | udelay(40); |
1817 | tw32_f(TG3_CPMU_LSPD_1000MB_CLK, val); | 1845 | tw32_f(TG3_CPMU_LSPD_1000MB_CLK, val); |
1818 | } | 1846 | } |
1819 | |||
1820 | /* Disable GPHY autopowerdown. */ | ||
1821 | tg3_writephy(tp, MII_TG3_MISC_SHDW, | ||
1822 | MII_TG3_MISC_SHDW_WREN | | ||
1823 | MII_TG3_MISC_SHDW_APD_SEL | | ||
1824 | MII_TG3_MISC_SHDW_APD_WKTM_84MS); | ||
1825 | } | 1847 | } |
1826 | 1848 | ||
1827 | tg3_phy_apply_otp(tp); | 1849 | tg3_phy_apply_otp(tp); |
1828 | 1850 | ||
1851 | if (tp->tg3_flags3 & TG3_FLG3_PHY_ENABLE_APD) | ||
1852 | tg3_phy_toggle_apd(tp, true); | ||
1853 | else | ||
1854 | tg3_phy_toggle_apd(tp, false); | ||
1855 | |||
1829 | out: | 1856 | out: |
1830 | if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) { | 1857 | if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) { |
1831 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); | 1858 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); |
@@ -10264,6 +10291,10 @@ static int tg3_test_loopback(struct tg3 *tp) | |||
10264 | if (err) | 10291 | if (err) |
10265 | return TG3_LOOPBACK_FAILED; | 10292 | return TG3_LOOPBACK_FAILED; |
10266 | 10293 | ||
10294 | /* Turn off gphy autopowerdown. */ | ||
10295 | if (tp->tg3_flags3 & TG3_FLG3_PHY_ENABLE_APD) | ||
10296 | tg3_phy_toggle_apd(tp, false); | ||
10297 | |||
10267 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || | 10298 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || |
10268 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 || | 10299 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 || |
10269 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) { | 10300 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) { |
@@ -10308,6 +10339,10 @@ static int tg3_test_loopback(struct tg3 *tp) | |||
10308 | err |= TG3_PHY_LOOPBACK_FAILED; | 10339 | err |= TG3_PHY_LOOPBACK_FAILED; |
10309 | } | 10340 | } |
10310 | 10341 | ||
10342 | /* Re-enable gphy autopowerdown. */ | ||
10343 | if (tp->tg3_flags3 & TG3_FLG3_PHY_ENABLE_APD) | ||
10344 | tg3_phy_toggle_apd(tp, true); | ||
10345 | |||
10311 | return err; | 10346 | return err; |
10312 | } | 10347 | } |
10313 | 10348 | ||
@@ -11596,6 +11631,11 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
11596 | if (cfg2 & (1 << 18)) | 11631 | if (cfg2 & (1 << 18)) |
11597 | tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS; | 11632 | tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS; |
11598 | 11633 | ||
11634 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 && | ||
11635 | GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5784_AX && | ||
11636 | (cfg2 & NIC_SRAM_DATA_CFG_2_APD_EN)) | ||
11637 | tp->tg3_flags3 |= TG3_FLG3_PHY_ENABLE_APD; | ||
11638 | |||
11599 | if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) { | 11639 | if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) { |
11600 | u32 cfg3; | 11640 | u32 cfg3; |
11601 | 11641 | ||
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 53684b9b83f9..eba62e2074ca 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -1822,6 +1822,7 @@ | |||
1822 | 1822 | ||
1823 | #define NIC_SRAM_DATA_CFG_2 0x00000d38 | 1823 | #define NIC_SRAM_DATA_CFG_2 0x00000d38 |
1824 | 1824 | ||
1825 | #define NIC_SRAM_DATA_CFG_2_APD_EN 0x00000400 | ||
1825 | #define SHASTA_EXT_LED_MODE_MASK 0x00018000 | 1826 | #define SHASTA_EXT_LED_MODE_MASK 0x00018000 |
1826 | #define SHASTA_EXT_LED_LEGACY 0x00000000 | 1827 | #define SHASTA_EXT_LED_LEGACY 0x00000000 |
1827 | #define SHASTA_EXT_LED_SHARED 0x00008000 | 1828 | #define SHASTA_EXT_LED_SHARED 0x00008000 |
@@ -2619,6 +2620,7 @@ struct tg3 { | |||
2619 | #define TG3_FLG3_RGMII_EXT_IBND_RX_EN 0x00000200 | 2620 | #define TG3_FLG3_RGMII_EXT_IBND_RX_EN 0x00000200 |
2620 | #define TG3_FLG3_RGMII_EXT_IBND_TX_EN 0x00000400 | 2621 | #define TG3_FLG3_RGMII_EXT_IBND_TX_EN 0x00000400 |
2621 | #define TG3_FLG3_CLKREQ_BUG 0x00000800 | 2622 | #define TG3_FLG3_CLKREQ_BUG 0x00000800 |
2623 | #define TG3_FLG3_PHY_ENABLE_APD 0x00001000 | ||
2622 | 2624 | ||
2623 | struct timer_list timer; | 2625 | struct timer_list timer; |
2624 | u16 timer_counter; | 2626 | u16 timer_counter; |