kernel: bump 4.14 to 4.14.72
[openwrt/staging/chunkeey.git] / package / kernel / mac80211 / 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 drivers/net/wireless/ath/ath10k/core.c | 40 ++++++++++++++++++++++++++++------
40 1 file changed, 33 insertions(+), 7 deletions(-)
41
42 --- a/drivers/net/wireless/ath/ath10k/core.c
43 +++ b/drivers/net/wireless/ath/ath10k/core.c
44 @@ -860,6 +860,28 @@ static int ath10k_core_check_smbios(stru
45 return 0;
46 }
47
48 +static int ath10k_core_check_dt(struct ath10k *ar)
49 +{
50 + struct device_node *node;
51 + const char *variant = NULL;
52 +
53 + node = ar->dev->of_node;
54 + if (!node)
55 + return -ENOENT;
56 +
57 + of_property_read_string(node, "qcom,ath10k-calibration-variant",
58 + &variant);
59 + if (!variant)
60 + return -ENODATA;
61 +
62 + if (strscpy(ar->id.bdf_ext, variant, sizeof(ar->id.bdf_ext)) < 0)
63 + ath10k_dbg(ar, ATH10K_DBG_BOOT,
64 + "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
65 + variant);
66 +
67 + return 0;
68 +}
69 +
70 static int ath10k_download_and_run_otp(struct ath10k *ar)
71 {
72 u32 result, address = ar->hw_params.patch_load_addr;
73 @@ -1231,19 +1253,19 @@ static int ath10k_core_create_board_name
74 /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
75 char variant[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH] = { 0 };
76
77 + if (ar->id.bdf_ext[0] != '\0')
78 + scnprintf(variant, sizeof(variant), ",variant=%s",
79 + ar->id.bdf_ext);
80 +
81 if (ar->id.bmi_ids_valid) {
82 scnprintf(name, name_len,
83 - "bus=%s,bmi-chip-id=%d,bmi-board-id=%d",
84 + "bus=%s,bmi-chip-id=%d,bmi-board-id=%d%s",
85 ath10k_bus_str(ar->hif.bus),
86 ar->id.bmi_chip_id,
87 - ar->id.bmi_board_id);
88 + ar->id.bmi_board_id, variant);
89 goto out;
90 }
91
92 - if (ar->id.bdf_ext[0] != '\0')
93 - scnprintf(variant, sizeof(variant), ",variant=%s",
94 - ar->id.bdf_ext);
95 -
96 scnprintf(name, name_len,
97 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
98 ath10k_bus_str(ar->hif.bus),
99 @@ -2343,7 +2365,11 @@ static int ath10k_core_probe_fw(struct a
100
101 ret = ath10k_core_check_smbios(ar);
102 if (ret)
103 - ath10k_dbg(ar, ATH10K_DBG_BOOT, "bdf variant name not set.\n");
104 + ath10k_dbg(ar, ATH10K_DBG_BOOT, "SMBIOS bdf variant name not set.\n");
105 +
106 + ret = ath10k_core_check_dt(ar);
107 + if (ret)
108 + ath10k_dbg(ar, ATH10K_DBG_BOOT, "DT bdf variant name not set.\n");
109
110 ret = ath10k_core_fetch_board_file(ar);
111 if (ret) {