mac80211: ath11k: sync with ath-next
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / ath11k / 903-ath11k-support-setting-FW-memory-mode-via-DT.patch
1 From fb1c40c225cbc413d82c872dd8c8af3469b2b921 Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Fri, 16 Dec 2022 17:17:52 +0100
4 Subject: [PATCH] ath11k: support setting FW memory mode via DT
5
6 ath11k is really memory intensive for devices with less that 1GB of RAM,
7 so lets allow saving a significant amount of memory by setting the FW to
8 Mode-1 via DTS for devices that need it.
9
10 However the drawback is reduced number of VDEV-s and peers which is a
11 reasonable tradeoff.
12
13 Mode-2 allows for further reduction, but it has further restrictions.
14
15 While we are here, lets add a print to be able to easily determine what
16 FW memory mode is being used.
17
18 Signed-off-by: Robert Marko <robimarko@gmail.com>
19 ---
20 drivers/net/wireless/ath/ath11k/core.c | 28 ++++++++++++++++++++++++--
21 1 file changed, 26 insertions(+), 2 deletions(-)
22
23 --- a/drivers/net/wireless/ath/ath11k/core.c
24 +++ b/drivers/net/wireless/ath/ath11k/core.c
25 @@ -36,7 +36,7 @@ bool ath11k_ftm_mode;
26 module_param_named(ftm_mode, ath11k_ftm_mode, bool, 0444);
27 MODULE_PARM_DESC(ftm_mode, "Boots up in factory test mode");
28
29 -static const struct ath11k_hw_params ath11k_hw_params[] = {
30 +static struct ath11k_hw_params ath11k_hw_params[] = {
31 {
32 .hw_rev = ATH11K_HW_IPQ8074,
33 .name = "ipq8074 hw2.0",
34 @@ -2040,7 +2040,8 @@ static void ath11k_core_reset(struct wor
35 static int ath11k_init_hw_params(struct ath11k_base *ab)
36 {
37 const struct ath11k_hw_params *hw_params = NULL;
38 - int i;
39 + u32 fw_mem_mode;
40 + int i, ret;
41
42 for (i = 0; i < ARRAY_SIZE(ath11k_hw_params); i++) {
43 hw_params = &ath11k_hw_params[i];
44 @@ -2056,7 +2057,31 @@ static int ath11k_init_hw_params(struct
45
46 ab->hw_params = *hw_params;
47
48 + ret = of_property_read_u32(ab->dev->of_node,
49 + "qcom,ath11k-fw-memory-mode",
50 + &fw_mem_mode);
51 + if (!ret) {
52 + if (fw_mem_mode == 0) {
53 + ab->hw_params.fw_mem_mode = 0;
54 + ab->hw_params.num_vdevs = 16 + 1;
55 + ab->hw_params.num_peers = 512;
56 + }
57 + else if (fw_mem_mode == 1) {
58 + ab->hw_params.fw_mem_mode = 1;
59 + ab->hw_params.num_vdevs = 8;
60 + ab->hw_params.num_peers = 128;
61 + } else if (fw_mem_mode == 2) {
62 + ab->hw_params.fw_mem_mode = 2;
63 + ab->hw_params.num_vdevs = 8;
64 + ab->hw_params.num_peers = 128;
65 + ab->hw_params.coldboot_cal_mm = false;
66 + ab->hw_params.coldboot_cal_ftm = false;
67 + } else
68 + ath11k_info(ab, "Unsupported FW memory mode: %u\n", fw_mem_mode);
69 + }
70 +
71 ath11k_info(ab, "%s\n", ab->hw_params.name);
72 + ath11k_info(ab, "FW memory mode: %d\n", ab->hw_params.fw_mem_mode);
73
74 return 0;
75 }