wlan-ap-Telecominfraproject/feeds/wifi-ax/mac80211/patches/qca/195-ath11k-add-coldboot-calibration-for-qcn9000.patch
John Crispin 528a778e38 open-converged-wireless: Import 21.02 based uCentral tree
Signed-off-by: John Crispin <john@phrozen.org>
2021-03-25 12:19:47 +01:00

229 lines
7.1 KiB
Diff

From f4fe362e3f0a3b3d08bd6cfeb57004c777d8ba0f Mon Sep 17 00:00:00 2001
From: Jaya Surya Mathavan <jmathava@codeaurora.org>
Date: Tue, 23 Jun 2020 11:40:04 +0530
Subject: [PATCH] ath11k: add coldboot calibration in qcn9000
Changed ATH11K_COLD_BOOT_FW_RESET_DELAY to 60 seconds to support qcn9000
Firmware reset after coldboot-calibration moved to qmi and made common for both ahb and pci.
Signed-off-by: Jaya Surya Mathavan <jmathava@codeaurora.org>
---
drivers/net/wireless/ath/ath11k/ahb.c | 37 +++++++++++-----------------------
drivers/net/wireless/ath/ath11k/core.h | 1 +
drivers/net/wireless/ath/ath11k/pci.c | 3 +++
drivers/net/wireless/ath/ath11k/qmi.c | 32 +++++++++++++++++++++++++++--
drivers/net/wireless/ath/ath11k/qmi.h | 3 ++-
5 files changed, 48 insertions(+), 28 deletions(-)
--- a/drivers/net/wireless/ath/ath11k/ahb.c
+++ b/drivers/net/wireless/ath/ath11k/ahb.c
@@ -11,6 +11,7 @@
#include "ahb.h"
#include "debug.h"
#include "hif.h"
+#include "qmi.h"
#include <linux/remoteproc.h>
static const struct of_device_id ath11k_ahb_of_match[] = {
@@ -338,29 +339,6 @@ static void ath11k_ahb_power_down(struct
rproc_shutdown(ab->tgt_rproc);
}
-int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
-{
- int timeout;
-
- if (enable_cold_boot_cal == 0 || ab->qmi.cal_done)
- return 0;
-
- ath11k_dbg(ab, ATH11K_DBG_AHB, "wait for cold boot done\n");
- timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, (ab->qmi.cal_done == 1),
- ATH11K_COLD_BOOT_FW_RESET_DELAY);
- if (timeout <= 0) {
- ath11k_warn(ab, "Coldboot Calibration timed out\n");
- return -ETIMEDOUT;
- }
-
- /* reset the firmware */
- ath11k_ahb_power_down(ab);
- ath11k_ahb_power_up(ab);
- ath11k_dbg(ab, ATH11K_DBG_AHB, "exit wait for cold boot done\n");
-
- return 0;
-}
-
static void ath11k_ahb_init_qmi_ce_config(struct ath11k_base *ab)
{
struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg;
@@ -633,10 +611,12 @@ static const struct ath11k_hif_ops ath11
static int ath11k_ahb_probe(struct platform_device *pdev)
{
struct ath11k_base *ab;
+ struct device *dev = &pdev->dev;
const struct of_device_id *of_id;
struct resource *mem_res;
void __iomem *mem;
int ret;
+ u32 hw_mode_id;
of_id = of_match_device(ath11k_ahb_of_match, &pdev->dev);
if (!of_id) {
@@ -674,6 +654,7 @@ static int ath11k_ahb_probe(struct platf
ab->fw_mode = ATH11K_FIRMWARE_MODE_NORMAL;
ab->mem = mem;
ab->mem_len = resource_size(mem_res);
+ ab->enable_cold_boot_cal = enable_cold_boot_cal;
platform_set_drvdata(pdev, ab);
ret = ath11k_core_pre_init(ab);
@@ -704,7 +685,15 @@ static int ath11k_ahb_probe(struct platf
goto err_ce_free;
}
- ath11k_ahb_fwreset_from_cold_boot(ab);
+ /* TODO
+ * below 4 lines can be removed once fw changes available
+ */
+ of_property_read_u32(dev->of_node, "wlan-hw-mode",
+ &hw_mode_id);
+ if (hw_mode_id == WMI_HOST_HW_MODE_2G_PHYB)
+ ab->enable_cold_boot_cal = 0;
+
+ ath11k_qmi_fwreset_from_cold_boot(ab);
return 0;
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -777,6 +777,7 @@ struct ath11k_base {
struct ath11k_targ_cap target_caps;
u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE];
bool pdevs_macaddr_valid;
+ bool enable_cold_boot_cal;
int bd_api;
struct ath11k_hw_params hw_params;
--- a/drivers/net/wireless/ath/ath11k/pci.c
+++ b/drivers/net/wireless/ath/ath11k/pci.c
@@ -12,6 +12,7 @@
#include "hif.h"
#include "mhi.h"
#include "debug.h"
+#include "qmi.h"
#include <linux/of.h>
#define ATH11K_PCI_BAR_NUM 0
@@ -984,6 +985,7 @@ static int ath11k_pci_probe(struct pci_d
case QCN9000_DEVICE_ID:
ab_pci->msi_config = &ath11k_msi_config[1];
ab->bus_params.static_window_map = true;
+ ab->enable_cold_boot_cal = enable_cold_boot_cal;
break;
default:
dev_err(&pdev->dev, "Unknown PCI device found: 0x%x\n",
@@ -1044,6 +1046,7 @@ static int ath11k_pci_probe(struct pci_d
ath11k_err(ab, "failed to init core: %d\n", ret);
goto err_free_irq;
}
+ ath11k_qmi_fwreset_from_cold_boot(ab);
return 0;
err_free_irq:
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -6,6 +6,7 @@
#include "qmi.h"
#include "core.h"
#include "debug.h"
+#include "hif.h"
#include <linux/of.h>
#include <linux/firmware.h>
#include <linux/devcoredump.h>
@@ -2278,7 +2279,6 @@ static int ath11k_qmi_assign_target_mem_
{
struct device *dev = ab->dev;
int i, idx;
- u32 caldb_location[2] = {0, 0};
u32 addr = 0;
for (i = 0, idx = 0; i < ab->qmi.mem_seg_count; i++) {
@@ -2311,12 +2311,17 @@ static int ath11k_qmi_assign_target_mem_
if (of_property_read_u32(dev->of_node, "qcom,caldb-addr", &addr))
ath11k_warn(ab, "qmi fail to get caldb-addr in dt\n");
- if (enable_cold_boot_cal) {
+ if (ab->bus_params.fixed_bdf_addr && ab->enable_cold_boot_cal) {
ab->qmi.target_mem[idx].paddr = (u32)addr;
ab->qmi.target_mem[idx].vaddr = (u32)addr;
- } else {
+ } else if (ab->bus_params.fixed_bdf_addr) {
ab->qmi.target_mem[idx].paddr = 0UL;
ab->qmi.target_mem[idx].vaddr = 0UL;
+ } else {
+ ab->qmi.target_mem[idx].paddr = (phys_addr_t)addr;
+ ab->qmi.target_mem[idx].vaddr =
+ ioremap(ab->qmi.target_mem[idx].paddr,
+ ab->qmi.target_mem[i].size);
}
ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size;
ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type;
@@ -2899,6 +2904,30 @@ int ath11k_qmi_firmware_start(struct ath
return 0;
}
+int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab)
+{
+ int timeout;
+
+ if (ab->enable_cold_boot_cal == 0 || ab->qmi.cal_done)
+ return 0;
+
+ ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n");
+
+ timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, (ab->qmi.cal_done == 1),
+ ATH11K_COLD_BOOT_FW_RESET_DELAY);
+ if (timeout <= 0) {
+ ath11k_warn(ab, "Coldboot Calibration timed out\n");
+ return -ETIMEDOUT;
+ }
+
+ /* reset the firmware */
+ ath11k_hif_power_down(ab);
+ ath11k_hif_power_up(ab);
+ ath11k_dbg(ab, ATH11K_DBG_QMI, "exit wait for cold boot done\n");
+ return 0;
+}
+EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot);
+
int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
{
int ret;
@@ -3340,7 +3369,7 @@ static void ath11k_qmi_driver_event_work
queue_work(ab->workqueue, &ab->restart_work);
break;
}
- if (enable_cold_boot_cal && ab->qmi.cal_done == 0) {
+ if (ab->enable_cold_boot_cal && ab->qmi.cal_done == 0) {
ath11k_qmi_process_coldboot_calibration(ab);
} else {
clear_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags);
--- a/drivers/net/wireless/ath/ath11k/qmi.h
+++ b/drivers/net/wireless/ath/ath11k/qmi.h
@@ -42,7 +42,7 @@
#define QMI_WLANFW_MAX_DATA_SIZE_V01 6144
#define ATH11K_FIRMWARE_MODE_OFF 4
#define ATH11K_QMI_TARGET_MEM_MODE_DEFAULT 0
-#define ATH11K_COLD_BOOT_FW_RESET_DELAY (40 * HZ)
+#define ATH11K_COLD_BOOT_FW_RESET_DELAY (60 * HZ)
struct ath11k_base;
@@ -577,6 +577,7 @@ int wlfw_send_qdss_trace_config_download
int ath11k_send_qdss_trace_mode_req(struct ath11k_base *ab,
enum wlfw_qdss_trace_mode_enum_v01 mode);
+int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab);
#endif