xref: /freebsd/sys/contrib/dev/broadcom/brcm80211/brcmfmac/dmi.c (revision 9375e11f079d725d42c5b431de33044088ad14f7)
1b4c3e9b5SBjoern A. Zeeb // SPDX-License-Identifier: ISC
2b4c3e9b5SBjoern A. Zeeb /*
3b4c3e9b5SBjoern A. Zeeb  * Copyright 2018 Hans de Goede <hdegoede@redhat.com>
4b4c3e9b5SBjoern A. Zeeb  */
5b4c3e9b5SBjoern A. Zeeb 
6b4c3e9b5SBjoern A. Zeeb #include <linux/dmi.h>
7b4c3e9b5SBjoern A. Zeeb #include <linux/mod_devicetable.h>
8b4c3e9b5SBjoern A. Zeeb #include "core.h"
9b4c3e9b5SBjoern A. Zeeb #include "common.h"
10b4c3e9b5SBjoern A. Zeeb #include "brcm_hw_ids.h"
11b4c3e9b5SBjoern A. Zeeb 
12b4c3e9b5SBjoern A. Zeeb /* The DMI data never changes so we can use a static buf for this */
13b4c3e9b5SBjoern A. Zeeb static char dmi_board_type[128];
14b4c3e9b5SBjoern A. Zeeb 
15b4c3e9b5SBjoern A. Zeeb struct brcmf_dmi_data {
16b4c3e9b5SBjoern A. Zeeb 	u32 chip;
17b4c3e9b5SBjoern A. Zeeb 	u32 chiprev;
18b4c3e9b5SBjoern A. Zeeb 	const char *board_type;
19b4c3e9b5SBjoern A. Zeeb };
20b4c3e9b5SBjoern A. Zeeb 
21b4c3e9b5SBjoern A. Zeeb /* NOTE: Please keep all entries sorted alphabetically */
22b4c3e9b5SBjoern A. Zeeb 
23b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data acepc_t8_data = {
24b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_4345_CHIP_ID, 6, "acepc-t8"
25b4c3e9b5SBjoern A. Zeeb };
26b4c3e9b5SBjoern A. Zeeb 
27*9375e11fSBjoern A. Zeeb static const struct brcmf_dmi_data acer_a1_840_data = {
28*9375e11fSBjoern A. Zeeb 	BRCM_CC_43340_CHIP_ID, 2, "acer-a1-840"
29*9375e11fSBjoern A. Zeeb };
30*9375e11fSBjoern A. Zeeb 
31b4c3e9b5SBjoern A. Zeeb /* The Chuwi Hi8 Pro uses the same Ampak AP6212 module as the Chuwi Vi8 Plus
32b4c3e9b5SBjoern A. Zeeb  * and the nvram for the Vi8 Plus is already in linux-firmware, so use that.
33b4c3e9b5SBjoern A. Zeeb  */
34b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data chuwi_hi8_pro_data = {
35b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_43430_CHIP_ID, 0, "ilife-S806"
36b4c3e9b5SBjoern A. Zeeb };
37b4c3e9b5SBjoern A. Zeeb 
38b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data gpd_win_pocket_data = {
39b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_4356_CHIP_ID, 2, "gpd-win-pocket"
40b4c3e9b5SBjoern A. Zeeb };
41b4c3e9b5SBjoern A. Zeeb 
42b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data jumper_ezpad_mini3_data = {
43b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_43430_CHIP_ID, 0, "jumper-ezpad-mini3"
44b4c3e9b5SBjoern A. Zeeb };
45b4c3e9b5SBjoern A. Zeeb 
46b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data meegopad_t08_data = {
47b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_43340_CHIP_ID, 2, "meegopad-t08"
48b4c3e9b5SBjoern A. Zeeb };
49b4c3e9b5SBjoern A. Zeeb 
50b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data pov_tab_p1006w_data = {
51b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_43340_CHIP_ID, 2, "pov-tab-p1006w-data"
52b4c3e9b5SBjoern A. Zeeb };
53b4c3e9b5SBjoern A. Zeeb 
54b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data predia_basic_data = {
55b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_43341_CHIP_ID, 2, "predia-basic"
56b4c3e9b5SBjoern A. Zeeb };
57b4c3e9b5SBjoern A. Zeeb 
58b4c3e9b5SBjoern A. Zeeb /* Note the Voyo winpad A15 tablet uses the same Ampak AP6330 module, with the
59b4c3e9b5SBjoern A. Zeeb  * exact same nvram file as the Prowise-PT301 tablet. Since the nvram for the
60b4c3e9b5SBjoern A. Zeeb  * Prowise-PT301 is already in linux-firmware we just point to that here.
61b4c3e9b5SBjoern A. Zeeb  */
62b4c3e9b5SBjoern A. Zeeb static const struct brcmf_dmi_data voyo_winpad_a15_data = {
63b4c3e9b5SBjoern A. Zeeb 	BRCM_CC_4330_CHIP_ID, 4, "Prowise-PT301"
64b4c3e9b5SBjoern A. Zeeb };
65b4c3e9b5SBjoern A. Zeeb 
66b4c3e9b5SBjoern A. Zeeb static const struct dmi_system_id dmi_platform_data[] = {
67b4c3e9b5SBjoern A. Zeeb 	{
68b4c3e9b5SBjoern A. Zeeb 		/* ACEPC T8 Cherry Trail Z8350 mini PC */
69b4c3e9b5SBjoern A. Zeeb 		.matches = {
70b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."),
71b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
72b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "T8"),
73b4c3e9b5SBjoern A. Zeeb 			/* also match on somewhat unique bios-version */
74b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
75b4c3e9b5SBjoern A. Zeeb 		},
76b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&acepc_t8_data,
77b4c3e9b5SBjoern A. Zeeb 	},
78b4c3e9b5SBjoern A. Zeeb 	{
79b4c3e9b5SBjoern A. Zeeb 		/* ACEPC T11 Cherry Trail Z8350 mini PC, same wifi as the T8 */
80b4c3e9b5SBjoern A. Zeeb 		.matches = {
81b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."),
82b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
83b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "T11"),
84b4c3e9b5SBjoern A. Zeeb 			/* also match on somewhat unique bios-version */
85b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
86b4c3e9b5SBjoern A. Zeeb 		},
87b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&acepc_t8_data,
88b4c3e9b5SBjoern A. Zeeb 	},
89b4c3e9b5SBjoern A. Zeeb 	{
90b4c3e9b5SBjoern A. Zeeb 		/* ACEPC W5 Pro Cherry Trail Z8350 HDMI stick, same wifi as the T8 */
91b4c3e9b5SBjoern A. Zeeb 		.matches = {
92b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
93b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
94b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
95b4c3e9b5SBjoern A. Zeeb 		},
96b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&acepc_t8_data,
97b4c3e9b5SBjoern A. Zeeb 	},
98b4c3e9b5SBjoern A. Zeeb 	{
99*9375e11fSBjoern A. Zeeb 		/* Acer Iconia One 8 A1-840 (non FHD version) */
100*9375e11fSBjoern A. Zeeb 		.matches = {
101*9375e11fSBjoern A. Zeeb 			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
102*9375e11fSBjoern A. Zeeb 			DMI_MATCH(DMI_PRODUCT_NAME, "BayTrail"),
103*9375e11fSBjoern A. Zeeb 			/* Above strings are too generic also match BIOS date */
104*9375e11fSBjoern A. Zeeb 			DMI_MATCH(DMI_BIOS_DATE, "04/01/2014"),
105*9375e11fSBjoern A. Zeeb 		},
106*9375e11fSBjoern A. Zeeb 		.driver_data = (void *)&acer_a1_840_data,
107*9375e11fSBjoern A. Zeeb 	},
108*9375e11fSBjoern A. Zeeb 	{
109b4c3e9b5SBjoern A. Zeeb 		/* Chuwi Hi8 Pro with D2D3_Hi8Pro.233 BIOS */
110b4c3e9b5SBjoern A. Zeeb 		.matches = {
111b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
112b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
113b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "MRD"),
114b4c3e9b5SBjoern A. Zeeb 			/* Above strings are too generic, also match on BIOS date */
115b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BIOS_DATE, "05/10/2016"),
116b4c3e9b5SBjoern A. Zeeb 		},
117b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&chuwi_hi8_pro_data,
118b4c3e9b5SBjoern A. Zeeb 	},
119b4c3e9b5SBjoern A. Zeeb 	{
120b4c3e9b5SBjoern A. Zeeb 		/* Cyberbook T116 rugged tablet */
121b4c3e9b5SBjoern A. Zeeb 		.matches = {
122b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"),
123b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
124b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "20170531"),
125b4c3e9b5SBjoern A. Zeeb 		},
126b4c3e9b5SBjoern A. Zeeb 		/* The factory image nvram file is identical to the ACEPC T8 one */
127b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&acepc_t8_data,
128b4c3e9b5SBjoern A. Zeeb 	},
129b4c3e9b5SBjoern A. Zeeb 	{
130b4c3e9b5SBjoern A. Zeeb 		/* Match for the GPDwin which unfortunately uses somewhat
131b4c3e9b5SBjoern A. Zeeb 		 * generic dmi strings, which is why we test for 4 strings.
132b4c3e9b5SBjoern A. Zeeb 		 * Comparing against 23 other byt/cht boards, board_vendor
133b4c3e9b5SBjoern A. Zeeb 		 * and board_name are unique to the GPDwin, where as only one
134b4c3e9b5SBjoern A. Zeeb 		 * other board has the same board_serial and 3 others have
135b4c3e9b5SBjoern A. Zeeb 		 * the same default product_name. Also the GPDwin is the
136b4c3e9b5SBjoern A. Zeeb 		 * only device to have both board_ and product_name not set.
137b4c3e9b5SBjoern A. Zeeb 		 */
138b4c3e9b5SBjoern A. Zeeb 		.matches = {
139b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
140b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_NAME, "Default string"),
141b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_SERIAL, "Default string"),
142b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
143b4c3e9b5SBjoern A. Zeeb 		},
144b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&gpd_win_pocket_data,
145b4c3e9b5SBjoern A. Zeeb 	},
146b4c3e9b5SBjoern A. Zeeb 	{
147b4c3e9b5SBjoern A. Zeeb 		/* Jumper EZpad mini3 */
148b4c3e9b5SBjoern A. Zeeb 		.matches = {
149b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
150b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
151b4c3e9b5SBjoern A. Zeeb 			/* jumperx.T87.KFBNEEA02 with the version-nr dropped */
152b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
153b4c3e9b5SBjoern A. Zeeb 		},
154b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&jumper_ezpad_mini3_data,
155b4c3e9b5SBjoern A. Zeeb 	},
156b4c3e9b5SBjoern A. Zeeb 	{
157b4c3e9b5SBjoern A. Zeeb 		/* Meegopad T08 */
158b4c3e9b5SBjoern A. Zeeb 		.matches = {
159b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_SYS_VENDOR, "Default string"),
160b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
161b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
162b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_VERSION, "V1.1"),
163b4c3e9b5SBjoern A. Zeeb 		},
164b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&meegopad_t08_data,
165b4c3e9b5SBjoern A. Zeeb 	},
166b4c3e9b5SBjoern A. Zeeb 	{
167b4c3e9b5SBjoern A. Zeeb 		/* Point of View TAB-P1006W-232 */
168b4c3e9b5SBjoern A. Zeeb 		.matches = {
169b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
170b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BayTrail"),
171b4c3e9b5SBjoern A. Zeeb 			/* Note 105b is Foxcon's USB/PCI vendor id */
172b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "105B"),
173b4c3e9b5SBjoern A. Zeeb 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "0E57"),
174b4c3e9b5SBjoern A. Zeeb 		},
175b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&pov_tab_p1006w_data,
176b4c3e9b5SBjoern A. Zeeb 	},
177b4c3e9b5SBjoern A. Zeeb 	{
178b4c3e9b5SBjoern A. Zeeb 		/* Predia Basic tablet (+ with keyboard dock) */
179b4c3e9b5SBjoern A. Zeeb 		.matches = {
180b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
181b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
182b4c3e9b5SBjoern A. Zeeb 			/* Mx.WT107.KUBNGEA02 with the version-nr dropped */
183b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BIOS_VERSION, "Mx.WT107.KUBNGEA"),
184b4c3e9b5SBjoern A. Zeeb 		},
185b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&predia_basic_data,
186b4c3e9b5SBjoern A. Zeeb 	},
187b4c3e9b5SBjoern A. Zeeb 	{
188b4c3e9b5SBjoern A. Zeeb 		/* Voyo winpad A15 tablet */
189b4c3e9b5SBjoern A. Zeeb 		.matches = {
190b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
191b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
192b4c3e9b5SBjoern A. Zeeb 			/* Above strings are too generic, also match on BIOS date */
193b4c3e9b5SBjoern A. Zeeb 			DMI_MATCH(DMI_BIOS_DATE, "11/20/2014"),
194b4c3e9b5SBjoern A. Zeeb 		},
195b4c3e9b5SBjoern A. Zeeb 		.driver_data = (void *)&voyo_winpad_a15_data,
196b4c3e9b5SBjoern A. Zeeb 	},
197b4c3e9b5SBjoern A. Zeeb 	{}
198b4c3e9b5SBjoern A. Zeeb };
199b4c3e9b5SBjoern A. Zeeb 
brcmf_dmi_probe(struct brcmf_mp_device * settings,u32 chip,u32 chiprev)200b4c3e9b5SBjoern A. Zeeb void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev)
201b4c3e9b5SBjoern A. Zeeb {
202b4c3e9b5SBjoern A. Zeeb 	const struct dmi_system_id *match;
203b4c3e9b5SBjoern A. Zeeb 	const struct brcmf_dmi_data *data;
204b4c3e9b5SBjoern A. Zeeb 	const char *sys_vendor;
205b4c3e9b5SBjoern A. Zeeb 	const char *product_name;
206b4c3e9b5SBjoern A. Zeeb 
207b4c3e9b5SBjoern A. Zeeb 	/* Some models have DMI strings which are too generic, e.g.
208b4c3e9b5SBjoern A. Zeeb 	 * "Default string", we use a quirk table for these.
209b4c3e9b5SBjoern A. Zeeb 	 */
210b4c3e9b5SBjoern A. Zeeb 	for (match = dmi_first_match(dmi_platform_data);
211b4c3e9b5SBjoern A. Zeeb 	     match;
212b4c3e9b5SBjoern A. Zeeb 	     match = dmi_first_match(match + 1)) {
213b4c3e9b5SBjoern A. Zeeb 		data = match->driver_data;
214b4c3e9b5SBjoern A. Zeeb 
215b4c3e9b5SBjoern A. Zeeb 		if (data->chip == chip && data->chiprev == chiprev) {
216b4c3e9b5SBjoern A. Zeeb 			settings->board_type = data->board_type;
217b4c3e9b5SBjoern A. Zeeb 			return;
218b4c3e9b5SBjoern A. Zeeb 		}
219b4c3e9b5SBjoern A. Zeeb 	}
220b4c3e9b5SBjoern A. Zeeb 
221b4c3e9b5SBjoern A. Zeeb 	/* Not found in the quirk-table, use sys_vendor-product_name */
222b4c3e9b5SBjoern A. Zeeb 	sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR);
223b4c3e9b5SBjoern A. Zeeb 	product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
224b4c3e9b5SBjoern A. Zeeb 	if (sys_vendor && product_name) {
225b4c3e9b5SBjoern A. Zeeb 		snprintf(dmi_board_type, sizeof(dmi_board_type), "%s-%s",
226b4c3e9b5SBjoern A. Zeeb 			 sys_vendor, product_name);
227b4c3e9b5SBjoern A. Zeeb 		settings->board_type = dmi_board_type;
228b4c3e9b5SBjoern A. Zeeb 	}
229b4c3e9b5SBjoern A. Zeeb }
230