b5c53baf67e85d1e834e6a7b01258effbefcdbcb
[openwrt/openwrt.git] / package / kernel / ath10k-ct / patches / 203-ath10k-Try-to-get-mac-address-from-dts.patch
1 From 22fb5991a44c78ff18ec0082dc90c809356eb893 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Sun, 27 Sep 2020 19:23:35 +0200
4 Subject: [PATCH 1/2] ath10k: Try to get mac-address from dts
5
6 Most of embedded device that have the ath10k wifi integrated store the
7 mac-address in nvmem partitions. Try to fetch the mac-address using the
8 standard 'of_get_mac_address' than in all the check also try to fetch the
9 address using the nvmem api searching for a defined 'mac-address' cell.
10 Mac-address defined in the dts have priority than any other address found.
11
12 Tested-on: QCA9984 hw1.0 PCI 10.4
13
14 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
15 ---
16 ath10k-5.10/core.c | 10 ++++++++++
17 1 file changed, 10 insertions(+)
18
19 diff --git a/ath10k-5.10/core.c b/ath10k-5.10/core.c
20 index 5f4e12196..9ed7b9883 100644
21 --- a/ath10k-5.10/core.c
22 +++ b/ath10k-5.10/core.c
23 @@ -8,6 +8,9 @@
24 #include <linux/module.h>
25 #include <linux/firmware.h>
26 #include <linux/of.h>
27 +#include <linux/of_net.h>
28 +#include <linux/of_platform.h>
29 +#include <linux/property.h>
30 #include <linux/property.h>
31 #include <linux/dmi.h>
32 #include <linux/ctype.h>
33 @@ -2961,8 +2963,14 @@ EXPORT_SYMBOL(ath10k_core_stop);
34 static int ath10k_core_probe_fw(struct ath10k *ar)
35 {
36 struct bmi_target_info target_info;
37 + const char *mac;
38 int ret = 0;
39
40 +#ifdef CONFIG_OF
41 + /* register the platform to be found by the of api */
42 + of_platform_device_create(ar->dev->of_node, NULL, NULL);
43 +#endif
44 +
45 ret = ath10k_hif_power_up(ar, ATH10K_FIRMWARE_MODE_NORMAL);
46 if (ret) {
47 ath10k_err(ar, "could not power on hif bus (%d)\n", ret);
48 @@ -3062,6 +3068,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
49
50 device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr));
51
52 + mac = of_get_mac_address(ar->dev->of_node);
53 + if (!IS_ERR(mac))
54 + ether_addr_copy(ar->mac_addr, mac);
55 +
56 ret = ath10k_core_init_firmware_features(ar);
57 if (ret) {
58 ath10k_err(ar, "fatal problem with firmware features: %d\n",
59 --
60 2.27.0
61