BACKPORT: r8169: enable internal ASPM and clock request settings
authorhayeswang <hayeswang@realtek.com>
Thu, 1 Nov 2012 16:46:28 +0000 (16:46 +0000)
committerGerrit <chrome-bot@google.com>
Tue, 6 Nov 2012 21:22:27 +0000 (13:22 -0800)
The following chips need to enable internal settings to let ASPM
and clock request work.

RTL8111E-VL, RTL8111F, RTL8411, RTL8111G
RTL8105, RTL8402, RTL8106

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit d64ec841517a25f6d468bde9f67e5b4cffdc67c7)

Resolve conflicts as follows:

In the original CL, changes are made to many chip-specific configuration
functions, such as rtl_hw_start_8168e_2, rtl_hw_start_8402, etc. Our
source is missing some of these configuration functions and others do
not integrate cleanly. Therefore, only apply the changes to the hw_start
functions that integrate cleanly:

rtl_hw_start_8168e_2
rtl_hw_start_8105e_1

TEST=Confirm basic functionality on 8168e and 8105e cards.
BUG=chrome-os-partner:15923

Change-Id: Ib790aeb102920e127c43f74a9643e89afdffc251
Reviewed-on: https://gerrit.chromium.org/gerrit/37418
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Commit-Ready: Shawn Nematbakhsh <shawnn@google.com>
Tested-by: Shawn Nematbakhsh <shawnn@google.com>
drivers/net/ethernet/realtek/r8169.c

index 5d08cde..47c3fbc 100644 (file)
@@ -419,6 +419,7 @@ enum rtl8168_registers {
        MISC                    = 0xf0, /* 8168e only. */
 #define TXPLA_RST                      (1 << 29)
 #define PWM_EN                         (1 << 22)
+#define FORCE_CLK                      (1 << 15) /* force clock request */
 };
 
 enum rtl_register_content {
@@ -482,6 +483,7 @@ enum rtl_register_content {
        PMEnable        = (1 << 0),     /* Power Management Enable */
 
        /* Config2 register p. 25 */
+       ClkReqEn        = (1 << 7),     /* Clock Request Enable */
        MSIEnable       = (1 << 5),     /* 8169 only. Reserved in the 8168. */
        PCI_Clock_66MHz = 0x01,
        PCI_Clock_33MHz = 0x00,
@@ -502,6 +504,7 @@ enum rtl_register_content {
        Spi_en          = (1 << 3),
        LanWake         = (1 << 1),     /* LanWake enable/disable */
        PMEStatus       = (1 << 0),     /* PME status can be reset by PCI RST# */
+       ASPM_en         = (1 << 0),     /* ASPM enable */
 
        /* TBICSR p.28 */
        TBIReset        = 0x80000000,
@@ -4512,8 +4515,6 @@ static void rtl_hw_start_8168e_2(void __iomem *ioaddr, struct pci_dev *pdev)
 
        RTL_W8(MaxTxPacketSize, EarlySize);
 
-       rtl_disable_clock_request(pdev);
-
        RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO);
        RTL_W8(MCU, RTL_R8(MCU) & ~NOW_IS_OOB);
 
@@ -4522,7 +4523,8 @@ static void rtl_hw_start_8168e_2(void __iomem *ioaddr, struct pci_dev *pdev)
 
        RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN);
        RTL_W32(MISC, RTL_R32(MISC) | PWM_EN);
-       RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
+       RTL_W8(Config5, (RTL_R8(Config5) & ~Spi_en) | ASPM_en);
+       RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
 }
 
 static void rtl_hw_start_8168f_1(void __iomem *ioaddr, struct pci_dev *pdev)
@@ -4759,6 +4761,9 @@ static void rtl_hw_start_8105e_1(void __iomem *ioaddr, struct pci_dev *pdev)
 
        RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET);
        RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN);
+       RTL_W8(Config5, RTL_R8(Config5) | ASPM_en);
+       RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
+       RTL_W32(MISC, RTL_R32(MISC) | FORCE_CLK);
 
        rtl_ephy_init(ioaddr, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1));
 }