]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
wifi: rtw89: 8852c: add quirk to set PCI BER for certain platforms
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 29 Mar 2024 01:52:50 +0000 (09:52 +0800)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Fri, 2 Aug 2024 14:27:25 +0000 (16:27 +0200)
BugLink: https://bugs.launchpad.net/bugs/2075154
[ Upstream commit 5b919d726b613c78d4dc463dd9f90c55843fd1b3 ]

Increase PCI BER (bit error rate) count depth setting which could increase
PHY circuit fault tolerance and improve compatibility.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://msgid.link/20240329015251.22762-4-pkshih@realtek.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/pci.c
drivers/net/wireless/realtek/rtw89/pci.h
drivers/net/wireless/realtek/rtw89/rtw8851be.c
drivers/net/wireless/realtek/rtw89/rtw8852ae.c
drivers/net/wireless/realtek/rtw89/rtw8852be.c
drivers/net/wireless/realtek/rtw89/rtw8852ce.c
drivers/net/wireless/realtek/rtw89/rtw8922ae.c

index fd527a249996416c61004fc832efb7bc021eb78b..b967d80ec84b56de893485aa46921ef6fd873654 100644 (file)
@@ -3940,6 +3940,24 @@ void rtw89_core_ntfy_btc_event(struct rtw89_dev *rtwdev, enum rtw89_btc_hmsg eve
        }
 }
 
+void rtw89_check_quirks(struct rtw89_dev *rtwdev, const struct dmi_system_id *quirks)
+{
+       const struct dmi_system_id *match;
+       enum rtw89_quirks quirk;
+
+       if (!quirks)
+               return;
+
+       for (match = dmi_first_match(quirks); match; match = dmi_first_match(match + 1)) {
+               quirk = (uintptr_t)match->driver_data;
+               if (quirk >= NUM_OF_RTW89_QUIRKS)
+                       continue;
+
+               set_bit(quirk, rtwdev->quirks);
+       }
+}
+EXPORT_SYMBOL(rtw89_check_quirks);
+
 int rtw89_core_start(struct rtw89_dev *rtwdev)
 {
        int ret;
index ea6df859ba1529977f6e574ed970ceea75874b36..e72a6a958a231d7baa54ee0136071dae27e03619 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/average.h>
 #include <linux/bitfield.h>
+#include <linux/dmi.h>
 #include <linux/firmware.h>
 #include <linux/iopoll.h>
 #include <linux/workqueue.h>
@@ -3812,6 +3813,7 @@ union rtw89_bus_info {
 
 struct rtw89_driver_info {
        const struct rtw89_chip_info *chip;
+       const struct dmi_system_id *quirks;
        union rtw89_bus_info bus;
 };
 
@@ -4139,6 +4141,12 @@ enum rtw89_flags {
        NUM_OF_RTW89_FLAGS,
 };
 
+enum rtw89_quirks {
+       RTW89_QUIRK_PCI_BER,
+
+       NUM_OF_RTW89_QUIRKS,
+};
+
 enum rtw89_pkt_drop_sel {
        RTW89_PKT_DROP_SEL_MACID_BE_ONCE,
        RTW89_PKT_DROP_SEL_MACID_BK_ONCE,
@@ -4804,6 +4812,7 @@ struct rtw89_dev {
        DECLARE_BITMAP(mac_id_map, RTW89_MAX_MAC_ID_NUM);
        DECLARE_BITMAP(flags, NUM_OF_RTW89_FLAGS);
        DECLARE_BITMAP(pkt_offload, RTW89_MAX_PKT_OFLD_NUM);
+       DECLARE_BITMAP(quirks, NUM_OF_RTW89_QUIRKS);
 
        struct rtw89_phy_stat phystat;
        struct rtw89_dack_info dack;
@@ -5803,6 +5812,7 @@ int rtw89_core_sta_remove(struct rtw89_dev *rtwdev,
 void rtw89_core_set_tid_config(struct rtw89_dev *rtwdev,
                               struct ieee80211_sta *sta,
                               struct cfg80211_tid_config *tid_config);
+void rtw89_check_quirks(struct rtw89_dev *rtwdev, const struct dmi_system_id *quirks);
 int rtw89_core_init(struct rtw89_dev *rtwdev);
 void rtw89_core_deinit(struct rtw89_dev *rtwdev);
 int rtw89_core_register(struct rtw89_dev *rtwdev);
index f7686e18dec14e357703e53ae49d0a10d2eb87e0..0e989b7e4987359518baebe35c959eece739506b 100644 (file)
@@ -2234,6 +2234,22 @@ static int rtw89_pci_deglitch_setting(struct rtw89_dev *rtwdev)
        return 0;
 }
 
+static void rtw89_pci_ber(struct rtw89_dev *rtwdev)
+{
+       u32 phy_offset;
+
+       if (!test_bit(RTW89_QUIRK_PCI_BER, rtwdev->quirks))
+               return;
+
+       phy_offset = R_RAC_DIRECT_OFFSET_G1;
+       rtw89_write16(rtwdev, phy_offset + RAC_ANA1E * RAC_MULT, RAC_ANA1E_G1_VAL);
+       rtw89_write16(rtwdev, phy_offset + RAC_ANA2E * RAC_MULT, RAC_ANA2E_VAL);
+
+       phy_offset = R_RAC_DIRECT_OFFSET_G2;
+       rtw89_write16(rtwdev, phy_offset + RAC_ANA1E * RAC_MULT, RAC_ANA1E_G2_VAL);
+       rtw89_write16(rtwdev, phy_offset + RAC_ANA2E * RAC_MULT, RAC_ANA2E_VAL);
+}
+
 static void rtw89_pci_rxdma_prefth(struct rtw89_dev *rtwdev)
 {
        if (rtwdev->chip->chip_id != RTL8852A)
@@ -2631,6 +2647,7 @@ static int rtw89_pci_ops_mac_pre_init_ax(struct rtw89_dev *rtwdev)
        const struct rtw89_pci_info *info = rtwdev->pci_info;
        int ret;
 
+       rtw89_pci_ber(rtwdev);
        rtw89_pci_rxdma_prefth(rtwdev);
        rtw89_pci_l1off_pwroff(rtwdev);
        rtw89_pci_deglitch_setting(rtwdev);
@@ -4073,6 +4090,8 @@ int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        rtwdev->hci.rpwm_addr = pci_info->rpwm_addr;
        rtwdev->hci.cpwm_addr = pci_info->cpwm_addr;
 
+       rtw89_check_quirks(rtwdev, info->quirks);
+
        SET_IEEE80211_DEV(rtwdev->hw, &pdev->dev);
 
        ret = rtw89_core_init(rtwdev);
index 772a84bd8db6b38518bfa676baf93a30a9e23d8e..b50d7a18e30bc2158e4c9957fc5088d95289dc76 100644 (file)
 #define RAC_REG_FLD_0                  0x1D
 #define BAC_AUTOK_N_MASK               GENMASK(3, 2)
 #define PCIE_AUTOK_4                   0x3
+#define RAC_ANA1E                      0x1E
+#define RAC_ANA1E_G1_VAL               0x66EA
+#define RAC_ANA1E_G2_VAL               0x6EEA
 #define RAC_ANA1F                      0x1F
 #define RAC_ANA24                      0x24
 #define B_AX_DEGLITCH                  GENMASK(11, 8)
 #define RAC_ANA26                      0x26
 #define B_AX_RXEN                      GENMASK(15, 14)
+#define RAC_ANA2E                      0x2E
+#define RAC_ANA2E_VAL                  0xFFFE
 #define RAC_CTRL_PPR_V1                        0x30
 #define B_AX_CLK_CALIB_EN              BIT(12)
 #define B_AX_CALIB_EN                  BIT(13)
index ca1374a717272271e78426f24f55124d83c223c8..ec3629d95fda1d7eb5d67928f453931eb4b9df20 100644 (file)
@@ -63,6 +63,7 @@ static const struct rtw89_pci_info rtw8851b_pci_info = {
 
 static const struct rtw89_driver_info rtw89_8851be_info = {
        .chip = &rtw8851b_chip_info,
+       .quirks = NULL,
        .bus = {
                .pci = &rtw8851b_pci_info,
        },
index 7c6ffedb77e27d39b7fb5df857ff343343adf477..fdee5dd4ba148b57396c35da11089f1e8f5984a7 100644 (file)
@@ -61,6 +61,7 @@ static const struct rtw89_pci_info rtw8852a_pci_info = {
 
 static const struct rtw89_driver_info rtw89_8852ae_info = {
        .chip = &rtw8852a_chip_info,
+       .quirks = NULL,
        .bus = {
                .pci = &rtw8852a_pci_info,
        },
index ed71364e6437b7db6e6d09b96417b093bfc92620..5f941122655c42f7b53144947ca42a4a1348c020 100644 (file)
@@ -63,6 +63,7 @@ static const struct rtw89_pci_info rtw8852b_pci_info = {
 
 static const struct rtw89_driver_info rtw89_8852be_info = {
        .chip = &rtw8852b_chip_info,
+       .quirks = NULL,
        .bus = {
                .pci = &rtw8852b_pci_info,
        },
index 583ea673a4f542dee33d34d615a19e025ae8a74b..e07c7f3ade41efb3acf30e6730ed9960de456ad6 100644 (file)
@@ -68,8 +68,31 @@ static const struct rtw89_pci_info rtw8852c_pci_info = {
        .recognize_intrs        = rtw89_pci_recognize_intrs_v1,
 };
 
+static const struct dmi_system_id rtw8852c_pci_quirks[] = {
+       {
+               .ident = "Dell Inc. Vostro 16 5640",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 16 5640"),
+                       DMI_MATCH(DMI_PRODUCT_SKU, "0CA0"),
+               },
+               .driver_data = (void *)RTW89_QUIRK_PCI_BER,
+       },
+       {
+               .ident = "Dell Inc. Inspiron 16 5640",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 16 5640"),
+                       DMI_MATCH(DMI_PRODUCT_SKU, "0C9F"),
+               },
+               .driver_data = (void *)RTW89_QUIRK_PCI_BER,
+       },
+       {},
+};
+
 static const struct rtw89_driver_info rtw89_8852ce_info = {
        .chip = &rtw8852c_chip_info,
+       .quirks = rtw8852c_pci_quirks,
        .bus = {
                .pci = &rtw8852c_pci_info,
        },
index 9f46fb16610554e1a52b22f86a28fcb9bb2f5456..15ea8e20dde36480b23b754481c58bdadcc5904f 100644 (file)
@@ -61,6 +61,7 @@ static const struct rtw89_pci_info rtw8922a_pci_info = {
 
 static const struct rtw89_driver_info rtw89_8922ae_info = {
        .chip = &rtw8922a_chip_info,
+       .quirks = NULL,
        .bus = {
                .pci = &rtw8922a_pci_info,
        },