Skip to content

Commit bd1e82b

Browse files
jwrdegoedeKalle Valo
authored andcommitted
brcmfmac: Set board_type from DMI on x86 based machines
For x86 based machines, set the board_type used for nvram file selection based on the DMI sys-vendor and product-name strings. Since on some models these strings are too generic, this commit also adds a quirk table overriding the strings for models listed in that table. The board_type setting is used to load the board-specific nvram file with a board-specific name so that we can ship files for each supported board in linux-firmware. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent 0ad4b55 commit bd1e82b

File tree

4 files changed

+127
-1
lines changed

4 files changed

+127
-1
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ brcmfmac-$(CONFIG_BRCM_TRACING) += \
5454
tracepoint.o
5555
brcmfmac-$(CONFIG_OF) += \
5656
of.o
57+
brcmfmac-$(CONFIG_DMI) += \
58+
dmi.o

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
448448
}
449449
}
450450
if (!found) {
451-
/* No platform data for this device, try OF (Open Firwmare) */
451+
/* No platform data for this device, try OF and DMI data */
452452
brcmf_of_probe(dev, bus_type, settings);
453+
brcmf_dmi_probe(settings, chip, chiprev);
453454
}
454455
return settings;
455456
}

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,11 @@ void brcmf_release_module_param(struct brcmf_mp_device *module_param);
7575
/* Sets dongle media info (drv_version, mac address). */
7676
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
7777

78+
#ifdef CONFIG_DMI
79+
void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev);
80+
#else
81+
static inline void
82+
brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev) {}
83+
#endif
84+
7885
#endif /* BRCMFMAC_COMMON_H */
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright 2018 Hans de Goede <hdegoede@redhat.com>
3+
*
4+
* Permission to use, copy, modify, and/or distribute this software for any
5+
* purpose with or without fee is hereby granted, provided that the above
6+
* copyright notice and this permission notice appear in all copies.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
*/
16+
17+
#include <linux/dmi.h>
18+
#include <linux/mod_devicetable.h>
19+
#include "core.h"
20+
#include "common.h"
21+
#include "brcm_hw_ids.h"
22+
23+
/* The DMI data never changes so we can use a static buf for this */
24+
static char dmi_board_type[128];
25+
26+
struct brcmf_dmi_data {
27+
u32 chip;
28+
u32 chiprev;
29+
const char *board_type;
30+
};
31+
32+
/* NOTE: Please keep all entries sorted alphabetically */
33+
34+
static const struct brcmf_dmi_data gpd_win_pocket_data = {
35+
BRCM_CC_4356_CHIP_ID, 2, "gpd-win-pocket"
36+
};
37+
38+
static const struct brcmf_dmi_data jumper_ezpad_mini3_data = {
39+
BRCM_CC_43430_CHIP_ID, 0, "jumper-ezpad-mini3"
40+
};
41+
42+
static const struct brcmf_dmi_data meegopad_t08_data = {
43+
BRCM_CC_43340_CHIP_ID, 2, "meegopad-t08"
44+
};
45+
46+
static const struct dmi_system_id dmi_platform_data[] = {
47+
{
48+
/* Match for the GPDwin which unfortunately uses somewhat
49+
* generic dmi strings, which is why we test for 4 strings.
50+
* Comparing against 23 other byt/cht boards, board_vendor
51+
* and board_name are unique to the GPDwin, where as only one
52+
* other board has the same board_serial and 3 others have
53+
* the same default product_name. Also the GPDwin is the
54+
* only device to have both board_ and product_name not set.
55+
*/
56+
.matches = {
57+
DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
58+
DMI_MATCH(DMI_BOARD_NAME, "Default string"),
59+
DMI_MATCH(DMI_BOARD_SERIAL, "Default string"),
60+
DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
61+
},
62+
.driver_data = (void *)&gpd_win_pocket_data,
63+
},
64+
{
65+
/* Jumper EZpad mini3 */
66+
.matches = {
67+
DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
68+
DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
69+
/* jumperx.T87.KFBNEEA02 with the version-nr dropped */
70+
DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
71+
},
72+
.driver_data = (void *)&jumper_ezpad_mini3_data,
73+
},
74+
{
75+
/* Meegopad T08 */
76+
.matches = {
77+
DMI_MATCH(DMI_SYS_VENDOR, "Default string"),
78+
DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
79+
DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
80+
DMI_MATCH(DMI_BOARD_VERSION, "V1.1"),
81+
},
82+
.driver_data = (void *)&meegopad_t08_data,
83+
},
84+
{}
85+
};
86+
87+
void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev)
88+
{
89+
const struct dmi_system_id *match;
90+
const struct brcmf_dmi_data *data;
91+
const char *sys_vendor;
92+
const char *product_name;
93+
94+
/* Some models have DMI strings which are too generic, e.g.
95+
* "Default string", we use a quirk table for these.
96+
*/
97+
for (match = dmi_first_match(dmi_platform_data);
98+
match;
99+
match = dmi_first_match(match + 1)) {
100+
data = match->driver_data;
101+
102+
if (data->chip == chip && data->chiprev == chiprev) {
103+
settings->board_type = data->board_type;
104+
return;
105+
}
106+
}
107+
108+
/* Not found in the quirk-table, use sys_vendor-product_name */
109+
sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR);
110+
product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
111+
if (sys_vendor && product_name) {
112+
snprintf(dmi_board_type, sizeof(dmi_board_type), "%s-%s",
113+
sys_vendor, product_name);
114+
settings->board_type = dmi_board_type;
115+
}
116+
}

0 commit comments

Comments
 (0)