ath10k-ct: Update to current version
[openwrt/staging/dedeckeh.git] / package / kernel / ath10k-ct / patches / 081-ath10k-calibration-variant.patch
1 From d06f26c5c8a41f246a9c40862a77a55725cedbd3 Mon Sep 17 00:00:00 2001
2 From: Sven Eckelmann <sven.eckelmann@openmesh.com>
3 Date: Fri, 8 Dec 2017 11:37:42 +0100
4 Subject: ath10k: search DT for qcom,ath10k-calibration-variant
5
6 Board Data File (BDF) is loaded upon driver boot-up procedure. The right
7 board data file is identified on QCA4019 using bus, bmi-chip-id and
8 bmi-board-id.
9
10 The problem, however, can occur when the (default) board data file cannot
11 fulfill with the vendor requirements and it is necessary to use a different
12 board data file.
13
14 This problem was solved for SMBIOS by adding a special SMBIOS type 0xF8.
15 Something similar has to be provided for systems without SMBIOS but with
16 device trees. No solution was specified by QCA and therefore a new one has
17 to be found for ath10k.
18
19 The device tree requires addition strings to define the variant name
20
21 wifi@a000000 {
22 status = "okay";
23 qcom,ath10k-calibration-variant = "RT-AC58U";
24 };
25
26 wifi@a800000 {
27 status = "okay";
28 qcom,ath10k-calibration-variant = "RT-AC58U";
29 };
30
31 This would create the boarddata identifiers for the board-2.bin search
32
33 * bus=ahb,bmi-chip-id=0,bmi-board-id=16,variant=RT-AC58U
34 * bus=ahb,bmi-chip-id=0,bmi-board-id=17,variant=RT-AC58U
35
36 Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
37 Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
38
39 Origin: upstream, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d06f26c5c8a41f246a9c40862a77a55725cedbd3
40 ---
41 ath10k-4.13/core.c | 40 ++++++++++++++++++++++++++++------
42 1 file changed, 33 insertions(+), 7 deletions(-)
43
44 --- a/ath10k-4.13/core.c
45 +++ b/ath10k-4.13/core.c
46 @@ -893,6 +893,28 @@ static int ath10k_core_check_smbios(stru
47 return 0;
48 }
49
50 +static int ath10k_core_check_dt(struct ath10k *ar)
51 +{
52 + struct device_node *node;
53 + const char *variant = NULL;
54 +
55 + node = ar->dev->of_node;
56 + if (!node)
57 + return -ENOENT;
58 +
59 + of_property_read_string(node, "qcom,ath10k-calibration-variant",
60 + &variant);
61 + if (!variant)
62 + return -ENODATA;
63 +
64 + if (strscpy(ar->id.bdf_ext, variant, sizeof(ar->id.bdf_ext)) < 0)
65 + ath10k_dbg(ar, ATH10K_DBG_BOOT,
66 + "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
67 + variant);
68 +
69 + return 0;
70 +}
71 +
72 static int ath10k_download_and_run_otp(struct ath10k *ar)
73 {
74 u32 result, address = ar->hw_params.patch_load_addr;
75 @@ -1532,19 +1554,19 @@ static int ath10k_core_create_board_name
76 /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
77 char variant[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH] = { 0 };
78
79 + if (ar->id.bdf_ext[0] != '\0')
80 + scnprintf(variant, sizeof(variant), ",variant=%s",
81 + ar->id.bdf_ext);
82 +
83 if (ar->id.bmi_ids_valid) {
84 scnprintf(name, name_len,
85 - "bus=%s,bmi-chip-id=%d,bmi-board-id=%d",
86 + "bus=%s,bmi-chip-id=%d,bmi-board-id=%d%s",
87 ath10k_bus_str(ar->hif.bus),
88 ar->id.bmi_chip_id,
89 - ar->id.bmi_board_id);
90 + ar->id.bmi_board_id, variant);
91 goto out;
92 }
93
94 - if (ar->id.bdf_ext[0] != '\0')
95 - scnprintf(variant, sizeof(variant), ",variant=%s",
96 - ar->id.bdf_ext);
97 -
98 scnprintf(name, name_len,
99 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
100 ath10k_bus_str(ar->hif.bus),
101 @@ -3014,7 +3036,11 @@ static int ath10k_core_probe_fw(struct a
102
103 ret = ath10k_core_check_smbios(ar);
104 if (ret)
105 - ath10k_dbg(ar, ATH10K_DBG_BOOT, "bdf variant name not set.\n");
106 + ath10k_dbg(ar, ATH10K_DBG_BOOT, "SMBIOS bdf variant name not set.\n");
107 +
108 + ret = ath10k_core_check_dt(ar);
109 + if (ret)
110 + ath10k_dbg(ar, ATH10K_DBG_BOOT, "DT bdf variant name not set.\n");
111
112 ret = ath10k_core_fetch_board_file(ar);
113 if (ret) {