From: Kalle Valo <kvalo@codeaurora.org>
To: ath11k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 06/10] ath11k: pci: add MSI config initialisation
Date: Thu, 13 Aug 2020 12:04:22 +0300 [thread overview]
Message-ID: <1597309466-19688-7-git-send-email-kvalo@codeaurora.org> (raw)
In-Reply-To: <1597309466-19688-1-git-send-email-kvalo@codeaurora.org>
From: Govind Singh <govinds@codeaurora.org>
QCA6390 uses PCI MSI for CE/MHI/DP interrupt. Add MSI vector mapping and MSI
enable/disable operations.
Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.1.0.1-01238-QCAHKSWPL_SILICONZ-2
Signed-off-by: Govind Singh <govinds@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
---
drivers/net/wireless/ath/ath11k/debug.h | 1 +
drivers/net/wireless/ath/ath11k/pci.c | 69 +++++++++++++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/pci.h | 13 +++++++
3 files changed, 83 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/debug.h b/drivers/net/wireless/ath/ath11k/debug.h
index c30085406bfb..1cfe54859388 100644
--- a/drivers/net/wireless/ath/ath11k/debug.h
+++ b/drivers/net/wireless/ath/ath11k/debug.h
@@ -25,6 +25,7 @@ enum ath11k_debug_mask {
ATH11K_DBG_REG = 0x00000200,
ATH11K_DBG_TESTMODE = 0x00000400,
ATH11k_DBG_HAL = 0x00000800,
+ ATH11K_DBG_PCI = 0x00001000,
ATH11K_DBG_ANY = 0xffffffff,
};
diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c
index 9b1baf53ac5a..5ebbdbde81ef 100644
--- a/drivers/net/wireless/ath/ath11k/pci.c
+++ b/drivers/net/wireless/ath/ath11k/pci.c
@@ -4,6 +4,7 @@
*/
#include <linux/module.h>
+#include <linux/msi.h>
#include <linux/pci.h>
#include "pci.h"
@@ -22,6 +23,62 @@ static const struct pci_device_id ath11k_pci_id_table[] = {
MODULE_DEVICE_TABLE(pci, ath11k_pci_id_table);
+static const struct ath11k_msi_config msi_config = {
+ .total_vectors = 32,
+ .total_users = 4,
+ .users = (struct ath11k_msi_user[]) {
+ { .name = "MHI", .num_vectors = 3, .base_vector = 0 },
+ { .name = "CE", .num_vectors = 10, .base_vector = 3 },
+ { .name = "WAKE", .num_vectors = 1, .base_vector = 13 },
+ { .name = "DP", .num_vectors = 18, .base_vector = 14 },
+ },
+};
+
+static int ath11k_pci_enable_msi(struct ath11k_pci *ab_pci)
+{
+ struct ath11k_base *ab = ab_pci->ab;
+ struct msi_desc *msi_desc;
+ int num_vectors;
+ int ret;
+
+ num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
+ msi_config.total_vectors,
+ msi_config.total_vectors,
+ PCI_IRQ_MSI);
+ if (num_vectors != msi_config.total_vectors) {
+ ath11k_err(ab, "failed to get %d MSI vectors, only %d available",
+ msi_config.total_vectors, num_vectors);
+
+ if (num_vectors >= 0)
+ return -EINVAL;
+ else
+ return num_vectors;
+ }
+
+ msi_desc = irq_get_msi_desc(ab_pci->pdev->irq);
+ if (!msi_desc) {
+ ath11k_err(ab, "msi_desc is NULL!\n");
+ ret = -EINVAL;
+ goto free_msi_vector;
+ }
+
+ ab_pci->msi_ep_base_data = msi_desc->msg.data;
+
+ ath11k_dbg(ab, ATH11K_DBG_PCI, "msi base data is %d\n", ab_pci->msi_ep_base_data);
+
+ return 0;
+
+free_msi_vector:
+ pci_free_irq_vectors(ab_pci->pdev);
+
+ return ret;
+}
+
+static void ath11k_pci_disable_msi(struct ath11k_pci *ab_pci)
+{
+ pci_free_irq_vectors(ab_pci->pdev);
+}
+
static int ath11k_pci_claim(struct ath11k_pci *ab_pci, struct pci_dev *pdev)
{
struct ath11k_base *ab = ab_pci->ab;
@@ -136,6 +193,7 @@ static int ath11k_pci_probe(struct pci_dev *pdev,
ab_pci = ath11k_pci_priv(ab);
ab_pci->dev_id = pci_dev->device;
ab_pci->ab = ab;
+ ab_pci->pdev = pdev;
pci_set_drvdata(pdev, ab);
ret = ath11k_pci_claim(ab_pci, pdev);
@@ -144,10 +202,20 @@ static int ath11k_pci_probe(struct pci_dev *pdev,
goto err_free_core;
}
+ ret = ath11k_pci_enable_msi(ab_pci);
+ if (ret) {
+ ath11k_err(ab, "failed to enable msi: %d\n", ret);
+ goto err_pci_free_region;
+ }
+
return 0;
+err_pci_free_region:
+ ath11k_pci_free_region(ab_pci);
+
err_free_core:
ath11k_core_free(ab);
+
return ret;
}
@@ -157,6 +225,7 @@ static void ath11k_pci_remove(struct pci_dev *pdev)
struct ath11k_pci *ab_pci = ath11k_pci_priv(ab);
set_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags);
+ ath11k_pci_disable_msi(ab_pci);
ath11k_pci_free_region(ab_pci);
ath11k_core_free(ab);
}
diff --git a/drivers/net/wireless/ath/ath11k/pci.h b/drivers/net/wireless/ath/ath11k/pci.h
index dfd30ec09818..db75eae26f71 100644
--- a/drivers/net/wireless/ath/ath11k/pci.h
+++ b/drivers/net/wireless/ath/ath11k/pci.h
@@ -5,10 +5,23 @@
#include "core.h"
+struct ath11k_msi_user {
+ char *name;
+ int num_vectors;
+ u32 base_vector;
+};
+
+struct ath11k_msi_config {
+ int total_vectors;
+ int total_users;
+ struct ath11k_msi_user *users;
+};
+
struct ath11k_pci {
struct pci_dev *pdev;
struct ath11k_base *ab;
u16 dev_id;
+ u32 msi_ep_base_data;
};
static inline struct ath11k_pci *ath11k_pci_priv(struct ath11k_base *ab)
--
2.7.4
next prev parent reply other threads:[~2020-08-13 9:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 9:04 [PATCH 00/10] ath11k: initial PCI support Kalle Valo
2020-08-13 9:04 ` [PATCH 01/10] ath11k: do not depend on ARCH_QCOM for ath11k Kalle Valo
2020-08-17 10:15 ` Kalle Valo
2020-08-13 9:04 ` [PATCH 02/10] ath11k: add hw_params entry for QCA6390 Kalle Valo
2020-08-13 9:04 ` [PATCH 03/10] ath11k: move ring mask definitions to hw_params Kalle Valo
2020-08-13 9:04 ` [PATCH 04/10] ath11k: add simple PCI client driver for QCA6390 chipset Kalle Valo
2020-08-13 9:04 ` [PATCH 05/10] ath11k: pci: setup resources Kalle Valo
2020-08-13 9:04 ` Kalle Valo [this message]
2020-08-13 9:04 ` [PATCH 07/10] ath11k: implement ath11k_core_pre_init() Kalle Valo
2020-08-13 9:04 ` [PATCH 08/10] ath11k: register MHI controller device for QCA6390 Kalle Valo
2020-08-13 9:04 ` [PATCH 09/10] ath11k: pci: add HAL, CE and core initialisation Kalle Valo
2020-08-13 9:04 ` [PATCH 10/10] ath11k: use remoteproc only with AHB devices Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1597309466-19688-7-git-send-email-kvalo@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=ath11k@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).