aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/realtek/r8169.c
diff options
context:
space:
mode:
authorChun-Hao Lin <hau@realtek.com>2014-08-19 13:54:04 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-22 15:33:47 -0400
commit6e1d0b8988188956dac091441c1492a79a342666 (patch)
tree498f184f70892071613af8cd135923cfc24809b9 /drivers/net/ethernet/realtek/r8169.c
parentd4261e5650004d6d51137553ea5433d5828562dc (diff)
r8169:add support for RTL8168H and RTL8107E
RTL8168H is Realtek PCIe Gigabit Ethernet controller. RTL8107E is Realtek PCIe Fast Ethernet controller. This patch add support for these two chips. Signed-off-by: Chun-Hao Lin <hau@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/realtek/r8169.c')
-rw-r--r--drivers/net/ethernet/realtek/r8169.c470
1 files changed, 452 insertions, 18 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 91652e7235e4..c8375f6cf5d4 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -52,6 +52,10 @@
52#define FIRMWARE_8106E_2 "rtl_nic/rtl8106e-2.fw" 52#define FIRMWARE_8106E_2 "rtl_nic/rtl8106e-2.fw"
53#define FIRMWARE_8168G_2 "rtl_nic/rtl8168g-2.fw" 53#define FIRMWARE_8168G_2 "rtl_nic/rtl8168g-2.fw"
54#define FIRMWARE_8168G_3 "rtl_nic/rtl8168g-3.fw" 54#define FIRMWARE_8168G_3 "rtl_nic/rtl8168g-3.fw"
55#define FIRMWARE_8168H_1 "rtl_nic/rtl8168h-1.fw"
56#define FIRMWARE_8168H_2 "rtl_nic/rtl8168h-2.fw"
57#define FIRMWARE_8107E_1 "rtl_nic/rtl8107e-1.fw"
58#define FIRMWARE_8107E_2 "rtl_nic/rtl8107e-2.fw"
55 59
56#ifdef RTL8169_DEBUG 60#ifdef RTL8169_DEBUG
57#define assert(expr) \ 61#define assert(expr) \
@@ -147,6 +151,10 @@ enum mac_version {
147 RTL_GIGA_MAC_VER_42, 151 RTL_GIGA_MAC_VER_42,
148 RTL_GIGA_MAC_VER_43, 152 RTL_GIGA_MAC_VER_43,
149 RTL_GIGA_MAC_VER_44, 153 RTL_GIGA_MAC_VER_44,
154 RTL_GIGA_MAC_VER_45,
155 RTL_GIGA_MAC_VER_46,
156 RTL_GIGA_MAC_VER_47,
157 RTL_GIGA_MAC_VER_48,
150 RTL_GIGA_MAC_NONE = 0xff, 158 RTL_GIGA_MAC_NONE = 0xff,
151}; 159};
152 160
@@ -282,6 +290,18 @@ static const struct {
282 [RTL_GIGA_MAC_VER_44] = 290 [RTL_GIGA_MAC_VER_44] =
283 _R("RTL8411", RTL_TD_1, FIRMWARE_8411_2, 291 _R("RTL8411", RTL_TD_1, FIRMWARE_8411_2,
284 JUMBO_9K, false), 292 JUMBO_9K, false),
293 [RTL_GIGA_MAC_VER_45] =
294 _R("RTL8168h/8111h", RTL_TD_1, FIRMWARE_8168H_1,
295 JUMBO_9K, false),
296 [RTL_GIGA_MAC_VER_46] =
297 _R("RTL8168h/8111h", RTL_TD_1, FIRMWARE_8168H_2,
298 JUMBO_9K, false),
299 [RTL_GIGA_MAC_VER_47] =
300 _R("RTL8107e", RTL_TD_1, FIRMWARE_8107E_1,
301 JUMBO_1K, false),
302 [RTL_GIGA_MAC_VER_48] =
303 _R("RTL8107e", RTL_TD_1, FIRMWARE_8107E_2,
304 JUMBO_1K, false),
285}; 305};
286#undef _R 306#undef _R
287 307
@@ -410,6 +430,7 @@ enum rtl8168_8101_registers {
410#define EPHYAR_DATA_MASK 0xffff 430#define EPHYAR_DATA_MASK 0xffff
411 DLLPR = 0xd0, 431 DLLPR = 0xd0,
412#define PFM_EN (1 << 6) 432#define PFM_EN (1 << 6)
433#define TX_10M_PS_EN (1 << 7)
413 DBG_REG = 0xd1, 434 DBG_REG = 0xd1,
414#define FIX_NAK_1 (1 << 4) 435#define FIX_NAK_1 (1 << 4)
415#define FIX_NAK_2 (1 << 3) 436#define FIX_NAK_2 (1 << 3)
@@ -429,6 +450,8 @@ enum rtl8168_8101_registers {
429#define EFUSEAR_REG_MASK 0x03ff 450#define EFUSEAR_REG_MASK 0x03ff
430#define EFUSEAR_REG_SHIFT 8 451#define EFUSEAR_REG_SHIFT 8
431#define EFUSEAR_DATA_MASK 0xff 452#define EFUSEAR_DATA_MASK 0xff
453 MISC_1 = 0xf2,
454#define PFM_D3COLD_EN (1 << 6)
432}; 455};
433 456
434enum rtl8168_registers { 457enum rtl8168_registers {
@@ -447,6 +470,7 @@ enum rtl8168_registers {
447#define ERIAR_MASK_SHIFT 12 470#define ERIAR_MASK_SHIFT 12
448#define ERIAR_MASK_0001 (0x1 << ERIAR_MASK_SHIFT) 471#define ERIAR_MASK_0001 (0x1 << ERIAR_MASK_SHIFT)
449#define ERIAR_MASK_0011 (0x3 << ERIAR_MASK_SHIFT) 472#define ERIAR_MASK_0011 (0x3 << ERIAR_MASK_SHIFT)
473#define ERIAR_MASK_0100 (0x4 << ERIAR_MASK_SHIFT)
450#define ERIAR_MASK_0101 (0x5 << ERIAR_MASK_SHIFT) 474#define ERIAR_MASK_0101 (0x5 << ERIAR_MASK_SHIFT)
451#define ERIAR_MASK_1111 (0xf << ERIAR_MASK_SHIFT) 475#define ERIAR_MASK_1111 (0xf << ERIAR_MASK_SHIFT)
452 EPHY_RXER_NUM = 0x7c, 476 EPHY_RXER_NUM = 0x7c,
@@ -598,6 +622,9 @@ enum rtl_register_content {
598 622
599 /* DumpCounterCommand */ 623 /* DumpCounterCommand */
600 CounterDump = 0x8, 624 CounterDump = 0x8,
625
626 /* magic enable v2 */
627 MagicPacket_v2 = (1 << 16), /* Wake up when receives a Magic Packet */
601}; 628};
602 629
603enum rtl_desc_bit { 630enum rtl_desc_bit {
@@ -823,6 +850,8 @@ MODULE_FIRMWARE(FIRMWARE_8106E_1);
823MODULE_FIRMWARE(FIRMWARE_8106E_2); 850MODULE_FIRMWARE(FIRMWARE_8106E_2);
824MODULE_FIRMWARE(FIRMWARE_8168G_2); 851MODULE_FIRMWARE(FIRMWARE_8168G_2);
825MODULE_FIRMWARE(FIRMWARE_8168G_3); 852MODULE_FIRMWARE(FIRMWARE_8168G_3);
853MODULE_FIRMWARE(FIRMWARE_8168H_1);
854MODULE_FIRMWARE(FIRMWARE_8168H_2);
826 855
827static void rtl_lock_work(struct rtl8169_private *tp) 856static void rtl_lock_work(struct rtl8169_private *tp)
828{ 857{
@@ -1514,8 +1543,17 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
1514 options = RTL_R8(Config3); 1543 options = RTL_R8(Config3);
1515 if (options & LinkUp) 1544 if (options & LinkUp)
1516 wolopts |= WAKE_PHY; 1545 wolopts |= WAKE_PHY;
1517 if (options & MagicPacket) 1546 switch (tp->mac_version) {
1518 wolopts |= WAKE_MAGIC; 1547 case RTL_GIGA_MAC_VER_45:
1548 case RTL_GIGA_MAC_VER_46:
1549 if (rtl_eri_read(tp, 0xdc, ERIAR_EXGMAC) & MagicPacket_v2)
1550 wolopts |= WAKE_MAGIC;
1551 break;
1552 default:
1553 if (options & MagicPacket)
1554 wolopts |= WAKE_MAGIC;
1555 break;
1556 }
1519 1557
1520 options = RTL_R8(Config5); 1558 options = RTL_R8(Config5);
1521 if (options & UWF) 1559 if (options & UWF)
@@ -1543,24 +1581,48 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1543static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) 1581static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
1544{ 1582{
1545 void __iomem *ioaddr = tp->mmio_addr; 1583 void __iomem *ioaddr = tp->mmio_addr;
1546 unsigned int i; 1584 unsigned int i, tmp;
1547 static const struct { 1585 static const struct {
1548 u32 opt; 1586 u32 opt;
1549 u16 reg; 1587 u16 reg;
1550 u8 mask; 1588 u8 mask;
1551 } cfg[] = { 1589 } cfg[] = {
1552 { WAKE_PHY, Config3, LinkUp }, 1590 { WAKE_PHY, Config3, LinkUp },
1553 { WAKE_MAGIC, Config3, MagicPacket },
1554 { WAKE_UCAST, Config5, UWF }, 1591 { WAKE_UCAST, Config5, UWF },
1555 { WAKE_BCAST, Config5, BWF }, 1592 { WAKE_BCAST, Config5, BWF },
1556 { WAKE_MCAST, Config5, MWF }, 1593 { WAKE_MCAST, Config5, MWF },
1557 { WAKE_ANY, Config5, LanWake } 1594 { WAKE_ANY, Config5, LanWake },
1595 { WAKE_MAGIC, Config3, MagicPacket }
1558 }; 1596 };
1559 u8 options; 1597 u8 options;
1560 1598
1561 RTL_W8(Cfg9346, Cfg9346_Unlock); 1599 RTL_W8(Cfg9346, Cfg9346_Unlock);
1562 1600
1563 for (i = 0; i < ARRAY_SIZE(cfg); i++) { 1601 switch (tp->mac_version) {
1602 case RTL_GIGA_MAC_VER_45:
1603 case RTL_GIGA_MAC_VER_46:
1604 tmp = ARRAY_SIZE(cfg) - 1;
1605 if (wolopts & WAKE_MAGIC)
1606 rtl_w1w0_eri(tp,
1607 0x0dc,
1608 ERIAR_MASK_0100,
1609 MagicPacket_v2,
1610 0x0000,
1611 ERIAR_EXGMAC);
1612 else
1613 rtl_w1w0_eri(tp,
1614 0x0dc,
1615 ERIAR_MASK_0100,
1616 0x0000,
1617 MagicPacket_v2,
1618 ERIAR_EXGMAC);
1619 break;
1620 default:
1621 tmp = ARRAY_SIZE(cfg);
1622 break;
1623 }
1624
1625 for (i = 0; i < tmp; i++) {
1564 options = RTL_R8(cfg[i].reg) & ~cfg[i].mask; 1626 options = RTL_R8(cfg[i].reg) & ~cfg[i].mask;
1565 if (wolopts & cfg[i].opt) 1627 if (wolopts & cfg[i].opt)
1566 options |= cfg[i].mask; 1628 options |= cfg[i].mask;
@@ -2044,6 +2106,10 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
2044 u32 val; 2106 u32 val;
2045 int mac_version; 2107 int mac_version;
2046 } mac_info[] = { 2108 } mac_info[] = {
2109 /* 8168H family. */
2110 { 0x7cf00000, 0x54100000, RTL_GIGA_MAC_VER_46 },
2111 { 0x7cf00000, 0x54000000, RTL_GIGA_MAC_VER_45 },
2112
2047 /* 8168G family. */ 2113 /* 8168G family. */
2048 { 0x7cf00000, 0x5c800000, RTL_GIGA_MAC_VER_44 }, 2114 { 0x7cf00000, 0x5c800000, RTL_GIGA_MAC_VER_44 },
2049 { 0x7cf00000, 0x50900000, RTL_GIGA_MAC_VER_42 }, 2115 { 0x7cf00000, 0x50900000, RTL_GIGA_MAC_VER_42 },
@@ -2139,6 +2205,14 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
2139 tp->mac_version = tp->mii.supports_gmii ? 2205 tp->mac_version = tp->mii.supports_gmii ?
2140 RTL_GIGA_MAC_VER_42 : 2206 RTL_GIGA_MAC_VER_42 :
2141 RTL_GIGA_MAC_VER_43; 2207 RTL_GIGA_MAC_VER_43;
2208 } else if (tp->mac_version == RTL_GIGA_MAC_VER_45) {
2209 tp->mac_version = tp->mii.supports_gmii ?
2210 RTL_GIGA_MAC_VER_45 :
2211 RTL_GIGA_MAC_VER_47;
2212 } else if (tp->mac_version == RTL_GIGA_MAC_VER_46) {
2213 tp->mac_version = tp->mii.supports_gmii ?
2214 RTL_GIGA_MAC_VER_46 :
2215 RTL_GIGA_MAC_VER_48;
2142 } 2216 }
2143} 2217}
2144 2218
@@ -3464,6 +3538,189 @@ static void rtl8168g_2_hw_phy_config(struct rtl8169_private *tp)
3464 rtl_apply_firmware(tp); 3538 rtl_apply_firmware(tp);
3465} 3539}
3466 3540
3541static void rtl8168h_1_hw_phy_config(struct rtl8169_private *tp)
3542{
3543 u16 dout_tapbin;
3544 u32 data;
3545
3546 rtl_apply_firmware(tp);
3547
3548 /* CHN EST parameters adjust - giga master */
3549 rtl_writephy(tp, 0x1f, 0x0a43);
3550 rtl_writephy(tp, 0x13, 0x809b);
3551 rtl_w1w0_phy(tp, 0x14, 0x8000, 0xf800);
3552 rtl_writephy(tp, 0x13, 0x80a2);
3553 rtl_w1w0_phy(tp, 0x14, 0x8000, 0xff00);
3554 rtl_writephy(tp, 0x13, 0x80a4);
3555 rtl_w1w0_phy(tp, 0x14, 0x8500, 0xff00);
3556 rtl_writephy(tp, 0x13, 0x809c);
3557 rtl_w1w0_phy(tp, 0x14, 0xbd00, 0xff00);
3558 rtl_writephy(tp, 0x1f, 0x0000);
3559
3560 /* CHN EST parameters adjust - giga slave */
3561 rtl_writephy(tp, 0x1f, 0x0a43);
3562 rtl_writephy(tp, 0x13, 0x80ad);
3563 rtl_w1w0_phy(tp, 0x14, 0x7000, 0xf800);
3564 rtl_writephy(tp, 0x13, 0x80b4);
3565 rtl_w1w0_phy(tp, 0x14, 0x5000, 0xff00);
3566 rtl_writephy(tp, 0x13, 0x80ac);
3567 rtl_w1w0_phy(tp, 0x14, 0x4000, 0xff00);
3568 rtl_writephy(tp, 0x1f, 0x0000);
3569
3570 /* CHN EST parameters adjust - fnet */
3571 rtl_writephy(tp, 0x1f, 0x0a43);
3572 rtl_writephy(tp, 0x13, 0x808e);
3573 rtl_w1w0_phy(tp, 0x14, 0x1200, 0xff00);
3574 rtl_writephy(tp, 0x13, 0x8090);
3575 rtl_w1w0_phy(tp, 0x14, 0xe500, 0xff00);
3576 rtl_writephy(tp, 0x13, 0x8092);
3577 rtl_w1w0_phy(tp, 0x14, 0x9f00, 0xff00);
3578 rtl_writephy(tp, 0x1f, 0x0000);
3579
3580 /* enable R-tune & PGA-retune function */
3581 dout_tapbin = 0;
3582 rtl_writephy(tp, 0x1f, 0x0a46);
3583 data = rtl_readphy(tp, 0x13);
3584 data &= 3;
3585 data <<= 2;
3586 dout_tapbin |= data;
3587 data = rtl_readphy(tp, 0x12);
3588 data &= 0xc000;
3589 data >>= 14;
3590 dout_tapbin |= data;
3591 dout_tapbin = ~(dout_tapbin^0x08);
3592 dout_tapbin <<= 12;
3593 dout_tapbin &= 0xf000;
3594 rtl_writephy(tp, 0x1f, 0x0a43);
3595 rtl_writephy(tp, 0x13, 0x827a);
3596 rtl_w1w0_phy(tp, 0x14, dout_tapbin, 0xf000);
3597 rtl_writephy(tp, 0x13, 0x827b);
3598 rtl_w1w0_phy(tp, 0x14, dout_tapbin, 0xf000);
3599 rtl_writephy(tp, 0x13, 0x827c);
3600 rtl_w1w0_phy(tp, 0x14, dout_tapbin, 0xf000);
3601 rtl_writephy(tp, 0x13, 0x827d);
3602 rtl_w1w0_phy(tp, 0x14, dout_tapbin, 0xf000);
3603
3604 rtl_writephy(tp, 0x1f, 0x0a43);
3605 rtl_writephy(tp, 0x13, 0x0811);
3606 rtl_w1w0_phy(tp, 0x14, 0x0800, 0x0000);
3607 rtl_writephy(tp, 0x1f, 0x0a42);
3608 rtl_w1w0_phy(tp, 0x16, 0x0002, 0x0000);
3609 rtl_writephy(tp, 0x1f, 0x0000);
3610
3611 /* enable GPHY 10M */
3612 rtl_writephy(tp, 0x1f, 0x0a44);
3613 rtl_w1w0_phy(tp, 0x11, 0x0800, 0x0000);
3614 rtl_writephy(tp, 0x1f, 0x0000);
3615
3616 /* SAR ADC performance */
3617 rtl_writephy(tp, 0x1f, 0x0bca);
3618 rtl_w1w0_phy(tp, 0x17, 0x4000, 0x3000);
3619 rtl_writephy(tp, 0x1f, 0x0000);
3620
3621 rtl_writephy(tp, 0x1f, 0x0a43);
3622 rtl_writephy(tp, 0x13, 0x803f);
3623 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x3000);
3624 rtl_writephy(tp, 0x13, 0x8047);
3625 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x3000);
3626 rtl_writephy(tp, 0x13, 0x804f);
3627 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x3000);
3628 rtl_writephy(tp, 0x13, 0x8057);
3629 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x3000);
3630 rtl_writephy(tp, 0x13, 0x805f);
3631 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x3000);
3632 rtl_writephy(tp, 0x13, 0x8067);
3633 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x3000);
3634 rtl_writephy(tp, 0x13, 0x806f);
3635 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x3000);
3636 rtl_writephy(tp, 0x1f, 0x0000);
3637
3638 /* disable phy pfm mode */
3639 rtl_writephy(tp, 0x1f, 0x0a44);
3640 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x0080);
3641 rtl_writephy(tp, 0x1f, 0x0000);
3642
3643 /* Check ALDPS bit, disable it if enabled */
3644 rtl_writephy(tp, 0x1f, 0x0a43);
3645 if (rtl_readphy(tp, 0x10) & 0x0004)
3646 rtl_w1w0_phy(tp, 0x10, 0x0000, 0x0004);
3647
3648 rtl_writephy(tp, 0x1f, 0x0000);
3649}
3650
3651static void rtl8168h_2_hw_phy_config(struct rtl8169_private *tp)
3652{
3653 u16 ioffset_p3, ioffset_p2, ioffset_p1, ioffset_p0;
3654 u16 rlen;
3655 u32 data;
3656
3657 rtl_apply_firmware(tp);
3658
3659 /* CHIN EST parameter update */
3660 rtl_writephy(tp, 0x1f, 0x0a43);
3661 rtl_writephy(tp, 0x13, 0x808a);
3662 rtl_w1w0_phy(tp, 0x14, 0x000a, 0x003f);
3663 rtl_writephy(tp, 0x1f, 0x0000);
3664
3665 /* enable R-tune & PGA-retune function */
3666 rtl_writephy(tp, 0x1f, 0x0a43);
3667 rtl_writephy(tp, 0x13, 0x0811);
3668 rtl_w1w0_phy(tp, 0x14, 0x0800, 0x0000);
3669 rtl_writephy(tp, 0x1f, 0x0a42);
3670 rtl_w1w0_phy(tp, 0x16, 0x0002, 0x0000);
3671 rtl_writephy(tp, 0x1f, 0x0000);
3672
3673 /* enable GPHY 10M */
3674 rtl_writephy(tp, 0x1f, 0x0a44);
3675 rtl_w1w0_phy(tp, 0x11, 0x0800, 0x0000);
3676 rtl_writephy(tp, 0x1f, 0x0000);
3677
3678 r8168_mac_ocp_write(tp, 0xdd02, 0x807d);
3679 data = r8168_mac_ocp_read(tp, 0xdd02);
3680 ioffset_p3 = ((data & 0x80)>>7);
3681 ioffset_p3 <<= 3;
3682
3683 data = r8168_mac_ocp_read(tp, 0xdd00);
3684 ioffset_p3 |= ((data & (0xe000))>>13);
3685 ioffset_p2 = ((data & (0x1e00))>>9);
3686 ioffset_p1 = ((data & (0x01e0))>>5);
3687 ioffset_p0 = ((data & 0x0010)>>4);
3688 ioffset_p0 <<= 3;
3689 ioffset_p0 |= (data & (0x07));
3690 data = (ioffset_p3<<12)|(ioffset_p2<<8)|(ioffset_p1<<4)|(ioffset_p0);
3691
3692 if ((ioffset_p3 != 0x0F) || (ioffset_p2 != 0x0F) ||
3693 (ioffset_p1 != 0x0F) || (ioffset_p0 == 0x0F)) {
3694 rtl_writephy(tp, 0x1f, 0x0bcf);
3695 rtl_writephy(tp, 0x16, data);
3696 rtl_writephy(tp, 0x1f, 0x0000);
3697 }
3698
3699 /* Modify rlen (TX LPF corner frequency) level */
3700 rtl_writephy(tp, 0x1f, 0x0bcd);
3701 data = rtl_readphy(tp, 0x16);
3702 data &= 0x000f;
3703 rlen = 0;
3704 if (data > 3)
3705 rlen = data - 3;
3706 data = rlen | (rlen<<4) | (rlen<<8) | (rlen<<12);
3707 rtl_writephy(tp, 0x17, data);
3708 rtl_writephy(tp, 0x1f, 0x0bcd);
3709 rtl_writephy(tp, 0x1f, 0x0000);
3710
3711 /* disable phy pfm mode */
3712 rtl_writephy(tp, 0x1f, 0x0a44);
3713 rtl_w1w0_phy(tp, 0x14, 0x0000, 0x0080);
3714 rtl_writephy(tp, 0x1f, 0x0000);
3715
3716 /* Check ALDPS bit, disable it if enabled */
3717 rtl_writephy(tp, 0x1f, 0x0a43);
3718 if (rtl_readphy(tp, 0x10) & 0x0004)
3719 rtl_w1w0_phy(tp, 0x10, 0x0000, 0x0004);
3720
3721 rtl_writephy(tp, 0x1f, 0x0000);
3722}
3723
3467static void rtl8102e_hw_phy_config(struct rtl8169_private *tp) 3724static void rtl8102e_hw_phy_config(struct rtl8169_private *tp)
3468{ 3725{
3469 static const struct phy_reg phy_reg_init[] = { 3726 static const struct phy_reg phy_reg_init[] = {
@@ -3654,6 +3911,14 @@ static void rtl_hw_phy_config(struct net_device *dev)
3654 case RTL_GIGA_MAC_VER_44: 3911 case RTL_GIGA_MAC_VER_44:
3655 rtl8168g_2_hw_phy_config(tp); 3912 rtl8168g_2_hw_phy_config(tp);
3656 break; 3913 break;
3914 case RTL_GIGA_MAC_VER_45:
3915 case RTL_GIGA_MAC_VER_47:
3916 rtl8168h_1_hw_phy_config(tp);
3917 break;
3918 case RTL_GIGA_MAC_VER_46:
3919 case RTL_GIGA_MAC_VER_48:
3920 rtl8168h_2_hw_phy_config(tp);
3921 break;
3657 3922
3658 case RTL_GIGA_MAC_VER_41: 3923 case RTL_GIGA_MAC_VER_41:
3659 default: 3924 default:
@@ -3865,6 +4130,10 @@ static void rtl_init_mdio_ops(struct rtl8169_private *tp)
3865 case RTL_GIGA_MAC_VER_42: 4130 case RTL_GIGA_MAC_VER_42:
3866 case RTL_GIGA_MAC_VER_43: 4131 case RTL_GIGA_MAC_VER_43:
3867 case RTL_GIGA_MAC_VER_44: 4132 case RTL_GIGA_MAC_VER_44:
4133 case RTL_GIGA_MAC_VER_45:
4134 case RTL_GIGA_MAC_VER_46:
4135 case RTL_GIGA_MAC_VER_47:
4136 case RTL_GIGA_MAC_VER_48:
3868 ops->write = r8168g_mdio_write; 4137 ops->write = r8168g_mdio_write;
3869 ops->read = r8168g_mdio_read; 4138 ops->read = r8168g_mdio_read;
3870 break; 4139 break;
@@ -3919,6 +4188,10 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
3919 case RTL_GIGA_MAC_VER_42: 4188 case RTL_GIGA_MAC_VER_42:
3920 case RTL_GIGA_MAC_VER_43: 4189 case RTL_GIGA_MAC_VER_43:
3921 case RTL_GIGA_MAC_VER_44: 4190 case RTL_GIGA_MAC_VER_44:
4191 case RTL_GIGA_MAC_VER_45:
4192 case RTL_GIGA_MAC_VER_46:
4193 case RTL_GIGA_MAC_VER_47:
4194 case RTL_GIGA_MAC_VER_48:
3922 RTL_W32(RxConfig, RTL_R32(RxConfig) | 4195 RTL_W32(RxConfig, RTL_R32(RxConfig) |
3923 AcceptBroadcast | AcceptMulticast | AcceptMyPhys); 4196 AcceptBroadcast | AcceptMulticast | AcceptMyPhys);
3924 break; 4197 break;
@@ -3987,6 +4260,10 @@ static void r810x_pll_power_up(struct rtl8169_private *tp)
3987 case RTL_GIGA_MAC_VER_13: 4260 case RTL_GIGA_MAC_VER_13:
3988 case RTL_GIGA_MAC_VER_16: 4261 case RTL_GIGA_MAC_VER_16:
3989 break; 4262 break;
4263 case RTL_GIGA_MAC_VER_47:
4264 case RTL_GIGA_MAC_VER_48:
4265 RTL_W8(PMCH, RTL_R8(PMCH) | 0xC0);
4266 break;
3990 default: 4267 default:
3991 RTL_W8(PMCH, RTL_R8(PMCH) | 0x80); 4268 RTL_W8(PMCH, RTL_R8(PMCH) | 0x80);
3992 break; 4269 break;
@@ -4087,6 +4364,8 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)
4087 case RTL_GIGA_MAC_VER_31: 4364 case RTL_GIGA_MAC_VER_31:
4088 case RTL_GIGA_MAC_VER_32: 4365 case RTL_GIGA_MAC_VER_32:
4089 case RTL_GIGA_MAC_VER_33: 4366 case RTL_GIGA_MAC_VER_33:
4367 case RTL_GIGA_MAC_VER_45:
4368 case RTL_GIGA_MAC_VER_46:
4090 RTL_W8(PMCH, RTL_R8(PMCH) & ~0x80); 4369 RTL_W8(PMCH, RTL_R8(PMCH) & ~0x80);
4091 break; 4370 break;
4092 case RTL_GIGA_MAC_VER_40: 4371 case RTL_GIGA_MAC_VER_40:
@@ -4111,6 +4390,10 @@ static void r8168_pll_power_up(struct rtl8169_private *tp)
4111 case RTL_GIGA_MAC_VER_33: 4390 case RTL_GIGA_MAC_VER_33:
4112 RTL_W8(PMCH, RTL_R8(PMCH) | 0x80); 4391 RTL_W8(PMCH, RTL_R8(PMCH) | 0x80);
4113 break; 4392 break;
4393 case RTL_GIGA_MAC_VER_45:
4394 case RTL_GIGA_MAC_VER_46:
4395 RTL_W8(PMCH, RTL_R8(PMCH) | 0xC0);
4396 break;
4114 case RTL_GIGA_MAC_VER_40: 4397 case RTL_GIGA_MAC_VER_40:
4115 case RTL_GIGA_MAC_VER_41: 4398 case RTL_GIGA_MAC_VER_41:
4116 rtl_w1w0_eri(tp, 0x1a8, ERIAR_MASK_1111, 0xfc000000, 4399 rtl_w1w0_eri(tp, 0x1a8, ERIAR_MASK_1111, 0xfc000000,
@@ -4153,6 +4436,8 @@ static void rtl_init_pll_power_ops(struct rtl8169_private *tp)
4153 case RTL_GIGA_MAC_VER_37: 4436 case RTL_GIGA_MAC_VER_37:
4154 case RTL_GIGA_MAC_VER_39: 4437 case RTL_GIGA_MAC_VER_39:
4155 case RTL_GIGA_MAC_VER_43: 4438 case RTL_GIGA_MAC_VER_43:
4439 case RTL_GIGA_MAC_VER_47:
4440 case RTL_GIGA_MAC_VER_48:
4156 ops->down = r810x_pll_power_down; 4441 ops->down = r810x_pll_power_down;
4157 ops->up = r810x_pll_power_up; 4442 ops->up = r810x_pll_power_up;
4158 break; 4443 break;
@@ -4182,6 +4467,8 @@ static void rtl_init_pll_power_ops(struct rtl8169_private *tp)
4182 case RTL_GIGA_MAC_VER_41: 4467 case RTL_GIGA_MAC_VER_41:
4183 case RTL_GIGA_MAC_VER_42: 4468 case RTL_GIGA_MAC_VER_42:
4184 case RTL_GIGA_MAC_VER_44: 4469 case RTL_GIGA_MAC_VER_44:
4470 case RTL_GIGA_MAC_VER_45:
4471 case RTL_GIGA_MAC_VER_46:
4185 ops->down = r8168_pll_power_down; 4472 ops->down = r8168_pll_power_down;
4186 ops->up = r8168_pll_power_up; 4473 ops->up = r8168_pll_power_up;
4187 break; 4474 break;
@@ -4232,6 +4519,10 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
4232 case RTL_GIGA_MAC_VER_42: 4519 case RTL_GIGA_MAC_VER_42:
4233 case RTL_GIGA_MAC_VER_43: 4520 case RTL_GIGA_MAC_VER_43:
4234 case RTL_GIGA_MAC_VER_44: 4521 case RTL_GIGA_MAC_VER_44:
4522 case RTL_GIGA_MAC_VER_45:
4523 case RTL_GIGA_MAC_VER_46:
4524 case RTL_GIGA_MAC_VER_47:
4525 case RTL_GIGA_MAC_VER_48:
4235 RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); 4526 RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF);
4236 break; 4527 break;
4237 default: 4528 default:
@@ -4393,6 +4684,10 @@ static void rtl_init_jumbo_ops(struct rtl8169_private *tp)
4393 case RTL_GIGA_MAC_VER_42: 4684 case RTL_GIGA_MAC_VER_42:
4394 case RTL_GIGA_MAC_VER_43: 4685 case RTL_GIGA_MAC_VER_43:
4395 case RTL_GIGA_MAC_VER_44: 4686 case RTL_GIGA_MAC_VER_44:
4687 case RTL_GIGA_MAC_VER_45:
4688 case RTL_GIGA_MAC_VER_46:
4689 case RTL_GIGA_MAC_VER_47:
4690 case RTL_GIGA_MAC_VER_48:
4396 default: 4691 default:
4397 ops->disable = NULL; 4692 ops->disable = NULL;
4398 ops->enable = NULL; 4693 ops->enable = NULL;
@@ -4495,15 +4790,19 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp)
4495 tp->mac_version == RTL_GIGA_MAC_VER_31) { 4790 tp->mac_version == RTL_GIGA_MAC_VER_31) {
4496 rtl_udelay_loop_wait_low(tp, &rtl_npq_cond, 20, 42*42); 4791 rtl_udelay_loop_wait_low(tp, &rtl_npq_cond, 20, 42*42);
4497 } else if (tp->mac_version == RTL_GIGA_MAC_VER_34 || 4792 } else if (tp->mac_version == RTL_GIGA_MAC_VER_34 ||
4498 tp->mac_version == RTL_GIGA_MAC_VER_35 || 4793 tp->mac_version == RTL_GIGA_MAC_VER_35 ||
4499 tp->mac_version == RTL_GIGA_MAC_VER_36 || 4794 tp->mac_version == RTL_GIGA_MAC_VER_36 ||
4500 tp->mac_version == RTL_GIGA_MAC_VER_37 || 4795 tp->mac_version == RTL_GIGA_MAC_VER_37 ||
4501 tp->mac_version == RTL_GIGA_MAC_VER_40 || 4796 tp->mac_version == RTL_GIGA_MAC_VER_38 ||
4502 tp->mac_version == RTL_GIGA_MAC_VER_41 || 4797 tp->mac_version == RTL_GIGA_MAC_VER_40 ||
4503 tp->mac_version == RTL_GIGA_MAC_VER_42 || 4798 tp->mac_version == RTL_GIGA_MAC_VER_41 ||
4504 tp->mac_version == RTL_GIGA_MAC_VER_43 || 4799 tp->mac_version == RTL_GIGA_MAC_VER_42 ||
4505 tp->mac_version == RTL_GIGA_MAC_VER_44 || 4800 tp->mac_version == RTL_GIGA_MAC_VER_43 ||
4506 tp->mac_version == RTL_GIGA_MAC_VER_38) { 4801 tp->mac_version == RTL_GIGA_MAC_VER_44 ||
4802 tp->mac_version == RTL_GIGA_MAC_VER_45 ||
4803 tp->mac_version == RTL_GIGA_MAC_VER_46 ||
4804 tp->mac_version == RTL_GIGA_MAC_VER_47 ||
4805 tp->mac_version == RTL_GIGA_MAC_VER_48) {
4507 RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq); 4806 RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq);
4508 rtl_udelay_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); 4807 rtl_udelay_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666);
4509 } else { 4808 } else {
@@ -5330,6 +5629,105 @@ static void rtl_hw_start_8411_2(struct rtl8169_private *tp)
5330 rtl_ephy_init(tp, e_info_8411_2, ARRAY_SIZE(e_info_8411_2)); 5629 rtl_ephy_init(tp, e_info_8411_2, ARRAY_SIZE(e_info_8411_2));
5331} 5630}
5332 5631
5632static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
5633{
5634 void __iomem *ioaddr = tp->mmio_addr;
5635 struct pci_dev *pdev = tp->pci_dev;
5636 u16 rg_saw_cnt;
5637 u32 data;
5638 static const struct ephy_info e_info_8168h_1[] = {
5639 { 0x1e, 0x0800, 0x0001 },
5640 { 0x1d, 0x0000, 0x0800 },
5641 { 0x05, 0xffff, 0x2089 },
5642 { 0x06, 0xffff, 0x5881 },
5643 { 0x04, 0xffff, 0x154a },
5644 { 0x01, 0xffff, 0x068b }
5645 };
5646
5647 /* disable aspm and clock request before access ephy */
5648 RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn);
5649 RTL_W8(Config5, RTL_R8(Config5) & ~ASPM_en);
5650 rtl_ephy_init(tp, e_info_8168h_1, ARRAY_SIZE(e_info_8168h_1));
5651
5652 RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO);
5653
5654 rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x00080002, ERIAR_EXGMAC);
5655 rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x38, ERIAR_EXGMAC);
5656 rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x48, ERIAR_EXGMAC);
5657 rtl_eri_write(tp, 0xe8, ERIAR_MASK_1111, 0x00100006, ERIAR_EXGMAC);
5658
5659 rtl_csi_access_enable_1(tp);
5660
5661 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
5662
5663 rtl_w1w0_eri(tp, 0xdc, ERIAR_MASK_0001, 0x00, 0x01, ERIAR_EXGMAC);
5664 rtl_w1w0_eri(tp, 0xdc, ERIAR_MASK_0001, 0x01, 0x00, ERIAR_EXGMAC);
5665
5666 rtl_w1w0_eri(tp, 0xdc, ERIAR_MASK_1111, 0x0010, 0x00, ERIAR_EXGMAC);
5667
5668 rtl_w1w0_eri(tp, 0xd4, ERIAR_MASK_1111, 0x1f00, 0x00, ERIAR_EXGMAC);
5669
5670 rtl_eri_write(tp, 0x5f0, ERIAR_MASK_0011, 0x4f87, ERIAR_EXGMAC);
5671
5672 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
5673 RTL_W32(MISC, RTL_R32(MISC) & ~RXDV_GATED_EN);
5674 RTL_W8(MaxTxPacketSize, EarlySize);
5675
5676 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
5677 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
5678
5679 /* Adjust EEE LED frequency */
5680 RTL_W8(EEE_LED, RTL_R8(EEE_LED) & ~0x07);
5681
5682 RTL_W8(DLLPR, RTL_R8(DLLPR) & ~PFM_EN);
5683 RTL_W8(DLLPR, RTL_R8(MISC_1) & ~PFM_D3COLD_EN);
5684
5685 RTL_W8(DLLPR, RTL_R8(DLLPR) & ~TX_10M_PS_EN);
5686
5687 rtl_w1w0_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC);
5688
5689 rtl_pcie_state_l2l3_enable(tp, false);
5690
5691 rtl_writephy(tp, 0x1f, 0x0c42);
5692 rg_saw_cnt = rtl_readphy(tp, 0x13);
5693 rtl_writephy(tp, 0x1f, 0x0000);
5694 if (rg_saw_cnt > 0) {
5695 u16 sw_cnt_1ms_ini;
5696
5697 sw_cnt_1ms_ini = 16000000/rg_saw_cnt;
5698 sw_cnt_1ms_ini &= 0x0fff;
5699 data = r8168_mac_ocp_read(tp, 0xd412);
5700 data &= 0x0fff;
5701 data |= sw_cnt_1ms_ini;
5702 r8168_mac_ocp_write(tp, 0xd412, data);
5703 }
5704
5705 data = r8168_mac_ocp_read(tp, 0xe056);
5706 data &= 0xf0;
5707 data |= 0x07;
5708 r8168_mac_ocp_write(tp, 0xe056, data);
5709
5710 data = r8168_mac_ocp_read(tp, 0xe052);
5711 data &= 0x8008;
5712 data |= 0x6000;
5713 r8168_mac_ocp_write(tp, 0xe052, data);
5714
5715 data = r8168_mac_ocp_read(tp, 0xe0d6);
5716 data &= 0x01ff;
5717 data |= 0x017f;
5718 r8168_mac_ocp_write(tp, 0xe0d6, data);
5719
5720 data = r8168_mac_ocp_read(tp, 0xd420);
5721 data &= 0x0fff;
5722 data |= 0x047f;
5723 r8168_mac_ocp_write(tp, 0xd420, data);
5724
5725 r8168_mac_ocp_write(tp, 0xe63e, 0x0001);
5726 r8168_mac_ocp_write(tp, 0xe63e, 0x0000);
5727 r8168_mac_ocp_write(tp, 0xc094, 0x0000);
5728 r8168_mac_ocp_write(tp, 0xc09e, 0x0000);
5729}
5730
5333static void rtl_hw_start_8168(struct net_device *dev) 5731static void rtl_hw_start_8168(struct net_device *dev)
5334{ 5732{
5335 struct rtl8169_private *tp = netdev_priv(dev); 5733 struct rtl8169_private *tp = netdev_priv(dev);
@@ -5440,6 +5838,11 @@ static void rtl_hw_start_8168(struct net_device *dev)
5440 rtl_hw_start_8411_2(tp); 5838 rtl_hw_start_8411_2(tp);
5441 break; 5839 break;
5442 5840
5841 case RTL_GIGA_MAC_VER_45:
5842 case RTL_GIGA_MAC_VER_46:
5843 rtl_hw_start_8168h_1(tp);
5844 break;
5845
5443 default: 5846 default:
5444 printk(KERN_ERR PFX "%s: unknown chipset (mac_version = %d).\n", 5847 printk(KERN_ERR PFX "%s: unknown chipset (mac_version = %d).\n",
5445 dev->name, tp->mac_version); 5848 dev->name, tp->mac_version);
@@ -5655,6 +6058,10 @@ static void rtl_hw_start_8101(struct net_device *dev)
5655 case RTL_GIGA_MAC_VER_43: 6058 case RTL_GIGA_MAC_VER_43:
5656 rtl_hw_start_8168g_2(tp); 6059 rtl_hw_start_8168g_2(tp);
5657 break; 6060 break;
6061 case RTL_GIGA_MAC_VER_47:
6062 case RTL_GIGA_MAC_VER_48:
6063 rtl_hw_start_8168h_1(tp);
6064 break;
5658 } 6065 }
5659 6066
5660 RTL_W8(Cfg9346, Cfg9346_Lock); 6067 RTL_W8(Cfg9346, Cfg9346_Lock);
@@ -5895,7 +6302,7 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
5895{ 6302{
5896 struct skb_shared_info *info = skb_shinfo(skb); 6303 struct skb_shared_info *info = skb_shinfo(skb);
5897 unsigned int cur_frag, entry; 6304 unsigned int cur_frag, entry;
5898 struct TxDesc * uninitialized_var(txd); 6305 struct TxDesc *uninitialized_var(txd);
5899 struct device *d = &tp->pci_dev->dev; 6306 struct device *d = &tp->pci_dev->dev;
5900 6307
5901 entry = tp->cur_tx; 6308 entry = tp->cur_tx;
@@ -7110,6 +7517,10 @@ static void rtl_hw_initialize(struct rtl8169_private *tp)
7110 case RTL_GIGA_MAC_VER_42: 7517 case RTL_GIGA_MAC_VER_42:
7111 case RTL_GIGA_MAC_VER_43: 7518 case RTL_GIGA_MAC_VER_43:
7112 case RTL_GIGA_MAC_VER_44: 7519 case RTL_GIGA_MAC_VER_44:
7520 case RTL_GIGA_MAC_VER_45:
7521 case RTL_GIGA_MAC_VER_46:
7522 case RTL_GIGA_MAC_VER_47:
7523 case RTL_GIGA_MAC_VER_48:
7113 rtl_hw_init_8168g(tp); 7524 rtl_hw_init_8168g(tp);
7114 break; 7525 break;
7115 7526
@@ -7255,8 +7666,19 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7255 RTL_W8(Cfg9346, Cfg9346_Unlock); 7666 RTL_W8(Cfg9346, Cfg9346_Unlock);
7256 RTL_W8(Config1, RTL_R8(Config1) | PMEnable); 7667 RTL_W8(Config1, RTL_R8(Config1) | PMEnable);
7257 RTL_W8(Config5, RTL_R8(Config5) & (BWF | MWF | UWF | LanWake | PMEStatus)); 7668 RTL_W8(Config5, RTL_R8(Config5) & (BWF | MWF | UWF | LanWake | PMEStatus));
7258 if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0) 7669 switch (tp->mac_version) {
7259 tp->features |= RTL_FEATURE_WOL; 7670 case RTL_GIGA_MAC_VER_45:
7671 case RTL_GIGA_MAC_VER_46:
7672 if (rtl_eri_read(tp, 0xdc, ERIAR_EXGMAC) & MagicPacket_v2)
7673 tp->features |= RTL_FEATURE_WOL;
7674 if ((RTL_R8(Config3) & LinkUp) != 0)
7675 tp->features |= RTL_FEATURE_WOL;
7676 break;
7677 default:
7678 if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0)
7679 tp->features |= RTL_FEATURE_WOL;
7680 break;
7681 }
7260 if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0) 7682 if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0)
7261 tp->features |= RTL_FEATURE_WOL; 7683 tp->features |= RTL_FEATURE_WOL;
7262 tp->features |= rtl_try_msi(tp, cfg); 7684 tp->features |= rtl_try_msi(tp, cfg);
@@ -7283,6 +7705,18 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7283 u64_stats_init(&tp->tx_stats.syncp); 7705 u64_stats_init(&tp->tx_stats.syncp);
7284 7706
7285 /* Get MAC address */ 7707 /* Get MAC address */
7708 if (tp->mac_version == RTL_GIGA_MAC_VER_45 ||
7709 tp->mac_version == RTL_GIGA_MAC_VER_46 ||
7710 tp->mac_version == RTL_GIGA_MAC_VER_47 ||
7711 tp->mac_version == RTL_GIGA_MAC_VER_48) {
7712 u16 mac_addr[3];
7713
7714 *(u32 *)&mac_addr[0] = rtl_eri_read(tp, 0xE0, ERIAR_EXGMAC);
7715 *(u16 *)&mac_addr[2] = rtl_eri_read(tp, 0xE4, ERIAR_EXGMAC);
7716
7717 if (is_valid_ether_addr((u8 *)mac_addr))
7718 rtl_rar_set(tp, (u8 *)mac_addr);
7719 }
7286 for (i = 0; i < ETH_ALEN; i++) 7720 for (i = 0; i < ETH_ALEN; i++)
7287 dev->dev_addr[i] = RTL_R8(MAC0 + i); 7721 dev->dev_addr[i] = RTL_R8(MAC0 + i);
7288 7722