generic: replace simple AQR hack patch with upstream version
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / ath11k / 0004-wifi-ath11k-Add-coldboot-calibration-support-for-QCN.patch
1 From bdfc967bf5fcd762473a01d39edb81f1165ba290 Mon Sep 17 00:00:00 2001
2 From: Anilkumar Kolli <quic_akolli@quicinc.com>
3 Date: Wed, 26 Jul 2023 19:40:31 +0530
4 Subject: [PATCH 4/5] wifi: ath11k: Add coldboot calibration support for
5 QCN9074
6
7 QCN9074 supports 6 GHz, which has increased number of channels
8 compared to 5 GHz/2 GHz. So, to support coldboot calibration in
9 QCN9074 ATH11K_COLD_BOOT_FW_RESET_DELAY extended to 60 seconds. To
10 avoid code redundancy, fwreset_from_cold_boot moved to QMI and made
11 common for both ahb and pci. Coldboot calibration is enabled only in
12 FTM mode for QCN9074. QCN9074 requires firmware restart after coldboot,
13 hence enable cbcal_restart_fw in hw_params.
14
15 This support can be enabled/disabled using hw params for different
16 hardware. Currently it is not enabled for QCA6390.
17
18 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
19
20 Signed-off-by: Anilkumar Kolli <quic_akolli@quicinc.com>
21 Signed-off-by: Seevalamuthu Mariappan <quic_seevalam@quicinc.com>
22 Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
23 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
24 Link: https://lore.kernel.org/r/20230726141032.3061-3-quic_rajkbhag@quicinc.com
25 ---
26 drivers/net/wireless/ath/ath11k/ahb.c | 28 ++------------------------
27 drivers/net/wireless/ath/ath11k/core.c | 4 ++--
28 drivers/net/wireless/ath/ath11k/pci.c | 2 ++
29 drivers/net/wireless/ath/ath11k/qmi.c | 28 ++++++++++++++++++++++++++
30 drivers/net/wireless/ath/ath11k/qmi.h | 3 ++-
31 5 files changed, 36 insertions(+), 29 deletions(-)
32
33 --- a/drivers/net/wireless/ath/ath11k/ahb.c
34 +++ b/drivers/net/wireless/ath/ath11k/ahb.c
35 @@ -14,6 +14,7 @@
36 #include "ahb.h"
37 #include "debug.h"
38 #include "hif.h"
39 +#include "qmi.h"
40 #include <linux/remoteproc.h>
41 #include "pcic.h"
42 #include <linux/soc/qcom/smem.h>
43 @@ -418,31 +419,6 @@ static void ath11k_ahb_power_down(struct
44 rproc_shutdown(ab_ahb->tgt_rproc);
45 }
46
47 -static int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
48 -{
49 - int timeout;
50 -
51 - if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done ||
52 - ab->hw_params.cbcal_restart_fw == 0)
53 - return 0;
54 -
55 - ath11k_dbg(ab, ATH11K_DBG_AHB, "wait for cold boot done\n");
56 - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
57 - (ab->qmi.cal_done == 1),
58 - ATH11K_COLD_BOOT_FW_RESET_DELAY);
59 - if (timeout <= 0) {
60 - ath11k_cold_boot_cal = 0;
61 - ath11k_warn(ab, "Coldboot Calibration failed timed out\n");
62 - }
63 -
64 - /* reset the firmware */
65 - ath11k_ahb_power_down(ab);
66 - ath11k_ahb_power_up(ab);
67 -
68 - ath11k_dbg(ab, ATH11K_DBG_AHB, "exited from cold boot mode\n");
69 - return 0;
70 -}
71 -
72 static void ath11k_ahb_init_qmi_ce_config(struct ath11k_base *ab)
73 {
74 struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg;
75 @@ -1225,7 +1201,7 @@ static int ath11k_ahb_probe(struct platf
76 goto err_ce_free;
77 }
78
79 - ath11k_ahb_fwreset_from_cold_boot(ab);
80 + ath11k_qmi_fwreset_from_cold_boot(ab);
81
82 return 0;
83
84 --- a/drivers/net/wireless/ath/ath11k/core.c
85 +++ b/drivers/net/wireless/ath/ath11k/core.c
86 @@ -336,8 +336,8 @@ static const struct ath11k_hw_params ath
87 .idle_ps = false,
88 .supports_sta_ps = false,
89 .coldboot_cal_mm = false,
90 - .coldboot_cal_ftm = false,
91 - .cbcal_restart_fw = false,
92 + .coldboot_cal_ftm = true,
93 + .cbcal_restart_fw = true,
94 .fw_mem_mode = 2,
95 .num_vdevs = 8,
96 .num_peers = 128,
97 --- a/drivers/net/wireless/ath/ath11k/pci.c
98 +++ b/drivers/net/wireless/ath/ath11k/pci.c
99 @@ -15,6 +15,7 @@
100 #include "mhi.h"
101 #include "debug.h"
102 #include "pcic.h"
103 +#include "qmi.h"
104
105 #define ATH11K_PCI_BAR_NUM 0
106 #define ATH11K_PCI_DMA_MASK 32
107 @@ -897,6 +898,7 @@ unsupported_wcn6855_soc:
108 ath11k_err(ab, "failed to init core: %d\n", ret);
109 goto err_irq_affinity_cleanup;
110 }
111 + ath11k_qmi_fwreset_from_cold_boot(ab);
112 return 0;
113
114 err_irq_affinity_cleanup:
115 --- a/drivers/net/wireless/ath/ath11k/qmi.c
116 +++ b/drivers/net/wireless/ath/ath11k/qmi.c
117 @@ -9,6 +9,7 @@
118 #include "qmi.h"
119 #include "core.h"
120 #include "debug.h"
121 +#include "hif.h"
122 #include <linux/of.h>
123 #include <linux/of_address.h>
124 #include <linux/ioport.h>
125 @@ -2839,6 +2840,33 @@ int ath11k_qmi_firmware_start(struct ath
126 return 0;
127 }
128
129 +int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab)
130 +{
131 + int timeout;
132 +
133 + if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done ||
134 + ab->hw_params.cbcal_restart_fw == 0)
135 + return 0;
136 +
137 + ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n");
138 +
139 + timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
140 + (ab->qmi.cal_done == 1),
141 + ATH11K_COLD_BOOT_FW_RESET_DELAY);
142 +
143 + if (timeout <= 0) {
144 + ath11k_warn(ab, "Coldboot Calibration timed out\n");
145 + return -ETIMEDOUT;
146 + }
147 +
148 + /* reset the firmware */
149 + ath11k_hif_power_down(ab);
150 + ath11k_hif_power_up(ab);
151 + ath11k_dbg(ab, ATH11K_DBG_QMI, "exit wait for cold boot done\n");
152 + return 0;
153 +}
154 +EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot);
155 +
156 static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
157 {
158 int timeout;
159 --- a/drivers/net/wireless/ath/ath11k/qmi.h
160 +++ b/drivers/net/wireless/ath/ath11k/qmi.h
161 @@ -37,7 +37,7 @@
162
163 #define QMI_WLANFW_MAX_DATA_SIZE_V01 6144
164 #define ATH11K_FIRMWARE_MODE_OFF 4
165 -#define ATH11K_COLD_BOOT_FW_RESET_DELAY (40 * HZ)
166 +#define ATH11K_COLD_BOOT_FW_RESET_DELAY (60 * HZ)
167
168 #define ATH11K_QMI_DEVICE_BAR_SIZE 0x200000
169
170 @@ -519,5 +519,6 @@ void ath11k_qmi_msg_recv_work(struct wor
171 void ath11k_qmi_deinit_service(struct ath11k_base *ab);
172 int ath11k_qmi_init_service(struct ath11k_base *ab);
173 void ath11k_qmi_free_resource(struct ath11k_base *ab);
174 +int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab);
175
176 #endif