Commit 9e305a6f authored by Ping-Ke Shih's avatar Ping-Ke Shih

wifi: rtw89: 8852c: correct logic and restore PCI PHY EQ after device resume

PCI PHY EQ value is missing after card off/on, so update the value after
device resume. The original commit only updates once at probe stage, which
could lead problem after suspend/resume.

The logic should be read a value from one register and write to another
register with a mask to avoid affecting unrelated bits.

Fixes: a78d33a1 ("wifi: rtw89: 8852c: disable PCI PHY EQ to improve compatibility")
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240521040139.20311-1-pkshih@realtek.com
parent d5b96a4a
...@@ -2330,21 +2330,20 @@ static void rtw89_pci_disable_eq(struct rtw89_dev *rtwdev) ...@@ -2330,21 +2330,20 @@ static void rtw89_pci_disable_eq(struct rtw89_dev *rtwdev)
u32 backup_aspm; u32 backup_aspm;
u32 phy_offset; u32 phy_offset;
u16 oobs_val; u16 oobs_val;
u16 val16;
int ret; int ret;
if (rtwdev->chip->chip_id != RTL8852C) if (rtwdev->chip->chip_id != RTL8852C)
return; return;
backup_aspm = rtw89_read32(rtwdev, R_AX_PCIE_MIX_CFG_V1);
rtw89_write32_clr(rtwdev, R_AX_PCIE_MIX_CFG_V1, B_AX_ASPM_CTRL_MASK);
g1_oobs = rtw89_read16_mask(rtwdev, R_RAC_DIRECT_OFFSET_G1 + g1_oobs = rtw89_read16_mask(rtwdev, R_RAC_DIRECT_OFFSET_G1 +
RAC_ANA09 * RAC_MULT, BAC_OOBS_SEL); RAC_ANA09 * RAC_MULT, BAC_OOBS_SEL);
g2_oobs = rtw89_read16_mask(rtwdev, R_RAC_DIRECT_OFFSET_G2 + g2_oobs = rtw89_read16_mask(rtwdev, R_RAC_DIRECT_OFFSET_G2 +
RAC_ANA09 * RAC_MULT, BAC_OOBS_SEL); RAC_ANA09 * RAC_MULT, BAC_OOBS_SEL);
if (g1_oobs && g2_oobs) if (g1_oobs && g2_oobs)
goto out; return;
backup_aspm = rtw89_read32(rtwdev, R_AX_PCIE_MIX_CFG_V1);
rtw89_write32_clr(rtwdev, R_AX_PCIE_MIX_CFG_V1, B_AX_ASPM_CTRL_MASK);
ret = rtw89_pci_get_phy_offset_by_link_speed(rtwdev, &phy_offset); ret = rtw89_pci_get_phy_offset_by_link_speed(rtwdev, &phy_offset);
if (ret) if (ret)
...@@ -2354,15 +2353,16 @@ static void rtw89_pci_disable_eq(struct rtw89_dev *rtwdev) ...@@ -2354,15 +2353,16 @@ static void rtw89_pci_disable_eq(struct rtw89_dev *rtwdev)
rtw89_write16(rtwdev, phy_offset + RAC_ANA10 * RAC_MULT, ADDR_SEL_PINOUT_DIS_VAL); rtw89_write16(rtwdev, phy_offset + RAC_ANA10 * RAC_MULT, ADDR_SEL_PINOUT_DIS_VAL);
rtw89_write16_set(rtwdev, phy_offset + RAC_ANA19 * RAC_MULT, B_PCIE_BIT_RD_SEL); rtw89_write16_set(rtwdev, phy_offset + RAC_ANA19 * RAC_MULT, B_PCIE_BIT_RD_SEL);
val16 = rtw89_read16_mask(rtwdev, phy_offset + RAC_ANA1F * RAC_MULT, oobs_val = rtw89_read16_mask(rtwdev, phy_offset + RAC_ANA1F * RAC_MULT,
OOBS_LEVEL_MASK); OOBS_LEVEL_MASK);
oobs_val = u16_encode_bits(val16, OOBS_SEN_MASK);
rtw89_write16(rtwdev, R_RAC_DIRECT_OFFSET_G1 + RAC_ANA03 * RAC_MULT, oobs_val); rtw89_write16_mask(rtwdev, R_RAC_DIRECT_OFFSET_G1 + RAC_ANA03 * RAC_MULT,
OOBS_SEN_MASK, oobs_val);
rtw89_write16_set(rtwdev, R_RAC_DIRECT_OFFSET_G1 + RAC_ANA09 * RAC_MULT, rtw89_write16_set(rtwdev, R_RAC_DIRECT_OFFSET_G1 + RAC_ANA09 * RAC_MULT,
BAC_OOBS_SEL); BAC_OOBS_SEL);
rtw89_write16(rtwdev, R_RAC_DIRECT_OFFSET_G2 + RAC_ANA03 * RAC_MULT, oobs_val); rtw89_write16_mask(rtwdev, R_RAC_DIRECT_OFFSET_G2 + RAC_ANA03 * RAC_MULT,
OOBS_SEN_MASK, oobs_val);
rtw89_write16_set(rtwdev, R_RAC_DIRECT_OFFSET_G2 + RAC_ANA09 * RAC_MULT, rtw89_write16_set(rtwdev, R_RAC_DIRECT_OFFSET_G2 + RAC_ANA09 * RAC_MULT,
BAC_OOBS_SEL); BAC_OOBS_SEL);
...@@ -2783,7 +2783,6 @@ static int rtw89_pci_ops_mac_pre_init_ax(struct rtw89_dev *rtwdev) ...@@ -2783,7 +2783,6 @@ static int rtw89_pci_ops_mac_pre_init_ax(struct rtw89_dev *rtwdev)
const struct rtw89_pci_info *info = rtwdev->pci_info; const struct rtw89_pci_info *info = rtwdev->pci_info;
int ret; int ret;
rtw89_pci_disable_eq(rtwdev);
rtw89_pci_ber(rtwdev); rtw89_pci_ber(rtwdev);
rtw89_pci_rxdma_prefth(rtwdev); rtw89_pci_rxdma_prefth(rtwdev);
rtw89_pci_l1off_pwroff(rtwdev); rtw89_pci_l1off_pwroff(rtwdev);
...@@ -4155,6 +4154,7 @@ static int __maybe_unused rtw89_pci_resume(struct device *dev) ...@@ -4155,6 +4154,7 @@ static int __maybe_unused rtw89_pci_resume(struct device *dev)
B_AX_SEL_REQ_ENTR_L1); B_AX_SEL_REQ_ENTR_L1);
} }
rtw89_pci_l2_hci_ldo(rtwdev); rtw89_pci_l2_hci_ldo(rtwdev);
rtw89_pci_disable_eq(rtwdev);
rtw89_pci_filter_out(rtwdev); rtw89_pci_filter_out(rtwdev);
rtw89_pci_link_cfg(rtwdev); rtw89_pci_link_cfg(rtwdev);
rtw89_pci_l1ss_cfg(rtwdev); rtw89_pci_l1ss_cfg(rtwdev);
...@@ -4289,6 +4289,7 @@ int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -4289,6 +4289,7 @@ int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_clear_resource; goto err_clear_resource;
} }
rtw89_pci_disable_eq(rtwdev);
rtw89_pci_filter_out(rtwdev); rtw89_pci_filter_out(rtwdev);
rtw89_pci_link_cfg(rtwdev); rtw89_pci_link_cfg(rtwdev);
rtw89_pci_l1ss_cfg(rtwdev); rtw89_pci_l1ss_cfg(rtwdev);
......
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