]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: refactor PCI window register access
authorBaochen Qiang <baochen.qiang@oss.qualcomm.com>
Mon, 12 Jan 2026 07:36:21 +0000 (15:36 +0800)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Fri, 16 Jan 2026 01:19:38 +0000 (17:19 -0800)
Currently offset of PCI window register address is defined as 0x310c which
is same across existing chips. However QCC2072 has a different offset
0x3278.

In order to make the window selection logic work for QCC2072 as well,
change to initialize this parameter per device at the probe time.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3

Signed-off-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20260112-ath12k-support-qcc2072-v2-1-fc8ce1e43969@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/pci.c
drivers/net/wireless/ath/ath12k/pci.h
drivers/net/wireless/ath/ath12k/wifi7/pci.c

index 151ae0c354780d1dcdd4795944231839046299d2..69579e59b5563a8aed0b8f92dafca9bbf6430656 100644 (file)
@@ -23,7 +23,6 @@
 #define ATH12K_PCI_IRQ_CE0_OFFSET              3
 
 #define WINDOW_ENABLE_BIT              0x40000000
-#define WINDOW_REG_ADDRESS             0x310c
 #define WINDOW_VALUE_MASK              GENMASK(24, 19)
 #define WINDOW_START                   0x80000
 #define WINDOW_RANGE_MASK              GENMASK(18, 0)
@@ -125,8 +124,8 @@ static void ath12k_pci_select_window(struct ath12k_pci *ab_pci, u32 offset)
 
        if (window != ab_pci->register_window) {
                iowrite32(WINDOW_ENABLE_BIT | window,
-                         ab->mem + WINDOW_REG_ADDRESS);
-               ioread32(ab->mem + WINDOW_REG_ADDRESS);
+                         ab->mem + ab_pci->window_reg_addr);
+               ioread32(ab->mem + ab_pci->window_reg_addr);
                ab_pci->register_window = window;
        }
 }
@@ -145,7 +144,7 @@ static void ath12k_pci_select_static_window(struct ath12k_pci *ab_pci)
        ab_pci->register_window = window;
        spin_unlock_bh(&ab_pci->window_lock);
 
-       iowrite32(WINDOW_ENABLE_BIT | window, ab_pci->ab->mem + WINDOW_REG_ADDRESS);
+       iowrite32(WINDOW_ENABLE_BIT | window, ab_pci->ab->mem + ab_pci->window_reg_addr);
 }
 
 static u32 ath12k_pci_get_window_start(struct ath12k_base *ab,
@@ -178,8 +177,8 @@ static void ath12k_pci_restore_window(struct ath12k_base *ab)
        spin_lock_bh(&ab_pci->window_lock);
 
        iowrite32(WINDOW_ENABLE_BIT | ab_pci->register_window,
-                 ab->mem + WINDOW_REG_ADDRESS);
-       ioread32(ab->mem + WINDOW_REG_ADDRESS);
+                 ab->mem + ab_pci->window_reg_addr);
+       ioread32(ab->mem + ab_pci->window_reg_addr);
 
        spin_unlock_bh(&ab_pci->window_lock);
 }
index 1cc4f0e050f9542992fe06162eb577a4c541ca7c..a74b09d23a6a10343e88224774a563ec9082fdd0 100644 (file)
@@ -130,6 +130,8 @@ struct ath12k_pci {
        u64 dma_mask;
        const struct ath12k_pci_device_family_ops *device_family_ops;
        const struct ath12k_pci_reg_base *reg_base;
+
+       u32 window_reg_addr;
 };
 
 struct ath12k_pci_driver {
index dedc88858bb0f78c42dae8de946a2e4dae4fc943..6c477fe97298ffd2eda5e1ebba32014359ca2a89 100644 (file)
@@ -27,6 +27,8 @@
 #define TCSR_SOC_HW_VERSION_MAJOR_MASK GENMASK(11, 8)
 #define TCSR_SOC_HW_VERSION_MINOR_MASK GENMASK(7, 4)
 
+#define WINDOW_REG_ADDRESS             0x310c
+
 static const struct pci_device_id ath12k_wifi7_pci_id_table[] = {
        { PCI_VDEVICE(QCOM, QCN9274_DEVICE_ID) },
        { PCI_VDEVICE(QCOM, WCN7850_DEVICE_ID) },
@@ -104,6 +106,11 @@ static int ath12k_wifi7_pci_probe(struct pci_dev *pdev,
                ab_pci->msi_config = &ath12k_wifi7_msi_config[0];
                ab->static_window_map = true;
                ab_pci->pci_ops = &ath12k_wifi7_pci_ops_qcn9274;
+               /*
+                * init window reg addr before reading hardware version
+                * as it will be used there
+                */
+               ab_pci->window_reg_addr = WINDOW_REG_ADDRESS;
                ath12k_wifi7_pci_read_hw_version(ab, &soc_hw_version_major,
                                                 &soc_hw_version_minor);
                ab->target_mem_mode = ath12k_core_get_memory_mode(ab);
@@ -126,6 +133,11 @@ static int ath12k_wifi7_pci_probe(struct pci_dev *pdev,
                ab_pci->msi_config = &ath12k_wifi7_msi_config[0];
                ab->static_window_map = false;
                ab_pci->pci_ops = &ath12k_wifi7_pci_ops_wcn7850;
+               /*
+                * init window reg addr before reading hardware version
+                * as it will be used there
+                */
+               ab_pci->window_reg_addr = WINDOW_REG_ADDRESS;
                ath12k_wifi7_pci_read_hw_version(ab, &soc_hw_version_major,
                                                 &soc_hw_version_minor);
                ab->target_mem_mode = ATH12K_QMI_MEMORY_MODE_DEFAULT;