Commit df320ed7 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

r8169: add helpers for locking / unlocking the config registers

Add helpers for locking / unlocking the config registers.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c259b7f4
...@@ -745,6 +745,16 @@ static void rtl_unlock_work(struct rtl8169_private *tp) ...@@ -745,6 +745,16 @@ static void rtl_unlock_work(struct rtl8169_private *tp)
mutex_unlock(&tp->wk.mutex); mutex_unlock(&tp->wk.mutex);
} }
static void rtl_lock_config_regs(struct rtl8169_private *tp)
{
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
}
static void rtl_unlock_config_regs(struct rtl8169_private *tp)
{
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
}
static void rtl_tx_performance_tweak(struct rtl8169_private *tp, u16 force) static void rtl_tx_performance_tweak(struct rtl8169_private *tp, u16 force)
{ {
pcie_capability_clear_and_set_word(tp->pci_dev, PCI_EXP_DEVCTL, pcie_capability_clear_and_set_word(tp->pci_dev, PCI_EXP_DEVCTL,
...@@ -1426,7 +1436,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) ...@@ -1426,7 +1436,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
}; };
u8 options; u8 options;
RTL_W8(tp, Cfg9346, Cfg9346_Unlock); rtl_unlock_config_regs(tp);
switch (tp->mac_version) { switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38:
...@@ -1474,7 +1484,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) ...@@ -1474,7 +1484,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
break; break;
} }
RTL_W8(tp, Cfg9346, Cfg9346_Lock); rtl_lock_config_regs(tp);
device_set_wakeup_enable(tp_to_dev(tp), wolopts); device_set_wakeup_enable(tp_to_dev(tp), wolopts);
} }
...@@ -4006,7 +4016,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) ...@@ -4006,7 +4016,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
{ {
rtl_lock_work(tp); rtl_lock_work(tp);
RTL_W8(tp, Cfg9346, Cfg9346_Unlock); rtl_unlock_config_regs(tp);
RTL_W32(tp, MAC4, addr[4] | addr[5] << 8); RTL_W32(tp, MAC4, addr[4] | addr[5] << 8);
RTL_R32(tp, MAC4); RTL_R32(tp, MAC4);
...@@ -4017,7 +4027,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) ...@@ -4017,7 +4027,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
if (tp->mac_version == RTL_GIGA_MAC_VER_34) if (tp->mac_version == RTL_GIGA_MAC_VER_34)
rtl_rar_exgmac_set(tp, addr); rtl_rar_exgmac_set(tp, addr);
RTL_W8(tp, Cfg9346, Cfg9346_Lock); rtl_lock_config_regs(tp);
rtl_unlock_work(tp); rtl_unlock_work(tp);
} }
...@@ -4229,18 +4239,18 @@ static void rtl8169_init_ring_indexes(struct rtl8169_private *tp) ...@@ -4229,18 +4239,18 @@ static void rtl8169_init_ring_indexes(struct rtl8169_private *tp)
static void rtl_hw_jumbo_enable(struct rtl8169_private *tp) static void rtl_hw_jumbo_enable(struct rtl8169_private *tp)
{ {
if (tp->jumbo_ops.enable) { if (tp->jumbo_ops.enable) {
RTL_W8(tp, Cfg9346, Cfg9346_Unlock); rtl_unlock_config_regs(tp);
tp->jumbo_ops.enable(tp); tp->jumbo_ops.enable(tp);
RTL_W8(tp, Cfg9346, Cfg9346_Lock); rtl_lock_config_regs(tp);
} }
} }
static void rtl_hw_jumbo_disable(struct rtl8169_private *tp) static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
{ {
if (tp->jumbo_ops.disable) { if (tp->jumbo_ops.disable) {
RTL_W8(tp, Cfg9346, Cfg9346_Unlock); rtl_unlock_config_regs(tp);
tp->jumbo_ops.disable(tp); tp->jumbo_ops.disable(tp);
RTL_W8(tp, Cfg9346, Cfg9346_Lock); rtl_lock_config_regs(tp);
} }
} }
...@@ -4561,13 +4571,13 @@ static void rtl_set_rx_mode(struct net_device *dev) ...@@ -4561,13 +4571,13 @@ static void rtl_set_rx_mode(struct net_device *dev)
static void rtl_hw_start(struct rtl8169_private *tp) static void rtl_hw_start(struct rtl8169_private *tp)
{ {
RTL_W8(tp, Cfg9346, Cfg9346_Unlock); rtl_unlock_config_regs(tp);
tp->hw_start(tp); tp->hw_start(tp);
rtl_set_rx_max_size(tp); rtl_set_rx_max_size(tp);
rtl_set_rx_tx_desc_registers(tp); rtl_set_rx_tx_desc_registers(tp);
RTL_W8(tp, Cfg9346, Cfg9346_Lock); rtl_lock_config_regs(tp);
/* Initially a 10 us delay. Turned it into a PCI commit. - FR */ /* Initially a 10 us delay. Turned it into a PCI commit. - FR */
RTL_R8(tp, IntrMask); RTL_R8(tp, IntrMask);
...@@ -6976,9 +6986,9 @@ static int rtl_alloc_irq(struct rtl8169_private *tp) ...@@ -6976,9 +6986,9 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)
unsigned int flags; unsigned int flags;
if (tp->mac_version <= RTL_GIGA_MAC_VER_06) { if (tp->mac_version <= RTL_GIGA_MAC_VER_06) {
RTL_W8(tp, Cfg9346, Cfg9346_Unlock); rtl_unlock_config_regs(tp);
RTL_W8(tp, Config2, RTL_R8(tp, Config2) & ~MSIEnable); RTL_W8(tp, Config2, RTL_R8(tp, Config2) & ~MSIEnable);
RTL_W8(tp, Cfg9346, Cfg9346_Lock); rtl_lock_config_regs(tp);
flags = PCI_IRQ_LEGACY; flags = PCI_IRQ_LEGACY;
} else { } else {
flags = PCI_IRQ_ALL_TYPES; flags = PCI_IRQ_ALL_TYPES;
......
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