aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/r8169.c
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2008-08-02 15:08:49 -0400
committerFrancois Romieu <romieu@fr.zoreil.com>2008-08-17 09:53:05 -0400
commit2857ffb7b8913ef713533ac5783abd70a20529e4 (patch)
treea5bef83f5b90759ce29d29c9a48fb7a3c81a54b7 /drivers/net/r8169.c
parentdacf815434a4d5f5b45687873df46927c64cfb19 (diff)
r8169: additional 8101 and 8102 support
Signed-off-by: Ivan Vecera <ivecera@redhat.com> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Edward Hsu <edward_hsu@realtek.com.tw>
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r--drivers/net/r8169.c124
1 files changed, 122 insertions, 2 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index f4ad9ff26869..bbaf8a55080d 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -96,6 +96,10 @@ enum mac_version {
96 RTL_GIGA_MAC_VER_04 = 0x04, // 8169SB 96 RTL_GIGA_MAC_VER_04 = 0x04, // 8169SB
97 RTL_GIGA_MAC_VER_05 = 0x05, // 8110SCd 97 RTL_GIGA_MAC_VER_05 = 0x05, // 8110SCd
98 RTL_GIGA_MAC_VER_06 = 0x06, // 8110SCe 98 RTL_GIGA_MAC_VER_06 = 0x06, // 8110SCe
99 RTL_GIGA_MAC_VER_07 = 0x07, // 8102e
100 RTL_GIGA_MAC_VER_08 = 0x08, // 8102e
101 RTL_GIGA_MAC_VER_09 = 0x09, // 8102e
102 RTL_GIGA_MAC_VER_10 = 0x0a, // 8101e
99 RTL_GIGA_MAC_VER_11 = 0x0b, // 8168Bb 103 RTL_GIGA_MAC_VER_11 = 0x0b, // 8168Bb
100 RTL_GIGA_MAC_VER_12 = 0x0c, // 8168Be 104 RTL_GIGA_MAC_VER_12 = 0x0c, // 8168Be
101 RTL_GIGA_MAC_VER_13 = 0x0d, // 8101Eb 105 RTL_GIGA_MAC_VER_13 = 0x0d, // 8101Eb
@@ -122,6 +126,10 @@ static const struct {
122 _R("RTL8169sb/8110sb", RTL_GIGA_MAC_VER_04, 0xff7e1880), // 8169SB 126 _R("RTL8169sb/8110sb", RTL_GIGA_MAC_VER_04, 0xff7e1880), // 8169SB
123 _R("RTL8169sc/8110sc", RTL_GIGA_MAC_VER_05, 0xff7e1880), // 8110SCd 127 _R("RTL8169sc/8110sc", RTL_GIGA_MAC_VER_05, 0xff7e1880), // 8110SCd
124 _R("RTL8169sc/8110sc", RTL_GIGA_MAC_VER_06, 0xff7e1880), // 8110SCe 128 _R("RTL8169sc/8110sc", RTL_GIGA_MAC_VER_06, 0xff7e1880), // 8110SCe
129 _R("RTL8102e", RTL_GIGA_MAC_VER_07, 0xff7e1880), // PCI-E
130 _R("RTL8102e", RTL_GIGA_MAC_VER_08, 0xff7e1880), // PCI-E
131 _R("RTL8102e", RTL_GIGA_MAC_VER_09, 0xff7e1880), // PCI-E
132 _R("RTL8101e", RTL_GIGA_MAC_VER_10, 0xff7e1880), // PCI-E
125 _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_11, 0xff7e1880), // PCI-E 133 _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_11, 0xff7e1880), // PCI-E
126 _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_12, 0xff7e1880), // PCI-E 134 _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_12, 0xff7e1880), // PCI-E
127 _R("RTL8101e", RTL_GIGA_MAC_VER_13, 0xff7e1880), // PCI-E 8139 135 _R("RTL8101e", RTL_GIGA_MAC_VER_13, 0xff7e1880), // PCI-E 8139
@@ -837,8 +845,12 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
837 } 845 }
838 } 846 }
839 847
840 /* The 8100e/8101e do Fast Ethernet only. */ 848 /* The 8100e/8101e/8102e do Fast Ethernet only. */
841 if ((tp->mac_version == RTL_GIGA_MAC_VER_13) || 849 if ((tp->mac_version == RTL_GIGA_MAC_VER_07) ||
850 (tp->mac_version == RTL_GIGA_MAC_VER_08) ||
851 (tp->mac_version == RTL_GIGA_MAC_VER_09) ||
852 (tp->mac_version == RTL_GIGA_MAC_VER_10) ||
853 (tp->mac_version == RTL_GIGA_MAC_VER_13) ||
842 (tp->mac_version == RTL_GIGA_MAC_VER_14) || 854 (tp->mac_version == RTL_GIGA_MAC_VER_14) ||
843 (tp->mac_version == RTL_GIGA_MAC_VER_15) || 855 (tp->mac_version == RTL_GIGA_MAC_VER_15) ||
844 (tp->mac_version == RTL_GIGA_MAC_VER_16)) { 856 (tp->mac_version == RTL_GIGA_MAC_VER_16)) {
@@ -1212,8 +1224,17 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
1212 { 0x7c800000, 0x30000000, RTL_GIGA_MAC_VER_11 }, 1224 { 0x7c800000, 0x30000000, RTL_GIGA_MAC_VER_11 },
1213 1225
1214 /* 8101 family. */ 1226 /* 8101 family. */
1227 { 0x7cf00000, 0x34a00000, RTL_GIGA_MAC_VER_09 },
1228 { 0x7cf00000, 0x24a00000, RTL_GIGA_MAC_VER_09 },
1229 { 0x7cf00000, 0x34900000, RTL_GIGA_MAC_VER_08 },
1230 { 0x7cf00000, 0x24900000, RTL_GIGA_MAC_VER_08 },
1231 { 0x7cf00000, 0x34800000, RTL_GIGA_MAC_VER_07 },
1232 { 0x7cf00000, 0x24800000, RTL_GIGA_MAC_VER_07 },
1215 { 0x7cf00000, 0x34000000, RTL_GIGA_MAC_VER_13 }, 1233 { 0x7cf00000, 0x34000000, RTL_GIGA_MAC_VER_13 },
1234 { 0x7cf00000, 0x34300000, RTL_GIGA_MAC_VER_10 },
1216 { 0x7cf00000, 0x34200000, RTL_GIGA_MAC_VER_16 }, 1235 { 0x7cf00000, 0x34200000, RTL_GIGA_MAC_VER_16 },
1236 { 0x7c800000, 0x34800000, RTL_GIGA_MAC_VER_09 },
1237 { 0x7c800000, 0x24800000, RTL_GIGA_MAC_VER_09 },
1217 { 0x7c800000, 0x34000000, RTL_GIGA_MAC_VER_16 }, 1238 { 0x7c800000, 0x34000000, RTL_GIGA_MAC_VER_16 },
1218 /* FIXME: where did these entries come from ? -- FR */ 1239 /* FIXME: where did these entries come from ? -- FR */
1219 { 0xfc800000, 0x38800000, RTL_GIGA_MAC_VER_15 }, 1240 { 0xfc800000, 0x38800000, RTL_GIGA_MAC_VER_15 },
@@ -1375,6 +1396,22 @@ static void rtl8168cx_hw_phy_config(void __iomem *ioaddr)
1375 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1396 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1376} 1397}
1377 1398
1399static void rtl8102e_hw_phy_config(void __iomem *ioaddr)
1400{
1401 struct phy_reg phy_reg_init[] = {
1402 { 0x1f, 0x0003 },
1403 { 0x08, 0x441d },
1404 { 0x01, 0x9100 },
1405 { 0x1f, 0x0000 }
1406 };
1407
1408 mdio_write(ioaddr, 0x1f, 0x0000);
1409 mdio_patch(ioaddr, 0x11, 1 << 12);
1410 mdio_patch(ioaddr, 0x19, 1 << 13);
1411
1412 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1413}
1414
1378static void rtl_hw_phy_config(struct net_device *dev) 1415static void rtl_hw_phy_config(struct net_device *dev)
1379{ 1416{
1380 struct rtl8169_private *tp = netdev_priv(dev); 1417 struct rtl8169_private *tp = netdev_priv(dev);
@@ -1392,6 +1429,11 @@ static void rtl_hw_phy_config(struct net_device *dev)
1392 case RTL_GIGA_MAC_VER_04: 1429 case RTL_GIGA_MAC_VER_04:
1393 rtl8169sb_hw_phy_config(ioaddr); 1430 rtl8169sb_hw_phy_config(ioaddr);
1394 break; 1431 break;
1432 case RTL_GIGA_MAC_VER_07:
1433 case RTL_GIGA_MAC_VER_08:
1434 case RTL_GIGA_MAC_VER_09:
1435 rtl8102e_hw_phy_config(ioaddr);
1436 break;
1395 case RTL_GIGA_MAC_VER_18: 1437 case RTL_GIGA_MAC_VER_18:
1396 rtl8168cp_hw_phy_config(ioaddr); 1438 rtl8168cp_hw_phy_config(ioaddr);
1397 break; 1439 break;
@@ -2255,6 +2297,70 @@ static void rtl_hw_start_8168(struct net_device *dev)
2255 RTL_W16(IntrMask, tp->intr_event); 2297 RTL_W16(IntrMask, tp->intr_event);
2256} 2298}
2257 2299
2300#define R810X_CPCMD_QUIRK_MASK (\
2301 EnableBist | \
2302 Mac_dbgo_oe | \
2303 Force_half_dup | \
2304 Force_half_dup | \
2305 Force_txflow_en | \
2306 Cxpl_dbg_sel | \
2307 ASF | \
2308 PktCntrDisable | \
2309 PCIDAC | \
2310 PCIMulRW)
2311
2312static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev)
2313{
2314 static struct ephy_info e_info_8102e_1[] = {
2315 { 0x01, 0, 0x6e65 },
2316 { 0x02, 0, 0x091f },
2317 { 0x03, 0, 0xc2f9 },
2318 { 0x06, 0, 0xafb5 },
2319 { 0x07, 0, 0x0e00 },
2320 { 0x19, 0, 0xec80 },
2321 { 0x01, 0, 0x2e65 },
2322 { 0x01, 0, 0x6e65 }
2323 };
2324 u8 cfg1;
2325
2326 rtl_csi_access_enable(ioaddr);
2327
2328 RTL_W8(DBG_REG, FIX_NAK_1);
2329
2330 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
2331
2332 RTL_W8(Config1,
2333 LEDS1 | LEDS0 | Speed_down | MEMMAP | IOMAP | VPD | PMEnable);
2334 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
2335
2336 cfg1 = RTL_R8(Config1);
2337 if ((cfg1 & LEDS0) && (cfg1 & LEDS1))
2338 RTL_W8(Config1, cfg1 & ~LEDS0);
2339
2340 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R810X_CPCMD_QUIRK_MASK);
2341
2342 rtl_ephy_init(ioaddr, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1));
2343}
2344
2345static void rtl_hw_start_8102e_2(void __iomem *ioaddr, struct pci_dev *pdev)
2346{
2347 rtl_csi_access_enable(ioaddr);
2348
2349 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
2350
2351 RTL_W8(Config1, MEMMAP | IOMAP | VPD | PMEnable);
2352 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
2353
2354 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R810X_CPCMD_QUIRK_MASK);
2355}
2356
2357static void rtl_hw_start_8102e_3(void __iomem *ioaddr, struct pci_dev *pdev)
2358{
2359 rtl_hw_start_8102e_2(ioaddr, pdev);
2360
2361 rtl_ephy_write(ioaddr, 0x03, 0xc2f9);
2362}
2363
2258static void rtl_hw_start_8101(struct net_device *dev) 2364static void rtl_hw_start_8101(struct net_device *dev)
2259{ 2365{
2260 struct rtl8169_private *tp = netdev_priv(dev); 2366 struct rtl8169_private *tp = netdev_priv(dev);
@@ -2271,6 +2377,20 @@ static void rtl_hw_start_8101(struct net_device *dev)
2271 } 2377 }
2272 } 2378 }
2273 2379
2380 switch (tp->mac_version) {
2381 case RTL_GIGA_MAC_VER_07:
2382 rtl_hw_start_8102e_1(ioaddr, pdev);
2383 break;
2384
2385 case RTL_GIGA_MAC_VER_08:
2386 rtl_hw_start_8102e_3(ioaddr, pdev);
2387 break;
2388
2389 case RTL_GIGA_MAC_VER_09:
2390 rtl_hw_start_8102e_2(ioaddr, pdev);
2391 break;
2392 }
2393
2274 RTL_W8(Cfg9346, Cfg9346_Unlock); 2394 RTL_W8(Cfg9346, Cfg9346_Unlock);
2275 2395
2276 RTL_W8(EarlyTxThres, EarlyTxThld); 2396 RTL_W8(EarlyTxThres, EarlyTxThld);