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