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