diff options
author | Hayes Wang <hayeswang@realtek.com> | 2011-09-06 04:55:18 -0400 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2011-09-22 05:35:26 -0400 |
commit | c2218925f3a653ac6c39e62eb0e10232d2b44dab (patch) | |
tree | dc3455c63fceb6c1e4eaa4f603ec7d53c5d97187 /drivers/net/ethernet/realtek | |
parent | 3090bd9a3102331ed981280ef05ee5433ce978d7 (diff) |
r8169: support new chips of RTL8111F
Support new chips of RTL8111F.
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Diffstat (limited to 'drivers/net/ethernet/realtek')
-rw-r--r-- | drivers/net/ethernet/realtek/r8169.c | 180 |
1 files changed, 178 insertions, 2 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 44b40ea1d443..9a5965e7bd15 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
@@ -42,6 +42,8 @@ | |||
42 | #define FIRMWARE_8168E_1 "rtl_nic/rtl8168e-1.fw" | 42 | #define FIRMWARE_8168E_1 "rtl_nic/rtl8168e-1.fw" |
43 | #define FIRMWARE_8168E_2 "rtl_nic/rtl8168e-2.fw" | 43 | #define FIRMWARE_8168E_2 "rtl_nic/rtl8168e-2.fw" |
44 | #define FIRMWARE_8168E_3 "rtl_nic/rtl8168e-3.fw" | 44 | #define FIRMWARE_8168E_3 "rtl_nic/rtl8168e-3.fw" |
45 | #define FIRMWARE_8168F_1 "rtl_nic/rtl8168f-1.fw" | ||
46 | #define FIRMWARE_8168F_2 "rtl_nic/rtl8168f-2.fw" | ||
45 | #define FIRMWARE_8105E_1 "rtl_nic/rtl8105e-1.fw" | 47 | #define FIRMWARE_8105E_1 "rtl_nic/rtl8105e-1.fw" |
46 | 48 | ||
47 | #ifdef RTL8169_DEBUG | 49 | #ifdef RTL8169_DEBUG |
@@ -133,6 +135,8 @@ enum mac_version { | |||
133 | RTL_GIGA_MAC_VER_32, | 135 | RTL_GIGA_MAC_VER_32, |
134 | RTL_GIGA_MAC_VER_33, | 136 | RTL_GIGA_MAC_VER_33, |
135 | RTL_GIGA_MAC_VER_34, | 137 | RTL_GIGA_MAC_VER_34, |
138 | RTL_GIGA_MAC_VER_35, | ||
139 | RTL_GIGA_MAC_VER_36, | ||
136 | RTL_GIGA_MAC_NONE = 0xff, | 140 | RTL_GIGA_MAC_NONE = 0xff, |
137 | }; | 141 | }; |
138 | 142 | ||
@@ -218,7 +222,11 @@ static const struct { | |||
218 | [RTL_GIGA_MAC_VER_33] = | 222 | [RTL_GIGA_MAC_VER_33] = |
219 | _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_2), | 223 | _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_2), |
220 | [RTL_GIGA_MAC_VER_34] = | 224 | [RTL_GIGA_MAC_VER_34] = |
221 | _R("RTL8168evl/8111evl",RTL_TD_1, FIRMWARE_8168E_3) | 225 | _R("RTL8168evl/8111evl",RTL_TD_1, FIRMWARE_8168E_3), |
226 | [RTL_GIGA_MAC_VER_35] = | ||
227 | _R("RTL8168f/8111f", RTL_TD_1, FIRMWARE_8168F_1), | ||
228 | [RTL_GIGA_MAC_VER_36] = | ||
229 | _R("RTL8168f/8111f", RTL_TD_1, FIRMWARE_8168F_2) | ||
222 | }; | 230 | }; |
223 | #undef _R | 231 | #undef _R |
224 | 232 | ||
@@ -715,6 +723,8 @@ MODULE_FIRMWARE(FIRMWARE_8168E_1); | |||
715 | MODULE_FIRMWARE(FIRMWARE_8168E_2); | 723 | MODULE_FIRMWARE(FIRMWARE_8168E_2); |
716 | MODULE_FIRMWARE(FIRMWARE_8168E_3); | 724 | MODULE_FIRMWARE(FIRMWARE_8168E_3); |
717 | MODULE_FIRMWARE(FIRMWARE_8105E_1); | 725 | MODULE_FIRMWARE(FIRMWARE_8105E_1); |
726 | MODULE_FIRMWARE(FIRMWARE_8168F_1); | ||
727 | MODULE_FIRMWARE(FIRMWARE_8168F_2); | ||
718 | 728 | ||
719 | static int rtl8169_open(struct net_device *dev); | 729 | static int rtl8169_open(struct net_device *dev); |
720 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | 730 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, |
@@ -1203,6 +1213,19 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp) | |||
1203 | ERIAR_EXGMAC); | 1213 | ERIAR_EXGMAC); |
1204 | rtl_w1w0_eri(ioaddr, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, | 1214 | rtl_w1w0_eri(ioaddr, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, |
1205 | ERIAR_EXGMAC); | 1215 | ERIAR_EXGMAC); |
1216 | } else if (tp->mac_version == RTL_GIGA_MAC_VER_35 || | ||
1217 | tp->mac_version == RTL_GIGA_MAC_VER_36) { | ||
1218 | if (RTL_R8(PHYstatus) & _1000bpsF) { | ||
1219 | rtl_eri_write(ioaddr, 0x1bc, ERIAR_MASK_1111, | ||
1220 | 0x00000011, ERIAR_EXGMAC); | ||
1221 | rtl_eri_write(ioaddr, 0x1dc, ERIAR_MASK_1111, | ||
1222 | 0x00000005, ERIAR_EXGMAC); | ||
1223 | } else { | ||
1224 | rtl_eri_write(ioaddr, 0x1bc, ERIAR_MASK_1111, | ||
1225 | 0x0000001f, ERIAR_EXGMAC); | ||
1226 | rtl_eri_write(ioaddr, 0x1dc, ERIAR_MASK_1111, | ||
1227 | 0x0000003f, ERIAR_EXGMAC); | ||
1228 | } | ||
1206 | } | 1229 | } |
1207 | } | 1230 | } |
1208 | 1231 | ||
@@ -1742,6 +1765,10 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, | |||
1742 | u32 val; | 1765 | u32 val; |
1743 | int mac_version; | 1766 | int mac_version; |
1744 | } mac_info[] = { | 1767 | } mac_info[] = { |
1768 | /* 8168F family. */ | ||
1769 | { 0x7cf00000, 0x48100000, RTL_GIGA_MAC_VER_36 }, | ||
1770 | { 0x7cf00000, 0x48000000, RTL_GIGA_MAC_VER_35 }, | ||
1771 | |||
1745 | /* 8168E family. */ | 1772 | /* 8168E family. */ |
1746 | { 0x7c800000, 0x2c800000, RTL_GIGA_MAC_VER_34 }, | 1773 | { 0x7c800000, 0x2c800000, RTL_GIGA_MAC_VER_34 }, |
1747 | { 0x7cf00000, 0x2c200000, RTL_GIGA_MAC_VER_33 }, | 1774 | { 0x7cf00000, 0x2c200000, RTL_GIGA_MAC_VER_33 }, |
@@ -2876,6 +2903,97 @@ static void rtl8168e_2_hw_phy_config(struct rtl8169_private *tp) | |||
2876 | rtl_writephy(tp, 0x1f, 0x0000); | 2903 | rtl_writephy(tp, 0x1f, 0x0000); |
2877 | } | 2904 | } |
2878 | 2905 | ||
2906 | static void rtl8168f_1_hw_phy_config(struct rtl8169_private *tp) | ||
2907 | { | ||
2908 | static const struct phy_reg phy_reg_init[] = { | ||
2909 | /* Channel estimation fine tune */ | ||
2910 | { 0x1f, 0x0003 }, | ||
2911 | { 0x09, 0xa20f }, | ||
2912 | { 0x1f, 0x0000 }, | ||
2913 | |||
2914 | /* Modify green table for giga & fnet */ | ||
2915 | { 0x1f, 0x0005 }, | ||
2916 | { 0x05, 0x8b55 }, | ||
2917 | { 0x06, 0x0000 }, | ||
2918 | { 0x05, 0x8b5e }, | ||
2919 | { 0x06, 0x0000 }, | ||
2920 | { 0x05, 0x8b67 }, | ||
2921 | { 0x06, 0x0000 }, | ||
2922 | { 0x05, 0x8b70 }, | ||
2923 | { 0x06, 0x0000 }, | ||
2924 | { 0x1f, 0x0000 }, | ||
2925 | { 0x1f, 0x0007 }, | ||
2926 | { 0x1e, 0x0078 }, | ||
2927 | { 0x17, 0x0000 }, | ||
2928 | { 0x19, 0x00fb }, | ||
2929 | { 0x1f, 0x0000 }, | ||
2930 | |||
2931 | /* Modify green table for 10M */ | ||
2932 | { 0x1f, 0x0005 }, | ||
2933 | { 0x05, 0x8b79 }, | ||
2934 | { 0x06, 0xaa00 }, | ||
2935 | { 0x1f, 0x0000 }, | ||
2936 | |||
2937 | /* Disable hiimpedance detection (RTCT) */ | ||
2938 | { 0x1f, 0x0003 }, | ||
2939 | { 0x01, 0x328a }, | ||
2940 | { 0x1f, 0x0000 } | ||
2941 | }; | ||
2942 | |||
2943 | rtl_apply_firmware(tp); | ||
2944 | |||
2945 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
2946 | |||
2947 | /* For 4-corner performance improve */ | ||
2948 | rtl_writephy(tp, 0x1f, 0x0005); | ||
2949 | rtl_writephy(tp, 0x05, 0x8b80); | ||
2950 | rtl_w1w0_phy(tp, 0x06, 0x0006, 0x0000); | ||
2951 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2952 | |||
2953 | /* PHY auto speed down */ | ||
2954 | rtl_writephy(tp, 0x1f, 0x0007); | ||
2955 | rtl_writephy(tp, 0x1e, 0x002d); | ||
2956 | rtl_w1w0_phy(tp, 0x18, 0x0010, 0x0000); | ||
2957 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2958 | rtl_w1w0_phy(tp, 0x14, 0x8000, 0x0000); | ||
2959 | |||
2960 | /* Improve 10M EEE waveform */ | ||
2961 | rtl_writephy(tp, 0x1f, 0x0005); | ||
2962 | rtl_writephy(tp, 0x05, 0x8b86); | ||
2963 | rtl_w1w0_phy(tp, 0x06, 0x0001, 0x0000); | ||
2964 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2965 | |||
2966 | /* Improve 2-pair detection performance */ | ||
2967 | rtl_writephy(tp, 0x1f, 0x0005); | ||
2968 | rtl_writephy(tp, 0x05, 0x8b85); | ||
2969 | rtl_w1w0_phy(tp, 0x06, 0x4000, 0x0000); | ||
2970 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2971 | } | ||
2972 | |||
2973 | static void rtl8168f_2_hw_phy_config(struct rtl8169_private *tp) | ||
2974 | { | ||
2975 | rtl_apply_firmware(tp); | ||
2976 | |||
2977 | /* For 4-corner performance improve */ | ||
2978 | rtl_writephy(tp, 0x1f, 0x0005); | ||
2979 | rtl_writephy(tp, 0x05, 0x8b80); | ||
2980 | rtl_w1w0_phy(tp, 0x06, 0x0006, 0x0000); | ||
2981 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2982 | |||
2983 | /* PHY auto speed down */ | ||
2984 | rtl_writephy(tp, 0x1f, 0x0007); | ||
2985 | rtl_writephy(tp, 0x1e, 0x002d); | ||
2986 | rtl_w1w0_phy(tp, 0x18, 0x0010, 0x0000); | ||
2987 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2988 | rtl_w1w0_phy(tp, 0x14, 0x8000, 0x0000); | ||
2989 | |||
2990 | /* Improve 10M EEE waveform */ | ||
2991 | rtl_writephy(tp, 0x1f, 0x0005); | ||
2992 | rtl_writephy(tp, 0x05, 0x8b86); | ||
2993 | rtl_w1w0_phy(tp, 0x06, 0x0001, 0x0000); | ||
2994 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2995 | } | ||
2996 | |||
2879 | static void rtl8102e_hw_phy_config(struct rtl8169_private *tp) | 2997 | static void rtl8102e_hw_phy_config(struct rtl8169_private *tp) |
2880 | { | 2998 | { |
2881 | static const struct phy_reg phy_reg_init[] = { | 2999 | static const struct phy_reg phy_reg_init[] = { |
@@ -3000,6 +3118,12 @@ static void rtl_hw_phy_config(struct net_device *dev) | |||
3000 | case RTL_GIGA_MAC_VER_34: | 3118 | case RTL_GIGA_MAC_VER_34: |
3001 | rtl8168e_2_hw_phy_config(tp); | 3119 | rtl8168e_2_hw_phy_config(tp); |
3002 | break; | 3120 | break; |
3121 | case RTL_GIGA_MAC_VER_35: | ||
3122 | rtl8168f_1_hw_phy_config(tp); | ||
3123 | break; | ||
3124 | case RTL_GIGA_MAC_VER_36: | ||
3125 | rtl8168f_2_hw_phy_config(tp); | ||
3126 | break; | ||
3003 | 3127 | ||
3004 | default: | 3128 | default: |
3005 | break; | 3129 | break; |
@@ -3535,6 +3659,8 @@ static void __devinit rtl_init_pll_power_ops(struct rtl8169_private *tp) | |||
3535 | case RTL_GIGA_MAC_VER_32: | 3659 | case RTL_GIGA_MAC_VER_32: |
3536 | case RTL_GIGA_MAC_VER_33: | 3660 | case RTL_GIGA_MAC_VER_33: |
3537 | case RTL_GIGA_MAC_VER_34: | 3661 | case RTL_GIGA_MAC_VER_34: |
3662 | case RTL_GIGA_MAC_VER_35: | ||
3663 | case RTL_GIGA_MAC_VER_36: | ||
3538 | ops->down = r8168_pll_power_down; | 3664 | ops->down = r8168_pll_power_down; |
3539 | ops->up = r8168_pll_power_up; | 3665 | ops->up = r8168_pll_power_up; |
3540 | break; | 3666 | break; |
@@ -4009,7 +4135,9 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp) | |||
4009 | tp->mac_version == RTL_GIGA_MAC_VER_31) { | 4135 | tp->mac_version == RTL_GIGA_MAC_VER_31) { |
4010 | while (RTL_R8(TxPoll) & NPQ) | 4136 | while (RTL_R8(TxPoll) & NPQ) |
4011 | udelay(20); | 4137 | udelay(20); |
4012 | } else if (tp->mac_version == RTL_GIGA_MAC_VER_34) { | 4138 | } else if (tp->mac_version == RTL_GIGA_MAC_VER_34 || |
4139 | tp->mac_version == RTL_GIGA_MAC_VER_35 || | ||
4140 | tp->mac_version == RTL_GIGA_MAC_VER_36) { | ||
4013 | RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq); | 4141 | RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq); |
4014 | while (!(RTL_R32(TxConfig) & TXCFG_EMPTY)) | 4142 | while (!(RTL_R32(TxConfig) & TXCFG_EMPTY)) |
4015 | udelay(100); | 4143 | udelay(100); |
@@ -4495,6 +4623,49 @@ static void rtl_hw_start_8168e_2(void __iomem *ioaddr, struct pci_dev *pdev) | |||
4495 | RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); | 4623 | RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); |
4496 | } | 4624 | } |
4497 | 4625 | ||
4626 | static void rtl_hw_start_8168f_1(void __iomem *ioaddr, struct pci_dev *pdev) | ||
4627 | { | ||
4628 | static const struct ephy_info e_info_8168f_1[] = { | ||
4629 | { 0x06, 0x00c0, 0x0020 }, | ||
4630 | { 0x08, 0x0001, 0x0002 }, | ||
4631 | { 0x09, 0x0000, 0x0080 }, | ||
4632 | { 0x19, 0x0000, 0x0224 } | ||
4633 | }; | ||
4634 | |||
4635 | rtl_csi_access_enable_1(ioaddr); | ||
4636 | |||
4637 | rtl_ephy_init(ioaddr, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1)); | ||
4638 | |||
4639 | rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); | ||
4640 | |||
4641 | rtl_eri_write(ioaddr, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); | ||
4642 | rtl_eri_write(ioaddr, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); | ||
4643 | rtl_eri_write(ioaddr, 0xc8, ERIAR_MASK_1111, 0x00100002, ERIAR_EXGMAC); | ||
4644 | rtl_eri_write(ioaddr, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC); | ||
4645 | rtl_w1w0_eri(ioaddr, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC); | ||
4646 | rtl_w1w0_eri(ioaddr, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC); | ||
4647 | rtl_w1w0_eri(ioaddr, 0x1b0, ERIAR_MASK_0001, 0x10, 0x00, ERIAR_EXGMAC); | ||
4648 | rtl_w1w0_eri(ioaddr, 0x1d0, ERIAR_MASK_0001, 0x10, 0x00, ERIAR_EXGMAC); | ||
4649 | rtl_eri_write(ioaddr, 0xcc, ERIAR_MASK_1111, 0x00000050, ERIAR_EXGMAC); | ||
4650 | rtl_eri_write(ioaddr, 0xd0, ERIAR_MASK_1111, 0x00000060, ERIAR_EXGMAC); | ||
4651 | rtl_w1w0_eri(ioaddr, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0xff00, | ||
4652 | ERIAR_EXGMAC); | ||
4653 | |||
4654 | RTL_W8(MaxTxPacketSize, EarlySize); | ||
4655 | |||
4656 | rtl_disable_clock_request(pdev); | ||
4657 | |||
4658 | RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO); | ||
4659 | RTL_W8(MCU, RTL_R8(MCU) & ~NOW_IS_OOB); | ||
4660 | |||
4661 | /* Adjust EEE LED frequency */ | ||
4662 | RTL_W8(EEE_LED, RTL_R8(EEE_LED) & ~0x07); | ||
4663 | |||
4664 | RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN); | ||
4665 | RTL_W32(MISC, RTL_R32(MISC) | PWM_EN); | ||
4666 | RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); | ||
4667 | } | ||
4668 | |||
4498 | static void rtl_hw_start_8168(struct net_device *dev) | 4669 | static void rtl_hw_start_8168(struct net_device *dev) |
4499 | { | 4670 | { |
4500 | struct rtl8169_private *tp = netdev_priv(dev); | 4671 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -4589,6 +4760,11 @@ static void rtl_hw_start_8168(struct net_device *dev) | |||
4589 | rtl_hw_start_8168e_2(ioaddr, pdev); | 4760 | rtl_hw_start_8168e_2(ioaddr, pdev); |
4590 | break; | 4761 | break; |
4591 | 4762 | ||
4763 | case RTL_GIGA_MAC_VER_35: | ||
4764 | case RTL_GIGA_MAC_VER_36: | ||
4765 | rtl_hw_start_8168f_1(ioaddr, pdev); | ||
4766 | break; | ||
4767 | |||
4592 | default: | 4768 | default: |
4593 | printk(KERN_ERR PFX "%s: unknown chipset (mac_version = %d).\n", | 4769 | printk(KERN_ERR PFX "%s: unknown chipset (mac_version = %d).\n", |
4594 | dev->name, tp->mac_version); | 4770 | dev->name, tp->mac_version); |