r8169: add helpers for locking / unlocking the config registers
Add helpers for locking / unlocking the config registers. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c259b7f491
commit
df320ed7b3
@ -745,6 +745,16 @@ static void rtl_unlock_work(struct rtl8169_private *tp)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
};
|
||||
u8 options;
|
||||
|
||||
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
|
||||
rtl_unlock_config_regs(tp);
|
||||
|
||||
switch (tp->mac_version) {
|
||||
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)
|
||||
break;
|
||||
}
|
||||
|
||||
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
|
||||
rtl_lock_config_regs(tp);
|
||||
|
||||
device_set_wakeup_enable(tp_to_dev(tp), wolopts);
|
||||
}
|
||||
@ -4006,7 +4016,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
|
||||
{
|
||||
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_R32(tp, MAC4);
|
||||
@ -4017,7 +4027,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
|
||||
if (tp->mac_version == RTL_GIGA_MAC_VER_34)
|
||||
rtl_rar_exgmac_set(tp, addr);
|
||||
|
||||
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
|
||||
rtl_lock_config_regs(tp);
|
||||
|
||||
rtl_unlock_work(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)
|
||||
{
|
||||
if (tp->jumbo_ops.enable) {
|
||||
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
|
||||
rtl_unlock_config_regs(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)
|
||||
{
|
||||
if (tp->jumbo_ops.disable) {
|
||||
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
|
||||
rtl_unlock_config_regs(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)
|
||||
|
||||
static void rtl_hw_start(struct rtl8169_private *tp)
|
||||
{
|
||||
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
|
||||
rtl_unlock_config_regs(tp);
|
||||
|
||||
tp->hw_start(tp);
|
||||
|
||||
rtl_set_rx_max_size(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 */
|
||||
RTL_R8(tp, IntrMask);
|
||||
@ -6976,9 +6986,9 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)
|
||||
unsigned int flags;
|
||||
|
||||
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, Cfg9346, Cfg9346_Lock);
|
||||
rtl_lock_config_regs(tp);
|
||||
flags = PCI_IRQ_LEGACY;
|
||||
} else {
|
||||
flags = PCI_IRQ_ALL_TYPES;
|
||||
|
Loading…
Reference in New Issue
Block a user