Commit 0b55b630 authored by David S. Miller's avatar David S. Miller

Merge branch 'r8169-add-and-use-helper-rtl_is_8168evl_up'

Heiner Kallweit says:

====================
r8169: add and use helper rtl_is_8168evl_up

Few registers have been added or changed its purpose with version
RTL8168e-vl, so create a helper for identifying chip versions from
RTL8168e-vl.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 20023d3e 272b2265
...@@ -724,6 +724,12 @@ static void rtl_tx_performance_tweak(struct rtl8169_private *tp, u16 force) ...@@ -724,6 +724,12 @@ static void rtl_tx_performance_tweak(struct rtl8169_private *tp, u16 force)
PCI_EXP_DEVCTL_READRQ, force); PCI_EXP_DEVCTL_READRQ, force);
} }
static bool rtl_is_8168evl_up(struct rtl8169_private *tp)
{
return tp->mac_version >= RTL_GIGA_MAC_VER_34 &&
tp->mac_version != RTL_GIGA_MAC_VER_39;
}
struct rtl_cond { struct rtl_cond {
bool (*check)(struct rtl8169_private *); bool (*check)(struct rtl8169_private *);
const char *msg; const char *msg;
...@@ -1389,9 +1395,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) ...@@ -1389,9 +1395,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
rtl_unlock_config_regs(tp); rtl_unlock_config_regs(tp);
switch (tp->mac_version) { if (rtl_is_8168evl_up(tp)) {
case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38:
case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_51:
tmp = ARRAY_SIZE(cfg) - 1; tmp = ARRAY_SIZE(cfg) - 1;
if (wolopts & WAKE_MAGIC) if (wolopts & WAKE_MAGIC)
rtl_eri_set_bits(tp, 0x0dc, ERIAR_MASK_0100, rtl_eri_set_bits(tp, 0x0dc, ERIAR_MASK_0100,
...@@ -1399,10 +1403,8 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) ...@@ -1399,10 +1403,8 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
else else
rtl_eri_clear_bits(tp, 0x0dc, ERIAR_MASK_0100, rtl_eri_clear_bits(tp, 0x0dc, ERIAR_MASK_0100,
MagicPacket_v2); MagicPacket_v2);
break; } else {
default:
tmp = ARRAY_SIZE(cfg); tmp = ARRAY_SIZE(cfg);
break;
} }
for (i = 0; i < tmp; i++) { for (i = 0; i < tmp; i++) {
...@@ -4101,8 +4103,7 @@ static void rtl_set_tx_config_registers(struct rtl8169_private *tp) ...@@ -4101,8 +4103,7 @@ static void rtl_set_tx_config_registers(struct rtl8169_private *tp)
u32 val = TX_DMA_BURST << TxDMAShift | u32 val = TX_DMA_BURST << TxDMAShift |
InterFrameGap << TxInterFrameGapShift; InterFrameGap << TxInterFrameGapShift;
if (tp->mac_version >= RTL_GIGA_MAC_VER_34 && if (rtl_is_8168evl_up(tp))
tp->mac_version != RTL_GIGA_MAC_VER_39)
val |= TXCFG_AUTO_FIFO; val |= TXCFG_AUTO_FIFO;
RTL_W32(tp, TxConfig, val); RTL_W32(tp, TxConfig, val);
...@@ -4330,8 +4331,6 @@ static void rtl_hw_start_8168bef(struct rtl8169_private *tp) ...@@ -4330,8 +4331,6 @@ static void rtl_hw_start_8168bef(struct rtl8169_private *tp)
{ {
rtl_hw_start_8168bb(tp); rtl_hw_start_8168bb(tp);
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~(1 << 0)); RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~(1 << 0));
} }
...@@ -4383,8 +4382,6 @@ static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp) ...@@ -4383,8 +4382,6 @@ static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
/* Magic. */ /* Magic. */
RTL_W8(tp, DBG_REG, 0x20); RTL_W8(tp, DBG_REG, 0x20);
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
if (tp->dev->mtu <= ETH_DATA_LEN) if (tp->dev->mtu <= ETH_DATA_LEN)
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B); rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
} }
...@@ -4438,8 +4435,6 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp) ...@@ -4438,8 +4435,6 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp)
rtl_disable_clock_request(tp); rtl_disable_clock_request(tp);
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
if (tp->dev->mtu <= ETH_DATA_LEN) if (tp->dev->mtu <= ETH_DATA_LEN)
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B); rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
} }
...@@ -4451,8 +4446,6 @@ static void rtl_hw_start_8168dp(struct rtl8169_private *tp) ...@@ -4451,8 +4446,6 @@ static void rtl_hw_start_8168dp(struct rtl8169_private *tp)
if (tp->dev->mtu <= ETH_DATA_LEN) if (tp->dev->mtu <= ETH_DATA_LEN)
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B); rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
rtl_disable_clock_request(tp); rtl_disable_clock_request(tp);
} }
...@@ -4468,8 +4461,6 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp) ...@@ -4468,8 +4461,6 @@ static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B); rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
rtl_ephy_init(tp, e_info_8168d_4); rtl_ephy_init(tp, e_info_8168d_4);
rtl_enable_clock_request(tp); rtl_enable_clock_request(tp);
...@@ -4500,8 +4491,6 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp) ...@@ -4500,8 +4491,6 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
if (tp->dev->mtu <= ETH_DATA_LEN) if (tp->dev->mtu <= ETH_DATA_LEN)
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B); rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
rtl_disable_clock_request(tp); rtl_disable_clock_request(tp);
/* Reset tx FIFO pointer */ /* Reset tx FIFO pointer */
...@@ -4533,8 +4522,6 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp) ...@@ -4533,8 +4522,6 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
rtl_eri_set_bits(tp, 0x1b0, ERIAR_MASK_0001, BIT(4)); rtl_eri_set_bits(tp, 0x1b0, ERIAR_MASK_0001, BIT(4));
rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0xff00); rtl_w0w1_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0c00, 0xff00);
RTL_W8(tp, MaxTxPacketSize, EarlySize);
rtl_disable_clock_request(tp); rtl_disable_clock_request(tp);
RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB); RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB);
...@@ -4563,8 +4550,6 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp) ...@@ -4563,8 +4550,6 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp)
rtl_eri_write(tp, 0xcc, ERIAR_MASK_1111, 0x00000050); rtl_eri_write(tp, 0xcc, ERIAR_MASK_1111, 0x00000050);
rtl_eri_write(tp, 0xd0, ERIAR_MASK_1111, 0x00000060); rtl_eri_write(tp, 0xd0, ERIAR_MASK_1111, 0x00000060);
RTL_W8(tp, MaxTxPacketSize, EarlySize);
rtl_disable_clock_request(tp); rtl_disable_clock_request(tp);
RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB); RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB);
...@@ -4621,7 +4606,6 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp) ...@@ -4621,7 +4606,6 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp)
rtl_eri_write(tp, 0x2f8, ERIAR_MASK_0011, 0x1d8f); rtl_eri_write(tp, 0x2f8, ERIAR_MASK_0011, 0x1d8f);
RTL_W32(tp, MISC, RTL_R32(tp, MISC) & ~RXDV_GATED_EN); RTL_W32(tp, MISC, RTL_R32(tp, MISC) & ~RXDV_GATED_EN);
RTL_W8(tp, MaxTxPacketSize, EarlySize);
rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000); rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000);
rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000); rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000);
...@@ -4719,7 +4703,6 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp) ...@@ -4719,7 +4703,6 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
rtl_eri_write(tp, 0x5f0, ERIAR_MASK_0011, 0x4f87); rtl_eri_write(tp, 0x5f0, ERIAR_MASK_0011, 0x4f87);
RTL_W32(tp, MISC, RTL_R32(tp, MISC) & ~RXDV_GATED_EN); RTL_W32(tp, MISC, RTL_R32(tp, MISC) & ~RXDV_GATED_EN);
RTL_W8(tp, MaxTxPacketSize, EarlySize);
rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000); rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000);
rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000); rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000);
...@@ -4795,7 +4778,6 @@ static void rtl_hw_start_8168ep(struct rtl8169_private *tp) ...@@ -4795,7 +4778,6 @@ static void rtl_hw_start_8168ep(struct rtl8169_private *tp)
rtl_eri_write(tp, 0x5f0, ERIAR_MASK_0011, 0x4f87); rtl_eri_write(tp, 0x5f0, ERIAR_MASK_0011, 0x4f87);
RTL_W32(tp, MISC, RTL_R32(tp, MISC) & ~RXDV_GATED_EN); RTL_W32(tp, MISC, RTL_R32(tp, MISC) & ~RXDV_GATED_EN);
RTL_W8(tp, MaxTxPacketSize, EarlySize);
rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000); rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000);
rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000); rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000);
...@@ -5067,7 +5049,10 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp) ...@@ -5067,7 +5049,10 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)
pcie_capability_set_word(tp->pci_dev, PCI_EXP_DEVCTL, pcie_capability_set_word(tp->pci_dev, PCI_EXP_DEVCTL,
PCI_EXP_DEVCTL_NOSNOOP_EN); PCI_EXP_DEVCTL_NOSNOOP_EN);
RTL_W8(tp, MaxTxPacketSize, TxPacketMax); if (rtl_is_8168evl_up(tp))
RTL_W8(tp, MaxTxPacketSize, EarlySize);
else
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
rtl_hw_config(tp); rtl_hw_config(tp);
} }
...@@ -6483,13 +6468,10 @@ static int rtl_alloc_irq(struct rtl8169_private *tp) ...@@ -6483,13 +6468,10 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)
static void rtl_read_mac_address(struct rtl8169_private *tp, static void rtl_read_mac_address(struct rtl8169_private *tp,
u8 mac_addr[ETH_ALEN]) u8 mac_addr[ETH_ALEN])
{ {
u32 value;
/* Get MAC address */ /* Get MAC address */
switch (tp->mac_version) { if (rtl_is_8168evl_up(tp) && tp->mac_version != RTL_GIGA_MAC_VER_34) {
case RTL_GIGA_MAC_VER_35 ... RTL_GIGA_MAC_VER_38: u32 value = rtl_eri_read(tp, 0xe0);
case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_51:
value = rtl_eri_read(tp, 0xe0);
mac_addr[0] = (value >> 0) & 0xff; mac_addr[0] = (value >> 0) & 0xff;
mac_addr[1] = (value >> 8) & 0xff; mac_addr[1] = (value >> 8) & 0xff;
mac_addr[2] = (value >> 16) & 0xff; mac_addr[2] = (value >> 16) & 0xff;
...@@ -6498,9 +6480,6 @@ static void rtl_read_mac_address(struct rtl8169_private *tp, ...@@ -6498,9 +6480,6 @@ static void rtl_read_mac_address(struct rtl8169_private *tp,
value = rtl_eri_read(tp, 0xe4); value = rtl_eri_read(tp, 0xe4);
mac_addr[4] = (value >> 0) & 0xff; mac_addr[4] = (value >> 0) & 0xff;
mac_addr[5] = (value >> 8) & 0xff; mac_addr[5] = (value >> 8) & 0xff;
break;
default:
break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment