mac80211: ath11k: sync with ath-next
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / ath11k / 0003-wifi-ath11k-Split-coldboot-calibration-hw_param.patch
1 From 011e5a3052a22d3758d17442bf0c04c68bf79bea Mon Sep 17 00:00:00 2001
2 From: Seevalamuthu Mariappan <quic_seevalam@quicinc.com>
3 Date: Wed, 26 Jul 2023 19:40:30 +0530
4 Subject: [PATCH 3/5] wifi: ath11k: Split coldboot calibration hw_param
5
6 QCN9074 enables coldboot calibration only in Factory Test Mode (FTM).
7 Hence, split cold_boot_calib to two hw_params for mission and FTM
8 mode.
9
10 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
11
12 Signed-off-by: Seevalamuthu Mariappan <quic_seevalam@quicinc.com>
13 Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
14 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
15 Link: https://lore.kernel.org/r/20230726141032.3061-2-quic_rajkbhag@quicinc.com
16 ---
17 drivers/net/wireless/ath/ath11k/ahb.c | 3 +--
18 drivers/net/wireless/ath/ath11k/core.c | 36 ++++++++++++++++++++------
19 drivers/net/wireless/ath/ath11k/core.h | 1 +
20 drivers/net/wireless/ath/ath11k/hw.h | 3 ++-
21 drivers/net/wireless/ath/ath11k/qmi.c | 6 ++---
22 5 files changed, 35 insertions(+), 14 deletions(-)
23
24 --- a/drivers/net/wireless/ath/ath11k/ahb.c
25 +++ b/drivers/net/wireless/ath/ath11k/ahb.c
26 @@ -422,8 +422,7 @@ static int ath11k_ahb_fwreset_from_cold_
27 {
28 int timeout;
29
30 - if (ath11k_cold_boot_cal == 0 || ab->qmi.cal_done ||
31 - ab->hw_params.cold_boot_calib == 0 ||
32 + if (!ath11k_core_coldboot_cal_support(ab) || ab->qmi.cal_done ||
33 ab->hw_params.cbcal_restart_fw == 0)
34 return 0;
35
36 --- a/drivers/net/wireless/ath/ath11k/core.c
37 +++ b/drivers/net/wireless/ath/ath11k/core.c
38 @@ -86,7 +86,8 @@ static const struct ath11k_hw_params ath
39 .supports_shadow_regs = false,
40 .idle_ps = false,
41 .supports_sta_ps = false,
42 - .cold_boot_calib = true,
43 + .coldboot_cal_mm = true,
44 + .coldboot_cal_ftm = true,
45 .cbcal_restart_fw = true,
46 .fw_mem_mode = 0,
47 .num_vdevs = 16 + 1,
48 @@ -167,7 +168,8 @@ static const struct ath11k_hw_params ath
49 .supports_shadow_regs = false,
50 .idle_ps = false,
51 .supports_sta_ps = false,
52 - .cold_boot_calib = true,
53 + .coldboot_cal_mm = true,
54 + .coldboot_cal_ftm = true,
55 .cbcal_restart_fw = true,
56 .fw_mem_mode = 0,
57 .num_vdevs = 16 + 1,
58 @@ -248,7 +250,8 @@ static const struct ath11k_hw_params ath
59 .supports_shadow_regs = true,
60 .idle_ps = true,
61 .supports_sta_ps = true,
62 - .cold_boot_calib = false,
63 + .coldboot_cal_mm = false,
64 + .coldboot_cal_ftm = false,
65 .cbcal_restart_fw = false,
66 .fw_mem_mode = 0,
67 .num_vdevs = 16 + 1,
68 @@ -332,7 +335,8 @@ static const struct ath11k_hw_params ath
69 .supports_shadow_regs = false,
70 .idle_ps = false,
71 .supports_sta_ps = false,
72 - .cold_boot_calib = false,
73 + .coldboot_cal_mm = false,
74 + .coldboot_cal_ftm = false,
75 .cbcal_restart_fw = false,
76 .fw_mem_mode = 2,
77 .num_vdevs = 8,
78 @@ -413,7 +417,8 @@ static const struct ath11k_hw_params ath
79 .supports_shadow_regs = true,
80 .idle_ps = true,
81 .supports_sta_ps = true,
82 - .cold_boot_calib = false,
83 + .coldboot_cal_mm = false,
84 + .coldboot_cal_ftm = false,
85 .cbcal_restart_fw = false,
86 .fw_mem_mode = 0,
87 .num_vdevs = 16 + 1,
88 @@ -495,7 +500,8 @@ static const struct ath11k_hw_params ath
89 .supports_shadow_regs = true,
90 .idle_ps = true,
91 .supports_sta_ps = true,
92 - .cold_boot_calib = false,
93 + .coldboot_cal_mm = false,
94 + .coldboot_cal_ftm = false,
95 .cbcal_restart_fw = false,
96 .fw_mem_mode = 0,
97 .num_vdevs = 16 + 1,
98 @@ -578,7 +584,8 @@ static const struct ath11k_hw_params ath
99 .supports_shadow_regs = true,
100 .idle_ps = true,
101 .supports_sta_ps = true,
102 - .cold_boot_calib = true,
103 + .coldboot_cal_mm = true,
104 + .coldboot_cal_ftm = true,
105 .cbcal_restart_fw = false,
106 .fw_mem_mode = 0,
107 .num_vdevs = 16 + 1,
108 @@ -667,7 +674,8 @@ static const struct ath11k_hw_params ath
109 .supports_suspend = false,
110 .hal_params = &ath11k_hw_hal_params_ipq8074,
111 .single_pdev_only = false,
112 - .cold_boot_calib = true,
113 + .coldboot_cal_mm = true,
114 + .coldboot_cal_ftm = true,
115 .cbcal_restart_fw = true,
116 .fix_l1ss = true,
117 .supports_dynamic_smps_6ghz = false,
118 @@ -749,6 +757,18 @@ void ath11k_fw_stats_free(struct ath11k_
119 ath11k_fw_stats_bcn_free(&stats->bcn);
120 }
121
122 +bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab)
123 +{
124 + if (!ath11k_cold_boot_cal)
125 + return false;
126 +
127 + if (ath11k_ftm_mode)
128 + return ab->hw_params.coldboot_cal_ftm;
129 +
130 + else
131 + return ab->hw_params.coldboot_cal_mm;
132 +}
133 +
134 int ath11k_core_suspend(struct ath11k_base *ab)
135 {
136 int ret;
137 --- a/drivers/net/wireless/ath/ath11k/core.h
138 +++ b/drivers/net/wireless/ath/ath11k/core.h
139 @@ -1186,6 +1186,7 @@ void ath11k_core_halt(struct ath11k *ar)
140 int ath11k_core_resume(struct ath11k_base *ab);
141 int ath11k_core_suspend(struct ath11k_base *ab);
142 void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab);
143 +bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab);
144
145 const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
146 const char *filename);
147 --- a/drivers/net/wireless/ath/ath11k/hw.h
148 +++ b/drivers/net/wireless/ath/ath11k/hw.h
149 @@ -187,7 +187,8 @@ struct ath11k_hw_params {
150 bool supports_shadow_regs;
151 bool idle_ps;
152 bool supports_sta_ps;
153 - bool cold_boot_calib;
154 + bool coldboot_cal_mm;
155 + bool coldboot_cal_ftm;
156 bool cbcal_restart_fw;
157 int fw_mem_mode;
158 u32 num_vdevs;
159 --- a/drivers/net/wireless/ath/ath11k/qmi.c
160 +++ b/drivers/net/wireless/ath/ath11k/qmi.c
161 @@ -2079,7 +2079,7 @@ static int ath11k_qmi_assign_target_mem_
162 return -EINVAL;
163 }
164
165 - if (ath11k_cold_boot_cal && ab->hw_params.cold_boot_calib) {
166 + if (ath11k_core_coldboot_cal_support(ab)) {
167 if (hremote_node) {
168 ab->qmi.target_mem[idx].paddr =
169 res.start + host_ddr_sz;
170 @@ -3209,8 +3209,8 @@ static void ath11k_qmi_driver_event_work
171 break;
172 }
173
174 - if (ath11k_cold_boot_cal && ab->qmi.cal_done == 0 &&
175 - ab->hw_params.cold_boot_calib) {
176 + if (ab->qmi.cal_done == 0 &&
177 + ath11k_core_coldboot_cal_support(ab)) {
178 ath11k_qmi_process_coldboot_calibration(ab);
179 } else {
180 clear_bit(ATH11K_FLAG_CRASH_FLUSH,