diff options
author | Hayes Wang <hayeswang@realtek.com> | 2011-02-22 04:26:21 -0500 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2011-03-05 04:04:06 -0500 |
commit | 5a5e4443150713347a7a7e4d0880b343348f5811 (patch) | |
tree | 4d035ecb4ca8453626e87251bf2a6132b8d7a703 /drivers/net/r8169.c | |
parent | 716b50a31fb237c480e67ad66dc23feb35d40772 (diff) |
r8169: support the new chips for RTL8105E.
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Acked-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r-- | drivers/net/r8169.c | 92 |
1 files changed, 90 insertions, 2 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index de94489cf96e..2543edd9a2cc 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -36,6 +36,7 @@ | |||
36 | 36 | ||
37 | #define FIRMWARE_8168D_1 "rtl_nic/rtl8168d-1.fw" | 37 | #define FIRMWARE_8168D_1 "rtl_nic/rtl8168d-1.fw" |
38 | #define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw" | 38 | #define FIRMWARE_8168D_2 "rtl_nic/rtl8168d-2.fw" |
39 | #define FIRMWARE_8105E_1 "rtl_nic/rtl8105e-1.fw" | ||
39 | 40 | ||
40 | #ifdef RTL8169_DEBUG | 41 | #ifdef RTL8169_DEBUG |
41 | #define assert(expr) \ | 42 | #define assert(expr) \ |
@@ -123,6 +124,8 @@ enum mac_version { | |||
123 | RTL_GIGA_MAC_VER_26 = 0x1a, // 8168D | 124 | RTL_GIGA_MAC_VER_26 = 0x1a, // 8168D |
124 | RTL_GIGA_MAC_VER_27 = 0x1b, // 8168DP | 125 | RTL_GIGA_MAC_VER_27 = 0x1b, // 8168DP |
125 | RTL_GIGA_MAC_VER_28 = 0x1c, // 8168DP | 126 | RTL_GIGA_MAC_VER_28 = 0x1c, // 8168DP |
127 | RTL_GIGA_MAC_VER_29 = 0x1d, // 8105E | ||
128 | RTL_GIGA_MAC_VER_30 = 0x1e, // 8105E | ||
126 | }; | 129 | }; |
127 | 130 | ||
128 | #define _R(NAME,MAC,MASK) \ | 131 | #define _R(NAME,MAC,MASK) \ |
@@ -160,7 +163,9 @@ static const struct { | |||
160 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_25, 0xff7e1880), // PCI-E | 163 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_25, 0xff7e1880), // PCI-E |
161 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_26, 0xff7e1880), // PCI-E | 164 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_26, 0xff7e1880), // PCI-E |
162 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_27, 0xff7e1880), // PCI-E | 165 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_27, 0xff7e1880), // PCI-E |
163 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_28, 0xff7e1880) // PCI-E | 166 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_28, 0xff7e1880), // PCI-E |
167 | _R("RTL8105e", RTL_GIGA_MAC_VER_29, 0xff7e1880), // PCI-E | ||
168 | _R("RTL8105e", RTL_GIGA_MAC_VER_30, 0xff7e1880) // PCI-E | ||
164 | }; | 169 | }; |
165 | #undef _R | 170 | #undef _R |
166 | 171 | ||
@@ -267,9 +272,15 @@ enum rtl8168_8101_registers { | |||
267 | #define EPHYAR_REG_MASK 0x1f | 272 | #define EPHYAR_REG_MASK 0x1f |
268 | #define EPHYAR_REG_SHIFT 16 | 273 | #define EPHYAR_REG_SHIFT 16 |
269 | #define EPHYAR_DATA_MASK 0xffff | 274 | #define EPHYAR_DATA_MASK 0xffff |
275 | DLLPR = 0xd0, | ||
276 | #define PM_SWITCH (1 << 6) | ||
270 | DBG_REG = 0xd1, | 277 | DBG_REG = 0xd1, |
271 | #define FIX_NAK_1 (1 << 4) | 278 | #define FIX_NAK_1 (1 << 4) |
272 | #define FIX_NAK_2 (1 << 3) | 279 | #define FIX_NAK_2 (1 << 3) |
280 | TWSI = 0xd2, | ||
281 | MCU = 0xd3, | ||
282 | #define EN_NDP (1 << 3) | ||
283 | #define EN_OOB_RESET (1 << 2) | ||
273 | EFUSEAR = 0xdc, | 284 | EFUSEAR = 0xdc, |
274 | #define EFUSEAR_FLAG 0x80000000 | 285 | #define EFUSEAR_FLAG 0x80000000 |
275 | #define EFUSEAR_WRITE_CMD 0x80000000 | 286 | #define EFUSEAR_WRITE_CMD 0x80000000 |
@@ -568,6 +579,7 @@ MODULE_LICENSE("GPL"); | |||
568 | MODULE_VERSION(RTL8169_VERSION); | 579 | MODULE_VERSION(RTL8169_VERSION); |
569 | MODULE_FIRMWARE(FIRMWARE_8168D_1); | 580 | MODULE_FIRMWARE(FIRMWARE_8168D_1); |
570 | MODULE_FIRMWARE(FIRMWARE_8168D_2); | 581 | MODULE_FIRMWARE(FIRMWARE_8168D_2); |
582 | MODULE_FIRMWARE(FIRMWARE_8105E_1); | ||
571 | 583 | ||
572 | static int rtl8169_open(struct net_device *dev); | 584 | static int rtl8169_open(struct net_device *dev); |
573 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | 585 | static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, |
@@ -1145,7 +1157,9 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1145 | (tp->mac_version != RTL_GIGA_MAC_VER_13) && | 1157 | (tp->mac_version != RTL_GIGA_MAC_VER_13) && |
1146 | (tp->mac_version != RTL_GIGA_MAC_VER_14) && | 1158 | (tp->mac_version != RTL_GIGA_MAC_VER_14) && |
1147 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && | 1159 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && |
1148 | (tp->mac_version != RTL_GIGA_MAC_VER_16)) { | 1160 | (tp->mac_version != RTL_GIGA_MAC_VER_16) && |
1161 | (tp->mac_version != RTL_GIGA_MAC_VER_29) && | ||
1162 | (tp->mac_version != RTL_GIGA_MAC_VER_30)) { | ||
1149 | giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; | 1163 | giga_ctrl |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; |
1150 | } else { | 1164 | } else { |
1151 | netif_info(tp, link, dev, | 1165 | netif_info(tp, link, dev, |
@@ -1547,6 +1561,9 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, | |||
1547 | { 0x7c800000, 0x30000000, RTL_GIGA_MAC_VER_11 }, | 1561 | { 0x7c800000, 0x30000000, RTL_GIGA_MAC_VER_11 }, |
1548 | 1562 | ||
1549 | /* 8101 family. */ | 1563 | /* 8101 family. */ |
1564 | { 0x7cf00000, 0x40a00000, RTL_GIGA_MAC_VER_30 }, | ||
1565 | { 0x7cf00000, 0x40900000, RTL_GIGA_MAC_VER_29 }, | ||
1566 | { 0x7c800000, 0x40800000, RTL_GIGA_MAC_VER_30 }, | ||
1550 | { 0x7cf00000, 0x34a00000, RTL_GIGA_MAC_VER_09 }, | 1567 | { 0x7cf00000, 0x34a00000, RTL_GIGA_MAC_VER_09 }, |
1551 | { 0x7cf00000, 0x24a00000, RTL_GIGA_MAC_VER_09 }, | 1568 | { 0x7cf00000, 0x24a00000, RTL_GIGA_MAC_VER_09 }, |
1552 | { 0x7cf00000, 0x34900000, RTL_GIGA_MAC_VER_08 }, | 1569 | { 0x7cf00000, 0x34900000, RTL_GIGA_MAC_VER_08 }, |
@@ -2423,6 +2440,33 @@ static void rtl8102e_hw_phy_config(struct rtl8169_private *tp) | |||
2423 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | 2440 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); |
2424 | } | 2441 | } |
2425 | 2442 | ||
2443 | static void rtl8105e_hw_phy_config(struct rtl8169_private *tp) | ||
2444 | { | ||
2445 | static const struct phy_reg phy_reg_init[] = { | ||
2446 | { 0x1f, 0x0005 }, | ||
2447 | { 0x1a, 0x0000 }, | ||
2448 | { 0x1f, 0x0000 }, | ||
2449 | |||
2450 | { 0x1f, 0x0004 }, | ||
2451 | { 0x1c, 0x0000 }, | ||
2452 | { 0x1f, 0x0000 }, | ||
2453 | |||
2454 | { 0x1f, 0x0001 }, | ||
2455 | { 0x15, 0x7701 }, | ||
2456 | { 0x1f, 0x0000 } | ||
2457 | }; | ||
2458 | |||
2459 | /* Disable ALDPS before ram code */ | ||
2460 | rtl_writephy(tp, 0x1f, 0x0000); | ||
2461 | rtl_writephy(tp, 0x18, 0x0310); | ||
2462 | msleep(100); | ||
2463 | |||
2464 | if (rtl_apply_firmware(tp, FIRMWARE_8105E_1) < 0) | ||
2465 | netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n"); | ||
2466 | |||
2467 | rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); | ||
2468 | } | ||
2469 | |||
2426 | static void rtl_hw_phy_config(struct net_device *dev) | 2470 | static void rtl_hw_phy_config(struct net_device *dev) |
2427 | { | 2471 | { |
2428 | struct rtl8169_private *tp = netdev_priv(dev); | 2472 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -2490,6 +2534,10 @@ static void rtl_hw_phy_config(struct net_device *dev) | |||
2490 | case RTL_GIGA_MAC_VER_28: | 2534 | case RTL_GIGA_MAC_VER_28: |
2491 | rtl8168d_4_hw_phy_config(tp); | 2535 | rtl8168d_4_hw_phy_config(tp); |
2492 | break; | 2536 | break; |
2537 | case RTL_GIGA_MAC_VER_29: | ||
2538 | case RTL_GIGA_MAC_VER_30: | ||
2539 | rtl8105e_hw_phy_config(tp); | ||
2540 | break; | ||
2493 | 2541 | ||
2494 | default: | 2542 | default: |
2495 | break; | 2543 | break; |
@@ -2928,6 +2976,8 @@ static void __devinit rtl_init_pll_power_ops(struct rtl8169_private *tp) | |||
2928 | case RTL_GIGA_MAC_VER_09: | 2976 | case RTL_GIGA_MAC_VER_09: |
2929 | case RTL_GIGA_MAC_VER_10: | 2977 | case RTL_GIGA_MAC_VER_10: |
2930 | case RTL_GIGA_MAC_VER_16: | 2978 | case RTL_GIGA_MAC_VER_16: |
2979 | case RTL_GIGA_MAC_VER_29: | ||
2980 | case RTL_GIGA_MAC_VER_30: | ||
2931 | ops->down = r810x_pll_power_down; | 2981 | ops->down = r810x_pll_power_down; |
2932 | ops->up = r810x_pll_power_up; | 2982 | ops->up = r810x_pll_power_up; |
2933 | break; | 2983 | break; |
@@ -3890,6 +3940,37 @@ static void rtl_hw_start_8102e_3(void __iomem *ioaddr, struct pci_dev *pdev) | |||
3890 | rtl_ephy_write(ioaddr, 0x03, 0xc2f9); | 3940 | rtl_ephy_write(ioaddr, 0x03, 0xc2f9); |
3891 | } | 3941 | } |
3892 | 3942 | ||
3943 | static void rtl_hw_start_8105e_1(void __iomem *ioaddr, struct pci_dev *pdev) | ||
3944 | { | ||
3945 | static const struct ephy_info e_info_8105e_1[] = { | ||
3946 | { 0x07, 0, 0x4000 }, | ||
3947 | { 0x19, 0, 0x0200 }, | ||
3948 | { 0x19, 0, 0x0020 }, | ||
3949 | { 0x1e, 0, 0x2000 }, | ||
3950 | { 0x03, 0, 0x0001 }, | ||
3951 | { 0x19, 0, 0x0100 }, | ||
3952 | { 0x19, 0, 0x0004 }, | ||
3953 | { 0x0a, 0, 0x0020 } | ||
3954 | }; | ||
3955 | |||
3956 | /* Force LAN exit from ASPM if Rx/Tx are not idel */ | ||
3957 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) | 0x002800); | ||
3958 | |||
3959 | /* disable Early Tally Counter */ | ||
3960 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) & ~0x010000); | ||
3961 | |||
3962 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); | ||
3963 | RTL_W8(DLLPR, RTL_R8(DLLPR) | PM_SWITCH); | ||
3964 | |||
3965 | rtl_ephy_init(ioaddr, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1)); | ||
3966 | } | ||
3967 | |||
3968 | static void rtl_hw_start_8105e_2(void __iomem *ioaddr, struct pci_dev *pdev) | ||
3969 | { | ||
3970 | rtl_hw_start_8105e_1(ioaddr, pdev); | ||
3971 | rtl_ephy_write(ioaddr, 0x1e, rtl_ephy_read(ioaddr, 0x1e) | 0x8000); | ||
3972 | } | ||
3973 | |||
3893 | static void rtl_hw_start_8101(struct net_device *dev) | 3974 | static void rtl_hw_start_8101(struct net_device *dev) |
3894 | { | 3975 | { |
3895 | struct rtl8169_private *tp = netdev_priv(dev); | 3976 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -3918,6 +3999,13 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
3918 | case RTL_GIGA_MAC_VER_09: | 3999 | case RTL_GIGA_MAC_VER_09: |
3919 | rtl_hw_start_8102e_2(ioaddr, pdev); | 4000 | rtl_hw_start_8102e_2(ioaddr, pdev); |
3920 | break; | 4001 | break; |
4002 | |||
4003 | case RTL_GIGA_MAC_VER_29: | ||
4004 | rtl_hw_start_8105e_1(ioaddr, pdev); | ||
4005 | break; | ||
4006 | case RTL_GIGA_MAC_VER_30: | ||
4007 | rtl_hw_start_8105e_2(ioaddr, pdev); | ||
4008 | break; | ||
3921 | } | 4009 | } |
3922 | 4010 | ||
3923 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 4011 | RTL_W8(Cfg9346, Cfg9346_Unlock); |