diff options
Diffstat (limited to 'drivers/net/r8169.c')
| -rw-r--r-- | drivers/net/r8169.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 469ab0b7ce31..7ffdb80adf40 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
| 26 | #include <linux/pm_runtime.h> | 26 | #include <linux/pm_runtime.h> |
| 27 | #include <linux/firmware.h> | 27 | #include <linux/firmware.h> |
| 28 | #include <linux/pci-aspm.h> | ||
| 28 | 29 | ||
| 29 | #include <asm/system.h> | 30 | #include <asm/system.h> |
| 30 | #include <asm/io.h> | 31 | #include <asm/io.h> |
| @@ -617,8 +618,9 @@ static void ocp_write(struct rtl8169_private *tp, u8 mask, u16 reg, u32 data) | |||
| 617 | } | 618 | } |
| 618 | } | 619 | } |
| 619 | 620 | ||
| 620 | static void rtl8168_oob_notify(void __iomem *ioaddr, u8 cmd) | 621 | static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd) |
| 621 | { | 622 | { |
| 623 | void __iomem *ioaddr = tp->mmio_addr; | ||
| 622 | int i; | 624 | int i; |
| 623 | 625 | ||
| 624 | RTL_W8(ERIDR, cmd); | 626 | RTL_W8(ERIDR, cmd); |
| @@ -630,7 +632,7 @@ static void rtl8168_oob_notify(void __iomem *ioaddr, u8 cmd) | |||
| 630 | break; | 632 | break; |
| 631 | } | 633 | } |
| 632 | 634 | ||
| 633 | ocp_write(ioaddr, 0x1, 0x30, 0x00000001); | 635 | ocp_write(tp, 0x1, 0x30, 0x00000001); |
| 634 | } | 636 | } |
| 635 | 637 | ||
| 636 | #define OOB_CMD_RESET 0x00 | 638 | #define OOB_CMD_RESET 0x00 |
| @@ -2868,8 +2870,11 @@ static void r8168_pll_power_down(struct rtl8169_private *tp) | |||
| 2868 | { | 2870 | { |
| 2869 | void __iomem *ioaddr = tp->mmio_addr; | 2871 | void __iomem *ioaddr = tp->mmio_addr; |
| 2870 | 2872 | ||
| 2871 | if (tp->mac_version == RTL_GIGA_MAC_VER_27) | 2873 | if (((tp->mac_version == RTL_GIGA_MAC_VER_27) || |
| 2874 | (tp->mac_version == RTL_GIGA_MAC_VER_28)) && | ||
| 2875 | (ocp_read(tp, 0x0f, 0x0010) & 0x00008000)) { | ||
| 2872 | return; | 2876 | return; |
| 2877 | } | ||
| 2873 | 2878 | ||
| 2874 | if (((tp->mac_version == RTL_GIGA_MAC_VER_23) || | 2879 | if (((tp->mac_version == RTL_GIGA_MAC_VER_23) || |
| 2875 | (tp->mac_version == RTL_GIGA_MAC_VER_24)) && | 2880 | (tp->mac_version == RTL_GIGA_MAC_VER_24)) && |
| @@ -2891,6 +2896,8 @@ static void r8168_pll_power_down(struct rtl8169_private *tp) | |||
| 2891 | switch (tp->mac_version) { | 2896 | switch (tp->mac_version) { |
| 2892 | case RTL_GIGA_MAC_VER_25: | 2897 | case RTL_GIGA_MAC_VER_25: |
| 2893 | case RTL_GIGA_MAC_VER_26: | 2898 | case RTL_GIGA_MAC_VER_26: |
| 2899 | case RTL_GIGA_MAC_VER_27: | ||
| 2900 | case RTL_GIGA_MAC_VER_28: | ||
| 2894 | RTL_W8(PMCH, RTL_R8(PMCH) & ~0x80); | 2901 | RTL_W8(PMCH, RTL_R8(PMCH) & ~0x80); |
| 2895 | break; | 2902 | break; |
| 2896 | } | 2903 | } |
| @@ -2900,12 +2907,17 @@ static void r8168_pll_power_up(struct rtl8169_private *tp) | |||
| 2900 | { | 2907 | { |
| 2901 | void __iomem *ioaddr = tp->mmio_addr; | 2908 | void __iomem *ioaddr = tp->mmio_addr; |
| 2902 | 2909 | ||
| 2903 | if (tp->mac_version == RTL_GIGA_MAC_VER_27) | 2910 | if (((tp->mac_version == RTL_GIGA_MAC_VER_27) || |
| 2911 | (tp->mac_version == RTL_GIGA_MAC_VER_28)) && | ||
| 2912 | (ocp_read(tp, 0x0f, 0x0010) & 0x00008000)) { | ||
| 2904 | return; | 2913 | return; |
| 2914 | } | ||
| 2905 | 2915 | ||
| 2906 | switch (tp->mac_version) { | 2916 | switch (tp->mac_version) { |
| 2907 | case RTL_GIGA_MAC_VER_25: | 2917 | case RTL_GIGA_MAC_VER_25: |
| 2908 | case RTL_GIGA_MAC_VER_26: | 2918 | case RTL_GIGA_MAC_VER_26: |
| 2919 | case RTL_GIGA_MAC_VER_27: | ||
| 2920 | case RTL_GIGA_MAC_VER_28: | ||
| 2909 | RTL_W8(PMCH, RTL_R8(PMCH) | 0x80); | 2921 | RTL_W8(PMCH, RTL_R8(PMCH) | 0x80); |
| 2910 | break; | 2922 | break; |
| 2911 | } | 2923 | } |
| @@ -3009,6 +3021,11 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 3009 | mii->reg_num_mask = 0x1f; | 3021 | mii->reg_num_mask = 0x1f; |
| 3010 | mii->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII); | 3022 | mii->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII); |
| 3011 | 3023 | ||
| 3024 | /* disable ASPM completely as that cause random device stop working | ||
| 3025 | * problems as well as full system hangs for some PCIe devices users */ | ||
| 3026 | pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | | ||
| 3027 | PCIE_LINK_STATE_CLKPM); | ||
| 3028 | |||
| 3012 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ | 3029 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ |
| 3013 | rc = pci_enable_device(pdev); | 3030 | rc = pci_enable_device(pdev); |
| 3014 | if (rc < 0) { | 3031 | if (rc < 0) { |
| @@ -3042,7 +3059,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 3042 | goto err_out_mwi_2; | 3059 | goto err_out_mwi_2; |
| 3043 | } | 3060 | } |
| 3044 | 3061 | ||
| 3045 | tp->cp_cmd = PCIMulRW | RxChkSum; | 3062 | tp->cp_cmd = RxChkSum; |
| 3046 | 3063 | ||
| 3047 | if ((sizeof(dma_addr_t) > 4) && | 3064 | if ((sizeof(dma_addr_t) > 4) && |
| 3048 | !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { | 3065 | !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { |
| @@ -3318,7 +3335,8 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp) | |||
| 3318 | /* Disable interrupts */ | 3335 | /* Disable interrupts */ |
| 3319 | rtl8169_irq_mask_and_ack(ioaddr); | 3336 | rtl8169_irq_mask_and_ack(ioaddr); |
| 3320 | 3337 | ||
| 3321 | if (tp->mac_version == RTL_GIGA_MAC_VER_28) { | 3338 | if (tp->mac_version == RTL_GIGA_MAC_VER_27 || |
| 3339 | tp->mac_version == RTL_GIGA_MAC_VER_28) { | ||
| 3322 | while (RTL_R8(TxPoll) & NPQ) | 3340 | while (RTL_R8(TxPoll) & NPQ) |
| 3323 | udelay(20); | 3341 | udelay(20); |
| 3324 | 3342 | ||
| @@ -3847,8 +3865,7 @@ static void rtl_hw_start_8168(struct net_device *dev) | |||
| 3847 | Cxpl_dbg_sel | \ | 3865 | Cxpl_dbg_sel | \ |
| 3848 | ASF | \ | 3866 | ASF | \ |
| 3849 | PktCntrDisable | \ | 3867 | PktCntrDisable | \ |
| 3850 | PCIDAC | \ | 3868 | Mac_dbgo_sel) |
| 3851 | PCIMulRW) | ||
| 3852 | 3869 | ||
| 3853 | static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev) | 3870 | static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev) |
| 3854 | { | 3871 | { |
| @@ -3878,8 +3895,6 @@ static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev) | |||
| 3878 | if ((cfg1 & LEDS0) && (cfg1 & LEDS1)) | 3895 | if ((cfg1 & LEDS0) && (cfg1 & LEDS1)) |
| 3879 | RTL_W8(Config1, cfg1 & ~LEDS0); | 3896 | RTL_W8(Config1, cfg1 & ~LEDS0); |
| 3880 | 3897 | ||
| 3881 | RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R810X_CPCMD_QUIRK_MASK); | ||
| 3882 | |||
| 3883 | rtl_ephy_init(ioaddr, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1)); | 3898 | rtl_ephy_init(ioaddr, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1)); |
| 3884 | } | 3899 | } |
| 3885 | 3900 | ||
| @@ -3891,8 +3906,6 @@ static void rtl_hw_start_8102e_2(void __iomem *ioaddr, struct pci_dev *pdev) | |||
| 3891 | 3906 | ||
| 3892 | RTL_W8(Config1, MEMMAP | IOMAP | VPD | PMEnable); | 3907 | RTL_W8(Config1, MEMMAP | IOMAP | VPD | PMEnable); |
| 3893 | RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); | 3908 | RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); |
| 3894 | |||
| 3895 | RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R810X_CPCMD_QUIRK_MASK); | ||
| 3896 | } | 3909 | } |
| 3897 | 3910 | ||
| 3898 | static void rtl_hw_start_8102e_3(void __iomem *ioaddr, struct pci_dev *pdev) | 3911 | static void rtl_hw_start_8102e_3(void __iomem *ioaddr, struct pci_dev *pdev) |
| @@ -3918,6 +3931,8 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
| 3918 | } | 3931 | } |
| 3919 | } | 3932 | } |
| 3920 | 3933 | ||
| 3934 | RTL_W8(Cfg9346, Cfg9346_Unlock); | ||
| 3935 | |||
| 3921 | switch (tp->mac_version) { | 3936 | switch (tp->mac_version) { |
| 3922 | case RTL_GIGA_MAC_VER_07: | 3937 | case RTL_GIGA_MAC_VER_07: |
| 3923 | rtl_hw_start_8102e_1(ioaddr, pdev); | 3938 | rtl_hw_start_8102e_1(ioaddr, pdev); |
| @@ -3932,14 +3947,13 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
| 3932 | break; | 3947 | break; |
| 3933 | } | 3948 | } |
| 3934 | 3949 | ||
| 3935 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 3950 | RTL_W8(Cfg9346, Cfg9346_Lock); |
| 3936 | 3951 | ||
| 3937 | RTL_W8(MaxTxPacketSize, TxPacketMax); | 3952 | RTL_W8(MaxTxPacketSize, TxPacketMax); |
| 3938 | 3953 | ||
| 3939 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); | 3954 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); |
| 3940 | 3955 | ||
| 3941 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; | 3956 | tp->cp_cmd &= ~R810X_CPCMD_QUIRK_MASK; |
| 3942 | |||
| 3943 | RTL_W16(CPlusCmd, tp->cp_cmd); | 3957 | RTL_W16(CPlusCmd, tp->cp_cmd); |
| 3944 | 3958 | ||
| 3945 | RTL_W16(IntrMitigate, 0x0000); | 3959 | RTL_W16(IntrMitigate, 0x0000); |
| @@ -3949,14 +3963,10 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
| 3949 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 3963 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
| 3950 | rtl_set_rx_tx_config_registers(tp); | 3964 | rtl_set_rx_tx_config_registers(tp); |
| 3951 | 3965 | ||
| 3952 | RTL_W8(Cfg9346, Cfg9346_Lock); | ||
| 3953 | |||
| 3954 | RTL_R8(IntrMask); | 3966 | RTL_R8(IntrMask); |
| 3955 | 3967 | ||
| 3956 | rtl_set_rx_mode(dev); | 3968 | rtl_set_rx_mode(dev); |
| 3957 | 3969 | ||
| 3958 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | ||
| 3959 | |||
| 3960 | RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000); | 3970 | RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000); |
| 3961 | 3971 | ||
| 3962 | RTL_W16(IntrMask, tp->intr_event); | 3972 | RTL_W16(IntrMask, tp->intr_event); |
