-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path8005-brcmfmac-firmware-Support-passing-in-multiple-board_.patch
135 lines (120 loc) · 5.25 KB
/
8005-brcmfmac-firmware-Support-passing-in-multiple-board_.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
From 880d3f98041005210a332974c3b19e0116e14053 Mon Sep 17 00:00:00 2001
From: Hector Martin <[email protected]>
Date: Tue, 21 Dec 2021 17:38:37 +0900
Subject: [PATCH 05/34] brcmfmac: firmware: Support passing in multiple
board_types
In order to make use of the multiple alt_path functionality, change
board_type to an array. Bus drivers can pass in a NULL-terminated list
of board type strings to try for the firmware fetch.
Signed-off-by: Hector Martin <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/firmware.c | 35 +++++++++++++------
.../broadcom/brcm80211/brcmfmac/firmware.h | 2 +-
.../broadcom/brcm80211/brcmfmac/pcie.c | 7 +++-
.../broadcom/brcm80211/brcmfmac/sdio.c | 4 ++-
4 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 16f342bc5..02e36fa3d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -594,26 +594,41 @@ static int brcmf_fw_complete_request(const struct firmware *fw,
return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
}
-static const char **brcm_alt_fw_paths(const char *path, const char *board_type)
+static const char **brcm_alt_fw_paths(const char *path, struct brcmf_fw *fwctx)
{
+ const char **board_types = fwctx->req->board_types;
+ int board_type_count = 0;
+ int i;
char alt_path[BRCMF_FW_NAME_LEN];
char **alt_paths;
const char *suffix;
+ if (!board_types || !board_types[0])
+ return NULL;
+
+ while (*board_types++)
+ board_type_count++;
+
suffix = strrchr(path, '.');
if (!suffix || suffix == path)
return NULL;
- /* strip extension at the end */
- strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
- alt_path[suffix - path] = 0;
+ alt_paths = kzalloc(sizeof(char *) * (board_type_count + 1),
+ GFP_KERNEL);
+
+ board_types = fwctx->req->board_types;
+ for (i = 0; i < board_type_count; i++) {
+ /* strip extension at the end */
+ strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
+ alt_path[suffix - path] = 0;
- strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
- strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN);
- strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);
+ strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
+ strlcat(alt_path, board_types[i], BRCMF_FW_NAME_LEN);
+ strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);
- alt_paths = kzalloc(sizeof(char *) * 2, GFP_KERNEL);
- alt_paths[0] = kstrdup(alt_path, GFP_KERNEL);
+ alt_paths[i] = kstrdup(alt_path, GFP_KERNEL);
+ brcmf_dbg(TRACE, "FW alt path: %s\n", alt_paths[i]);
+ }
return (const char **)alt_paths;
}
@@ -638,7 +653,7 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
int ret, i;
/* Files can be board-specific, first try a board-specific path */
- if (fwctx->req->board_type) {
+ if (fwctx->req->board_types) {
const char **alt_paths = brcm_alt_fw_paths(cur->path, fwctx);
if (!alt_paths)
goto fallback;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
index e290dec9c..d94a1d5be 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
@@ -66,7 +66,7 @@ struct brcmf_fw_request {
u16 domain_nr;
u16 bus_nr;
u32 n_items;
- const char *board_type;
+ const char **board_types;
struct brcmf_fw_item items[];
};
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index ab0503c6f..0e4ba33fb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1877,11 +1877,16 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL;
fwreq->items[BRCMF_PCIE_FW_CLM].type = BRCMF_FW_TYPE_BINARY;
fwreq->items[BRCMF_PCIE_FW_CLM].flags = BRCMF_FW_REQF_OPTIONAL;
- fwreq->board_type = devinfo->settings->board_type;
/* NVRAM reserves PCI domain 0 for Broadcom's SDK faked bus */
fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
fwreq->bus_nr = devinfo->pdev->bus->number;
+ brcmf_dbg(PCIE, "Board: %s\n", devinfo->settings->board_type);
+ fwreq->board_types = devm_kzalloc(&devinfo->pdev->dev,
+ sizeof(const char *) * 2,
+ GFP_KERNEL);
+ fwreq->board_types[0] = devinfo->settings->board_type;
+
return fwreq;
}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 7466e6fd6..32f457bf0 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4432,7 +4432,9 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)
fwreq->items[BRCMF_SDIO_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
fwreq->items[BRCMF_SDIO_FW_CLM].type = BRCMF_FW_TYPE_BINARY;
fwreq->items[BRCMF_SDIO_FW_CLM].flags = BRCMF_FW_REQF_OPTIONAL;
- fwreq->board_type = bus->sdiodev->settings->board_type;
+ fwreq->board_types = devm_kzalloc(bus->sdiodev->dev,
+ sizeof(const char *) * 2, GFP_KERNEL);
+ fwreq->board_types[0] = bus->sdiodev->settings->board_type;
return fwreq;
}
--
2.25.1