Commit 5894d008 authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by Kalle Valo

wifi: rtlwifi: Convert LNKCTL change to PCIe cap RMW accessors

The rtlwifi driver comes with custom code to write into PCIe Link
Control register. RMW access for the Link Control register requires
locking that is already provided by the standard PCIe capability
accessors.

Convert the custom RMW code writing into LNKCTL register to standard
RMW capability accessors. The accesses are changed to cover the full
LNKCTL register instead of touching just a single byte of the register.

Fixes: 0c817338 ("rtl8192ce: Add new driver")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231124084725.12738-3-ilpo.jarvinen@linux.intel.com
parent b3943b3c
...@@ -163,21 +163,29 @@ static bool _rtl_pci_platform_switch_device_pci_aspm( ...@@ -163,21 +163,29 @@ static bool _rtl_pci_platform_switch_device_pci_aspm(
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
value &= PCI_EXP_LNKCTL_ASPMC;
if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192SE) if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192SE)
value |= 0x40; value |= PCI_EXP_LNKCTL_CCC;
pci_write_config_byte(rtlpci->pdev, 0x80, value); pcie_capability_clear_and_set_word(rtlpci->pdev, PCI_EXP_LNKCTL,
PCI_EXP_LNKCTL_ASPMC | value,
value);
return false; return false;
} }
/*When we set 0x01 to enable clk request. Set 0x0 to disable clk req.*/ /* @value is PCI_EXP_LNKCTL_CLKREQ_EN or 0 to enable/disable clk request. */
static void _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u8 value) static void _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u16 value)
{ {
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
pci_write_config_byte(rtlpci->pdev, 0x81, value); value &= PCI_EXP_LNKCTL_CLKREQ_EN;
pcie_capability_clear_and_set_word(rtlpci->pdev, PCI_EXP_LNKCTL,
PCI_EXP_LNKCTL_CLKREQ_EN,
value);
if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE)
udelay(100); udelay(100);
...@@ -258,7 +266,8 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) ...@@ -258,7 +266,8 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw)
if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_CLK_REQ) { if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_CLK_REQ) {
_rtl_pci_switch_clk_req(hw, (ppsc->reg_rfps_level & _rtl_pci_switch_clk_req(hw, (ppsc->reg_rfps_level &
RT_RF_OFF_LEVL_CLK_REQ) ? 1 : 0); RT_RF_OFF_LEVL_CLK_REQ) ?
PCI_EXP_LNKCTL_CLKREQ_EN : 0);
RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_CLK_REQ); RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_CLK_REQ);
} }
udelay(100); udelay(100);
......
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