a33ceaa21ed268e2a12d62553ae5ab9e64a6d315
[openwrt/staging/dangole.git] /
1 From 0ad4b55b2f29784f93875e6231bf57cd233624a2 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Wed, 10 Oct 2018 13:01:01 +0200
4 Subject: [PATCH] brcmfmac: Set board_type used for nvram file selection to
5 machine-compatible
6
7 For of/devicetree using machines, set the board_type used for nvram file
8 selection to the first string listed in the top-level's node compatible
9 string, aka the machine-compatible as used by of_machine_is_compatible().
10
11 The board_type setting is used to load the board-specific nvram file with
12 a board-specific name so that we can ship files for each supported board
13 in linux-firmware.
14
15 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
17 ---
18 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h | 1 +
19 drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 11 ++++++++++-
20 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 1 +
21 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 1 +
22 4 files changed, 13 insertions(+), 1 deletion(-)
23
24 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
25 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
26 @@ -59,6 +59,7 @@ struct brcmf_mp_device {
27 bool iapp;
28 bool ignore_probe_fail;
29 struct brcmfmac_pd_cc *country_codes;
30 + const char *board_type;
31 union {
32 struct brcmfmac_sdio_pd sdio;
33 } bus;
34 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
35 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
36 @@ -27,11 +27,20 @@ void brcmf_of_probe(struct device *dev,
37 struct brcmf_mp_device *settings)
38 {
39 struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio;
40 - struct device_node *np = dev->of_node;
41 + struct device_node *root, *np = dev->of_node;
42 + struct property *prop;
43 int irq;
44 u32 irqf;
45 u32 val;
46
47 + /* Set board-type to the first string of the machine compatible prop */
48 + root = of_find_node_by_path("/");
49 + if (root) {
50 + prop = of_find_property(root, "compatible", NULL);
51 + settings->board_type = of_prop_next_string(prop, NULL);
52 + of_node_put(root);
53 + }
54 +
55 if (!np || bus_type != BRCMF_BUSTYPE_SDIO ||
56 !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
57 return;
58 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
59 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
60 @@ -1785,6 +1785,7 @@ brcmf_pcie_prepare_fw_request(struct brc
61 fwreq->items[BRCMF_PCIE_FW_CODE].type = BRCMF_FW_TYPE_BINARY;
62 fwreq->items[BRCMF_PCIE_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
63 fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL;
64 + fwreq->board_type = devinfo->settings->board_type;
65 /* NVRAM reserves PCI domain 0 for Broadcom's SDK faked bus */
66 fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
67 fwreq->bus_nr = devinfo->pdev->bus->number;
68 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
69 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
70 @@ -4174,6 +4174,7 @@ brcmf_sdio_prepare_fw_request(struct brc
71
72 fwreq->items[BRCMF_SDIO_FW_CODE].type = BRCMF_FW_TYPE_BINARY;
73 fwreq->items[BRCMF_SDIO_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
74 + fwreq->board_type = bus->sdiodev->settings->board_type;
75
76 return fwreq;
77 }