wlan-ap-Telecominfraproject/feeds/ipq807x/mac80211/patches/155-ath11k-setup-pci-resource-for-QCA6x90-target.patch
John Crispin 3affbc1cad QualComm/AX: add Hawkeye and Cypress support
This series is based on
* 2020-07-10 ipq6018-ilq-11-0_qca_oem-034672b0676c37b1f4519e5720e18e95fe6236ef

Add support for
* qsdk kernel/v4.4
* qsdk ethernet subsystem
* v5.7 ath11k backport + QualComm staging patches (wlan_ap_1.0)
* ath11k-firmware
* hostapd/iw/...

Feature support
* full boot, system detection
* sysupgrade to nand
* HE support via latest hostapd
* driver support for usb, crypto, hwmon, cpufreq, ...

Missing
* NSS/HW flow offloading - FW blob is not redistributable

Using the qsdk v4.4 is an intermediate solution while the vanilla is being
tested. Vanilla kernel is almost on feature par. Work has already started
to upstream the ethernet and switch drivers. Once complete the target will
be fully upstream.

Signed-off-by: John Crispin <john@phrozen.org>
2020-07-23 18:54:03 +02:00

185 lines
5.0 KiB
Diff

From 23919eb122358de28eede398e9f1ad9295f205da Mon Sep 17 00:00:00 2001
From: Anilkumar Kolli <akolli@codeaurora.org>
Date: Mon, 23 Mar 2020 14:22:06 +0530
Subject: [PATCH 155/164] ath11k: setup pci resource for QCA6x90 target
Add support for setting up pci region and dma mask
for QCA6x90 target.
Signed-off-by: Govind Singh <govinds@codeaurora.org>
Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org>
---
drivers/net/wireless/ath/ath11k/core.c | 1 +
drivers/net/wireless/ath/ath11k/pci.c | 95 +++++++++++++++++++++++++++++++++-
drivers/net/wireless/ath/ath11k/pci.h | 12 +++++
3 files changed, 107 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index ad1c10fb8379..396e08071619 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -14,6 +14,7 @@
#include "hif.h"
unsigned int ath11k_debug_mask;
+EXPORT_SYMBOL(ath11k_debug_mask);
unsigned int rawmode;
unsigned int cryptmode;
unsigned int ath11k_ethernet_mode = 1;
diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c
index 84d9bc060636..fad919201047 100644
--- a/drivers/net/wireless/ath/ath11k/pci.c
+++ b/drivers/net/wireless/ath/ath11k/pci.c
@@ -6,6 +6,7 @@
#include <linux/module.h>
#include <linux/pci.h>
+#include "ahb.h"
#include "core.h"
#include "pci.h"
#include "debug.h"
@@ -18,10 +19,86 @@ static const struct pci_device_id ath11k_pci_id_table[] = {
MODULE_DEVICE_TABLE(pci, ath11k_pci_id_table);
+static inline struct ath11k_pci *ath11k_pci_priv(struct ath11k_base *ab)
+{
+ return (struct ath11k_pci *)ab->drv_priv;
+}
+
+static int ath11k_pci_claim(struct ath11k_pci *ar_pci, struct pci_dev *pdev)
+{
+ u32 pci_dma_mask = PCI_DMA_MASK_32_BIT;
+ struct ath11k_base *ab = ar_pci->ab;
+ u16 device_id;
+ int ret = 0;
+
+ pci_read_config_word(pdev, PCI_DEVICE_ID, &device_id);
+ if (device_id != ar_pci->dev_id) {
+ ath11k_err(ab, "pci device id mismatch, config ID: 0x%x, probe ID: 0x%x\n",
+ device_id, ar_pci->dev_id);
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = pci_assign_resource(pdev, PCI_BAR_NUM);
+ if (ret) {
+ ath11k_err(ab, "failed to assign pci resource, err = %d\n", ret);
+ goto out;
+ }
+
+ ret = pci_enable_device(pdev);
+ if (ret) {
+ ath11k_err(ab, "failed to enable pci device, err = %d\n", ret);
+ goto out;
+ }
+
+ ret = pci_request_region(pdev, PCI_BAR_NUM, "ath11k_pci");
+ if (ret) {
+ ath11k_err(ab, "failed to request pci region, err = %d\n", ret);
+ goto disable_device;
+ }
+
+ ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(pci_dma_mask));
+ if (ret) {
+ ath11k_err(ab, "failed to set pci dma mask (%d), err = %d\n",
+ ret, pci_dma_mask);
+ goto release_region;
+ }
+
+ ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(pci_dma_mask));
+ if (ret) {
+ ath11k_err(ab, "failed to set pci consistent dma mask (%d), err = %d\n",
+ ret, pci_dma_mask);
+ goto release_region;
+ }
+
+ pci_set_master(pdev);
+
+ ar_pci->mem_len = pci_resource_len(pdev, PCI_BAR_NUM);
+ ar_pci->mem = pci_iomap(pdev, PCI_BAR_NUM, 0);
+ if (!ar_pci->mem) {
+ ath11k_err(ab, "failed to map pci bar, bar = %d\n", PCI_BAR_NUM);
+ ret = -EIO;
+ goto clear_master;
+ }
+
+ ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot pci_mem 0x%pK\n", ar_pci->mem);
+ return 0;
+
+clear_master:
+ pci_clear_master(pdev);
+release_region:
+ pci_release_region(pdev, PCI_BAR_NUM);
+disable_device:
+ pci_disable_device(pdev);
+out:
+ return ret;
+}
+
static int ath11k_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *pci_dev)
{
struct ath11k_base *ab;
+ struct ath11k_pci *ar_pci;
enum ath11k_hw_rev hw_rev;
int ret;
@@ -38,7 +115,7 @@ static int ath11k_pci_probe(struct pci_dev *pdev,
return -ENOTSUPP;
}
- ab = ath11k_core_alloc(&pdev->dev, 0, ATH11K_BUS_PCI);
+ ab = ath11k_core_alloc(&pdev->dev, sizeof(*ar_pci), ATH11K_BUS_PCI);
if (!ab) {
dev_err(&pdev->dev, "failed to allocate ath11k base\n");
return -ENOMEM;
@@ -47,7 +124,23 @@ static int ath11k_pci_probe(struct pci_dev *pdev,
ab->dev = &pdev->dev;
ab->hw_rev = hw_rev;
pci_set_drvdata(pdev, ab);
+ ar_pci = ath11k_pci_priv(ab);
+ ar_pci->dev_id = pci_dev->device;
+ ar_pci->ab = ab;
+ ab->dev = &pdev->dev;
+ ab->hw_rev = hw_rev;
+ pci_set_drvdata(pdev, ab);
+ ret = ath11k_pci_claim(ar_pci, pdev);
+ if (ret) {
+ ath11k_err(ab, "failed to claim device: %d\n", ret);
+ goto err_free_core;
+ }
+
+ return 0;
+
+err_free_core:
+ ath11k_core_free(ab);
return ret;
}
diff --git a/drivers/net/wireless/ath/ath11k/pci.h b/drivers/net/wireless/ath/ath11k/pci.h
index 52003bcbf733..d9785cea8d89 100644
--- a/drivers/net/wireless/ath/ath11k/pci.h
+++ b/drivers/net/wireless/ath/ath11k/pci.h
@@ -7,4 +7,16 @@
#define QCA6290_DEVICE_ID 0x1100
#define QCA6390_VENDOR_ID 0x17CB
#define QCA6390_DEVICE_ID 0x1101
+#define PCI_BAR_NUM 0
+#define PCI_DMA_MASK_64_BIT 64
+#define PCI_DMA_MASK_32_BIT 32
+struct ath11k_pci {
+ struct pci_dev *pdev;
+ struct device *dev;
+ struct ath11k_base *ab;
+ void __iomem *mem;
+ size_t mem_len;
+ u16 dev_id;
+ u32 chip_id;
+};
--
2.7.4