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
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.
15 This support can be enabled/disabled using hw params for different
16 hardware. Currently it is not enabled for QCA6390.
18 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
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
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(-)
33 --- a/drivers/net/wireless/ath/ath11k/ahb.c
34 +++ b/drivers/net/wireless/ath/ath11k/ahb.c
40 #include <linux/remoteproc.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);
47 -static int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
51 - if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done ||
52 - ab->hw_params.cbcal_restart_fw == 0)
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);
60 - ath11k_cold_boot_cal = 0;
61 - ath11k_warn(ab, "Coldboot Calibration failed timed out\n");
64 - /* reset the firmware */
65 - ath11k_ahb_power_down(ab);
66 - ath11k_ahb_power_up(ab);
68 - ath11k_dbg(ab, ATH11K_DBG_AHB, "exited from cold boot mode\n");
72 static void ath11k_ahb_init_qmi_ce_config(struct ath11k_base *ab)
74 struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg;
75 @@ -1225,7 +1201,7 @@ static int ath11k_ahb_probe(struct platf
79 - ath11k_ahb_fwreset_from_cold_boot(ab);
80 + ath11k_qmi_fwreset_from_cold_boot(ab);
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
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,
97 --- a/drivers/net/wireless/ath/ath11k/pci.c
98 +++ b/drivers/net/wireless/ath/ath11k/pci.c
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;
111 + ath11k_qmi_fwreset_from_cold_boot(ab);
114 err_irq_affinity_cleanup:
115 --- a/drivers/net/wireless/ath/ath11k/qmi.c
116 +++ b/drivers/net/wireless/ath/ath11k/qmi.c
122 #include <linux/of.h>
123 #include <linux/of_address.h>
124 #include <linux/ioport.h>
125 @@ -2842,6 +2843,33 @@ int ath11k_qmi_firmware_start(struct ath
129 +int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab)
133 + if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done ||
134 + ab->hw_params.cbcal_restart_fw == 0)
137 + ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n");
139 + timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
140 + (ab->qmi.cal_done == 1),
141 + ATH11K_COLD_BOOT_FW_RESET_DELAY);
143 + if (timeout <= 0) {
144 + ath11k_warn(ab, "Coldboot Calibration timed out\n");
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");
154 +EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot);
156 static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
159 --- a/drivers/net/wireless/ath/ath11k/qmi.h
160 +++ b/drivers/net/wireless/ath/ath11k/qmi.h
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)
168 #define ATH11K_QMI_DEVICE_BAR_SIZE 0x200000
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);