aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHayes Wang <hayeswang@realtek.com>2011-07-06 03:58:06 -0400
committerFrancois Romieu <romieu@fr.zoreil.com>2011-07-14 17:22:32 -0400
commit70090424e59652c4b2e777b533cc23134b176b83 (patch)
tree72d36b249fb61f4d509ffa991293900c1c1f4c2e
parent133ac40ac26a6cba957ad5765892f0531ba6ccee (diff)
r8169: support RTL8111E-VL.
Signed-off-by: Hayes Wang <hayeswang@realtek.com> Acked-by: Francois Romieu <romieu@fr.zoreil.com>
-rw-r--r--drivers/net/r8169.c186
1 files changed, 179 insertions, 7 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index a983eaaaf2e3..ecfaf5634f53 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -41,6 +41,7 @@
41#define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw" 41#define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw"
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_8105E_1 "rtl_nic/rtl8105e-1.fw" 45#define FIRMWARE_8105E_1 "rtl_nic/rtl8105e-1.fw"
45 46
46#ifdef RTL8169_DEBUG 47#ifdef RTL8169_DEBUG
@@ -131,6 +132,7 @@ enum mac_version {
131 RTL_GIGA_MAC_VER_31, 132 RTL_GIGA_MAC_VER_31,
132 RTL_GIGA_MAC_VER_32, 133 RTL_GIGA_MAC_VER_32,
133 RTL_GIGA_MAC_VER_33, 134 RTL_GIGA_MAC_VER_33,
135 RTL_GIGA_MAC_VER_34,
134 RTL_GIGA_MAC_NONE = 0xff, 136 RTL_GIGA_MAC_NONE = 0xff,
135}; 137};
136 138
@@ -214,7 +216,9 @@ static const struct {
214 [RTL_GIGA_MAC_VER_32] = 216 [RTL_GIGA_MAC_VER_32] =
215 _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_1), 217 _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_1),
216 [RTL_GIGA_MAC_VER_33] = 218 [RTL_GIGA_MAC_VER_33] =
217 _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_2) 219 _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_2),
220 [RTL_GIGA_MAC_VER_34] =
221 _R("RTL8168evl/8111evl",RTL_TD_1, FIRMWARE_8168E_3)
218}; 222};
219#undef _R 223#undef _R
220 224
@@ -1151,6 +1155,39 @@ static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp)
1151 rtl_writephy(tp, MII_BMCR, val & 0xffff); 1155 rtl_writephy(tp, MII_BMCR, val & 0xffff);
1152} 1156}
1153 1157
1158static void rtl_link_chg_patch(struct rtl8169_private *tp)
1159{
1160 void __iomem *ioaddr = tp->mmio_addr;
1161 struct net_device *dev = tp->dev;
1162
1163 if (!netif_running(dev))
1164 return;
1165
1166 if (tp->mac_version == RTL_GIGA_MAC_VER_34) {
1167 if (RTL_R8(PHYstatus) & _1000bpsF) {
1168 rtl_eri_write(ioaddr, 0x1bc, ERIAR_MASK_1111,
1169 0x00000011, ERIAR_EXGMAC);
1170 rtl_eri_write(ioaddr, 0x1dc, ERIAR_MASK_1111,
1171 0x00000005, ERIAR_EXGMAC);
1172 } else if (RTL_R8(PHYstatus) & _100bps) {
1173 rtl_eri_write(ioaddr, 0x1bc, ERIAR_MASK_1111,
1174 0x0000001f, ERIAR_EXGMAC);
1175 rtl_eri_write(ioaddr, 0x1dc, ERIAR_MASK_1111,
1176 0x00000005, ERIAR_EXGMAC);
1177 } else {
1178 rtl_eri_write(ioaddr, 0x1bc, ERIAR_MASK_1111,
1179 0x0000001f, ERIAR_EXGMAC);
1180 rtl_eri_write(ioaddr, 0x1dc, ERIAR_MASK_1111,
1181 0x0000003f, ERIAR_EXGMAC);
1182 }
1183 /* Reset packet filter */
1184 rtl_w1w0_eri(ioaddr, 0xdc, ERIAR_MASK_0001, 0x00, 0x01,
1185 ERIAR_EXGMAC);
1186 rtl_w1w0_eri(ioaddr, 0xdc, ERIAR_MASK_0001, 0x01, 0x00,
1187 ERIAR_EXGMAC);
1188 }
1189}
1190
1154static void __rtl8169_check_link_status(struct net_device *dev, 1191static void __rtl8169_check_link_status(struct net_device *dev,
1155 struct rtl8169_private *tp, 1192 struct rtl8169_private *tp,
1156 void __iomem *ioaddr, bool pm) 1193 void __iomem *ioaddr, bool pm)
@@ -1159,6 +1196,7 @@ static void __rtl8169_check_link_status(struct net_device *dev,
1159 1196
1160 spin_lock_irqsave(&tp->lock, flags); 1197 spin_lock_irqsave(&tp->lock, flags);
1161 if (tp->link_ok(ioaddr)) { 1198 if (tp->link_ok(ioaddr)) {
1199 rtl_link_chg_patch(tp);
1162 /* This is to cancel a scheduled suspend if there's one. */ 1200 /* This is to cancel a scheduled suspend if there's one. */
1163 if (pm) 1201 if (pm)
1164 pm_request_resume(&tp->pci_dev->dev); 1202 pm_request_resume(&tp->pci_dev->dev);
@@ -1687,6 +1725,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
1687 int mac_version; 1725 int mac_version;
1688 } mac_info[] = { 1726 } mac_info[] = {
1689 /* 8168E family. */ 1727 /* 8168E family. */
1728 { 0x7c800000, 0x2c800000, RTL_GIGA_MAC_VER_34 },
1690 { 0x7cf00000, 0x2c200000, RTL_GIGA_MAC_VER_33 }, 1729 { 0x7cf00000, 0x2c200000, RTL_GIGA_MAC_VER_33 },
1691 { 0x7cf00000, 0x2c100000, RTL_GIGA_MAC_VER_32 }, 1730 { 0x7cf00000, 0x2c100000, RTL_GIGA_MAC_VER_32 },
1692 { 0x7c800000, 0x2c000000, RTL_GIGA_MAC_VER_33 }, 1731 { 0x7c800000, 0x2c000000, RTL_GIGA_MAC_VER_33 },
@@ -2664,7 +2703,7 @@ static void rtl8168d_4_hw_phy_config(struct rtl8169_private *tp)
2664 rtl_patchphy(tp, 0x0d, 1 << 5); 2703 rtl_patchphy(tp, 0x0d, 1 << 5);
2665} 2704}
2666 2705
2667static void rtl8168e_hw_phy_config(struct rtl8169_private *tp) 2706static void rtl8168e_1_hw_phy_config(struct rtl8169_private *tp)
2668{ 2707{
2669 static const struct phy_reg phy_reg_init[] = { 2708 static const struct phy_reg phy_reg_init[] = {
2670 /* Enable Delay cap */ 2709 /* Enable Delay cap */
@@ -2737,6 +2776,91 @@ static void rtl8168e_hw_phy_config(struct rtl8169_private *tp)
2737 rtl_writephy(tp, 0x0d, 0x0000); 2776 rtl_writephy(tp, 0x0d, 0x0000);
2738} 2777}
2739 2778
2779static void rtl8168e_2_hw_phy_config(struct rtl8169_private *tp)
2780{
2781 static const struct phy_reg phy_reg_init[] = {
2782 /* Enable Delay cap */
2783 { 0x1f, 0x0004 },
2784 { 0x1f, 0x0007 },
2785 { 0x1e, 0x00ac },
2786 { 0x18, 0x0006 },
2787 { 0x1f, 0x0002 },
2788 { 0x1f, 0x0000 },
2789 { 0x1f, 0x0000 },
2790
2791 /* Channel estimation fine tune */
2792 { 0x1f, 0x0003 },
2793 { 0x09, 0xa20f },
2794 { 0x1f, 0x0000 },
2795 { 0x1f, 0x0000 },
2796
2797 /* Green Setting */
2798 { 0x1f, 0x0005 },
2799 { 0x05, 0x8b5b },
2800 { 0x06, 0x9222 },
2801 { 0x05, 0x8b6d },
2802 { 0x06, 0x8000 },
2803 { 0x05, 0x8b76 },
2804 { 0x06, 0x8000 },
2805 { 0x1f, 0x0000 }
2806 };
2807
2808 rtl_apply_firmware(tp);
2809
2810 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
2811
2812 /* For 4-corner performance improve */
2813 rtl_writephy(tp, 0x1f, 0x0005);
2814 rtl_writephy(tp, 0x05, 0x8b80);
2815 rtl_w1w0_phy(tp, 0x17, 0x0006, 0x0000);
2816 rtl_writephy(tp, 0x1f, 0x0000);
2817
2818 /* PHY auto speed down */
2819 rtl_writephy(tp, 0x1f, 0x0004);
2820 rtl_writephy(tp, 0x1f, 0x0007);
2821 rtl_writephy(tp, 0x1e, 0x002d);
2822 rtl_w1w0_phy(tp, 0x18, 0x0010, 0x0000);
2823 rtl_writephy(tp, 0x1f, 0x0002);
2824 rtl_writephy(tp, 0x1f, 0x0000);
2825 rtl_w1w0_phy(tp, 0x14, 0x8000, 0x0000);
2826
2827 /* improve 10M EEE waveform */
2828 rtl_writephy(tp, 0x1f, 0x0005);
2829 rtl_writephy(tp, 0x05, 0x8b86);
2830 rtl_w1w0_phy(tp, 0x06, 0x0001, 0x0000);
2831 rtl_writephy(tp, 0x1f, 0x0000);
2832
2833 /* Improve 2-pair detection performance */
2834 rtl_writephy(tp, 0x1f, 0x0005);
2835 rtl_writephy(tp, 0x05, 0x8b85);
2836 rtl_w1w0_phy(tp, 0x06, 0x4000, 0x0000);
2837 rtl_writephy(tp, 0x1f, 0x0000);
2838
2839 /* EEE setting */
2840 rtl_w1w0_eri(tp->mmio_addr, 0x1b0, ERIAR_MASK_1111, 0x0000, 0x0003,
2841 ERIAR_EXGMAC);
2842 rtl_writephy(tp, 0x1f, 0x0005);
2843 rtl_writephy(tp, 0x05, 0x8b85);
2844 rtl_w1w0_phy(tp, 0x06, 0x0000, 0x2000);
2845 rtl_writephy(tp, 0x1f, 0x0004);
2846 rtl_writephy(tp, 0x1f, 0x0007);
2847 rtl_writephy(tp, 0x1e, 0x0020);
2848 rtl_w1w0_phy(tp, 0x06, 0x0000, 0x0100);
2849 rtl_writephy(tp, 0x1f, 0x0002);
2850 rtl_writephy(tp, 0x1f, 0x0000);
2851 rtl_writephy(tp, 0x0d, 0x0007);
2852 rtl_writephy(tp, 0x0e, 0x003c);
2853 rtl_writephy(tp, 0x0d, 0x4007);
2854 rtl_writephy(tp, 0x0e, 0x0000);
2855 rtl_writephy(tp, 0x0d, 0x0000);
2856
2857 /* Green feature */
2858 rtl_writephy(tp, 0x1f, 0x0003);
2859 rtl_w1w0_phy(tp, 0x19, 0x0000, 0x0001);
2860 rtl_w1w0_phy(tp, 0x10, 0x0000, 0x0400);
2861 rtl_writephy(tp, 0x1f, 0x0000);
2862}
2863
2740static void rtl8102e_hw_phy_config(struct rtl8169_private *tp) 2864static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
2741{ 2865{
2742 static const struct phy_reg phy_reg_init[] = { 2866 static const struct phy_reg phy_reg_init[] = {
@@ -2856,7 +2980,10 @@ static void rtl_hw_phy_config(struct net_device *dev)
2856 break; 2980 break;
2857 case RTL_GIGA_MAC_VER_32: 2981 case RTL_GIGA_MAC_VER_32:
2858 case RTL_GIGA_MAC_VER_33: 2982 case RTL_GIGA_MAC_VER_33:
2859 rtl8168e_hw_phy_config(tp); 2983 rtl8168e_1_hw_phy_config(tp);
2984 break;
2985 case RTL_GIGA_MAC_VER_34:
2986 rtl8168e_2_hw_phy_config(tp);
2860 break; 2987 break;
2861 2988
2862 default: 2989 default:
@@ -3362,6 +3489,7 @@ static void __devinit rtl_init_pll_power_ops(struct rtl8169_private *tp)
3362 case RTL_GIGA_MAC_VER_31: 3489 case RTL_GIGA_MAC_VER_31:
3363 case RTL_GIGA_MAC_VER_32: 3490 case RTL_GIGA_MAC_VER_32:
3364 case RTL_GIGA_MAC_VER_33: 3491 case RTL_GIGA_MAC_VER_33:
3492 case RTL_GIGA_MAC_VER_34:
3365 ops->down = r8168_pll_power_down; 3493 ops->down = r8168_pll_power_down;
3366 ops->up = r8168_pll_power_up; 3494 ops->up = r8168_pll_power_up;
3367 break; 3495 break;
@@ -3799,6 +3927,9 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp)
3799 tp->mac_version == RTL_GIGA_MAC_VER_31) { 3927 tp->mac_version == RTL_GIGA_MAC_VER_31) {
3800 while (RTL_R8(TxPoll) & NPQ) 3928 while (RTL_R8(TxPoll) & NPQ)
3801 udelay(20); 3929 udelay(20);
3930 } else if (tp->mac_version == RTL_GIGA_MAC_VER_34) {
3931 while (!(RTL_R32(TxConfig) & TXCFG_EMPTY))
3932 udelay(100);
3802 } else { 3933 } else {
3803 RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq); 3934 RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq);
3804 udelay(100); 3935 udelay(100);
@@ -4210,9 +4341,9 @@ static void rtl_hw_start_8168d_4(void __iomem *ioaddr, struct pci_dev *pdev)
4210 rtl_enable_clock_request(pdev); 4341 rtl_enable_clock_request(pdev);
4211} 4342}
4212 4343
4213static void rtl_hw_start_8168e(void __iomem *ioaddr, struct pci_dev *pdev) 4344static void rtl_hw_start_8168e_1(void __iomem *ioaddr, struct pci_dev *pdev)
4214{ 4345{
4215 static const struct ephy_info e_info_8168e[] = { 4346 static const struct ephy_info e_info_8168e_1[] = {
4216 { 0x00, 0x0200, 0x0100 }, 4347 { 0x00, 0x0200, 0x0100 },
4217 { 0x00, 0x0000, 0x0004 }, 4348 { 0x00, 0x0000, 0x0004 },
4218 { 0x06, 0x0002, 0x0001 }, 4349 { 0x06, 0x0002, 0x0001 },
@@ -4230,7 +4361,7 @@ static void rtl_hw_start_8168e(void __iomem *ioaddr, struct pci_dev *pdev)
4230 4361
4231 rtl_csi_access_enable_2(ioaddr); 4362 rtl_csi_access_enable_2(ioaddr);
4232 4363
4233 rtl_ephy_init(ioaddr, e_info_8168e, ARRAY_SIZE(e_info_8168e)); 4364 rtl_ephy_init(ioaddr, e_info_8168e_1, ARRAY_SIZE(e_info_8168e_1));
4234 4365
4235 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4366 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
4236 4367
@@ -4245,6 +4376,44 @@ static void rtl_hw_start_8168e(void __iomem *ioaddr, struct pci_dev *pdev)
4245 RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); 4376 RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
4246} 4377}
4247 4378
4379static void rtl_hw_start_8168e_2(void __iomem *ioaddr, struct pci_dev *pdev)
4380{
4381 static const struct ephy_info e_info_8168e_2[] = {
4382 { 0x09, 0x0000, 0x0080 },
4383 { 0x19, 0x0000, 0x0224 }
4384 };
4385
4386 rtl_csi_access_enable_1(ioaddr);
4387
4388 rtl_ephy_init(ioaddr, e_info_8168e_2, ARRAY_SIZE(e_info_8168e_2));
4389
4390 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
4391
4392 rtl_eri_write(ioaddr, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
4393 rtl_eri_write(ioaddr, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
4394 rtl_eri_write(ioaddr, 0xc8, ERIAR_MASK_1111, 0x00100002, ERIAR_EXGMAC);
4395 rtl_eri_write(ioaddr, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC);
4396 rtl_eri_write(ioaddr, 0xcc, ERIAR_MASK_1111, 0x00000050, ERIAR_EXGMAC);
4397 rtl_eri_write(ioaddr, 0xd0, ERIAR_MASK_1111, 0x07ff0060, ERIAR_EXGMAC);
4398 rtl_w1w0_eri(ioaddr, 0x1b0, ERIAR_MASK_0001, 0x10, 0x00, ERIAR_EXGMAC);
4399 rtl_w1w0_eri(ioaddr, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0xff00,
4400 ERIAR_EXGMAC);
4401
4402 RTL_W8(MaxTxPacketSize, 0x27);
4403
4404 rtl_disable_clock_request(pdev);
4405
4406 RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO);
4407 RTL_W8(MCU, RTL_R8(MCU) & ~NOW_IS_OOB);
4408
4409 /* Adjust EEE LED frequency */
4410 RTL_W8(EEE_LED, RTL_R8(EEE_LED) & ~0x07);
4411
4412 RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN);
4413 RTL_W32(MISC, RTL_R32(MISC) | PWM_EN);
4414 RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
4415}
4416
4248static void rtl_hw_start_8168(struct net_device *dev) 4417static void rtl_hw_start_8168(struct net_device *dev)
4249{ 4418{
4250 struct rtl8169_private *tp = netdev_priv(dev); 4419 struct rtl8169_private *tp = netdev_priv(dev);
@@ -4333,7 +4502,10 @@ static void rtl_hw_start_8168(struct net_device *dev)
4333 4502
4334 case RTL_GIGA_MAC_VER_32: 4503 case RTL_GIGA_MAC_VER_32:
4335 case RTL_GIGA_MAC_VER_33: 4504 case RTL_GIGA_MAC_VER_33:
4336 rtl_hw_start_8168e(ioaddr, pdev); 4505 rtl_hw_start_8168e_1(ioaddr, pdev);
4506 break;
4507 case RTL_GIGA_MAC_VER_34:
4508 rtl_hw_start_8168e_2(ioaddr, pdev);
4337 break; 4509 break;
4338 4510
4339 default: 4511 default: