blob: 09b589fb79d4d74269f2da183b32aee9a393a7d7 [file] [log] [blame]
Hans de Goedecef9dd82017-01-23 18:35:30 +01001/*
2 * Silead touchscreen driver DMI based configuration code
3 *
4 * Copyright (c) 2017 Red Hat Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Red Hat authors:
12 * Hans de Goede <hdegoede@redhat.com>
13 */
14
15#include <linux/acpi.h>
16#include <linux/device.h>
17#include <linux/dmi.h>
18#include <linux/i2c.h>
19#include <linux/notifier.h>
20#include <linux/property.h>
21#include <linux/string.h>
22
23struct silead_ts_dmi_data {
24 const char *acpi_name;
Hans de Goedeae311152017-03-22 16:55:53 +010025 const struct property_entry *properties;
Hans de Goedecef9dd82017-01-23 18:35:30 +010026};
27
Hans de Goedeae311152017-03-22 16:55:53 +010028static const struct property_entry cube_iwork8_air_props[] = {
Hans de Goedecef9dd82017-01-23 18:35:30 +010029 PROPERTY_ENTRY_U32("touchscreen-size-x", 1660),
30 PROPERTY_ENTRY_U32("touchscreen-size-y", 900),
31 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
32 PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-cube-iwork8-air.fw"),
33 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
34 { }
35};
36
37static const struct silead_ts_dmi_data cube_iwork8_air_data = {
38 .acpi_name = "MSSL1680:00",
39 .properties = cube_iwork8_air_props,
40};
41
Hans de Goedeae311152017-03-22 16:55:53 +010042static const struct property_entry jumper_ezpad_mini3_props[] = {
Hans de Goedecef9dd82017-01-23 18:35:30 +010043 PROPERTY_ENTRY_U32("touchscreen-size-x", 1700),
44 PROPERTY_ENTRY_U32("touchscreen-size-y", 1150),
45 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
46 PROPERTY_ENTRY_STRING("firmware-name", "gsl3676-jumper-ezpad-mini3.fw"),
47 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
48 { }
49};
50
51static const struct silead_ts_dmi_data jumper_ezpad_mini3_data = {
52 .acpi_name = "MSSL1680:00",
53 .properties = jumper_ezpad_mini3_props,
54};
55
Hans de Goede6b8e7d82017-03-22 16:55:54 +010056static const struct property_entry dexp_ursus_7w_props[] = {
57 PROPERTY_ENTRY_U32("touchscreen-size-x", 890),
58 PROPERTY_ENTRY_U32("touchscreen-size-y", 630),
59 PROPERTY_ENTRY_STRING("firmware-name", "gsl1686-dexp-ursus-7w.fw"),
60 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
Hans de Goedeaaa40962017-10-19 09:17:28 +020061 PROPERTY_ENTRY_BOOL("silead,home-button"),
Hans de Goede6b8e7d82017-03-22 16:55:54 +010062 { }
63};
64
65static const struct silead_ts_dmi_data dexp_ursus_7w_data = {
66 .acpi_name = "MSSL1680:00",
67 .properties = dexp_ursus_7w_props,
68};
69
Bernhard Übelackerf4c12d42017-11-26 19:32:58 +010070static const struct property_entry surftab_twin_10_1_st10432_8_props[] = {
71 PROPERTY_ENTRY_U32("touchscreen-size-x", 1900),
72 PROPERTY_ENTRY_U32("touchscreen-size-y", 1280),
73 PROPERTY_ENTRY_U32("touchscreen-inverted-y", 1),
74 PROPERTY_ENTRY_STRING("firmware-name",
75 "gsl3670-surftab-twin-10-1-st10432-8.fw"),
76 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
77 { }
78};
79
80static const struct silead_ts_dmi_data surftab_twin_10_1_st10432_8_data = {
81 .acpi_name = "MSSL1680:00",
82 .properties = surftab_twin_10_1_st10432_8_props,
83};
84
Hans de Goede5b7bb3a2017-04-09 11:07:44 +020085static const struct property_entry surftab_wintron70_st70416_6_props[] = {
86 PROPERTY_ENTRY_U32("touchscreen-size-x", 884),
87 PROPERTY_ENTRY_U32("touchscreen-size-y", 632),
88 PROPERTY_ENTRY_STRING("firmware-name",
89 "gsl1686-surftab-wintron70-st70416-6.fw"),
90 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
Hans de Goedeaaa40962017-10-19 09:17:28 +020091 PROPERTY_ENTRY_BOOL("silead,home-button"),
Hans de Goede5b7bb3a2017-04-09 11:07:44 +020092 { }
93};
94
95static const struct silead_ts_dmi_data surftab_wintron70_st70416_6_data = {
96 .acpi_name = "MSSL1680:00",
97 .properties = surftab_wintron70_st70416_6_props,
98};
99
Hans de Goeded9ca30b2017-05-07 14:35:15 +0200100static const struct property_entry gp_electronic_t701_props[] = {
101 PROPERTY_ENTRY_U32("touchscreen-size-x", 960),
102 PROPERTY_ENTRY_U32("touchscreen-size-y", 640),
Hans de Goede5c24c052017-10-19 09:44:14 +0200103 PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
104 PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
Hans de Goeded9ca30b2017-05-07 14:35:15 +0200105 PROPERTY_ENTRY_STRING("firmware-name",
106 "gsl1680-gp-electronic-t701.fw"),
107 { }
108};
109
110static const struct silead_ts_dmi_data gp_electronic_t701_data = {
111 .acpi_name = "MSSL1680:00",
112 .properties = gp_electronic_t701_props,
113};
114
Hans de Goede13fadfa2017-06-15 08:48:32 +0200115static const struct property_entry pipo_w2s_props[] = {
116 PROPERTY_ENTRY_U32("touchscreen-size-x", 1660),
117 PROPERTY_ENTRY_U32("touchscreen-size-y", 880),
118 PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
119 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
120 PROPERTY_ENTRY_STRING("firmware-name",
121 "gsl1680-pipo-w2s.fw"),
122 { }
123};
124
125static const struct silead_ts_dmi_data pipo_w2s_data = {
126 .acpi_name = "MSSL1680:00",
127 .properties = pipo_w2s_props,
128};
129
Hans de Goedef4d342c2017-06-15 08:48:31 +0200130static const struct property_entry pov_mobii_wintab_p800w_props[] = {
131 PROPERTY_ENTRY_U32("touchscreen-size-x", 1800),
132 PROPERTY_ENTRY_U32("touchscreen-size-y", 1150),
133 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
134 PROPERTY_ENTRY_STRING("firmware-name",
135 "gsl3692-pov-mobii-wintab-p800w.fw"),
Hans de Goedeaaa40962017-10-19 09:17:28 +0200136 PROPERTY_ENTRY_BOOL("silead,home-button"),
Hans de Goedef4d342c2017-06-15 08:48:31 +0200137 { }
138};
139
140static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_data = {
141 .acpi_name = "MSSL1680:00",
142 .properties = pov_mobii_wintab_p800w_props,
143};
144
Hans de Goede4edfc542017-07-01 12:15:22 +0200145static const struct property_entry itworks_tw891_props[] = {
146 PROPERTY_ENTRY_U32("touchscreen-size-x", 1600),
147 PROPERTY_ENTRY_U32("touchscreen-size-y", 890),
148 PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
149 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
150 PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-itworks-tw891.fw"),
151 { }
152};
153
154static const struct silead_ts_dmi_data itworks_tw891_data = {
155 .acpi_name = "MSSL1680:00",
156 .properties = itworks_tw891_props,
157};
158
Hans de Goede485f2a52017-10-04 15:30:12 +0200159static const struct property_entry chuwi_hi8_pro_props[] = {
160 PROPERTY_ENTRY_U32("touchscreen-size-x", 1728),
161 PROPERTY_ENTRY_U32("touchscreen-size-y", 1148),
162 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
163 PROPERTY_ENTRY_STRING("firmware-name", "gsl3680-chuwi-hi8-pro.fw"),
Hans de Goedeaaa40962017-10-19 09:17:28 +0200164 PROPERTY_ENTRY_BOOL("silead,home-button"),
Hans de Goede485f2a52017-10-04 15:30:12 +0200165 { }
166};
167
168static const struct silead_ts_dmi_data chuwi_hi8_pro_data = {
169 .acpi_name = "MSSL1680:00",
170 .properties = chuwi_hi8_pro_props,
171};
172
Sergey Tshovrebov3fcf2b22017-10-27 12:27:07 +0200173static const struct property_entry digma_citi_e200_props[] = {
174 PROPERTY_ENTRY_U32("touchscreen-size-x", 1980),
175 PROPERTY_ENTRY_U32("touchscreen-size-y", 1500),
176 PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
177 PROPERTY_ENTRY_STRING("firmware-name",
178 "gsl1686-digma_citi_e200.fw"),
179 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
180 PROPERTY_ENTRY_BOOL("silead,home-button"),
181 { }
182};
183
184static const struct silead_ts_dmi_data digma_citi_e200_data = {
185 .acpi_name = "MSSL1680:00",
186 .properties = digma_citi_e200_props,
187};
188
Nerijus Baliunas170e9a52017-12-11 00:02:13 +0200189static const struct property_entry onda_obook_20_plus_props[] = {
190 PROPERTY_ENTRY_U32("touchscreen-size-x", 1728),
191 PROPERTY_ENTRY_U32("touchscreen-size-y", 1148),
192 PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
193 PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
194 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
195 PROPERTY_ENTRY_STRING("firmware-name", "gsl3676-onda-obook-20-plus.fw"),
196 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
197 PROPERTY_ENTRY_BOOL("silead,home-button"),
198 { }
199};
200
201static const struct silead_ts_dmi_data onda_obook_20_plus_data = {
202 .acpi_name = "MSSL1680:00",
203 .properties = onda_obook_20_plus_props,
204};
205
Maruyama Shoheid2d541e2017-12-20 11:30:08 +0100206static const struct property_entry chuwi_hi8_props[] = {
207 PROPERTY_ENTRY_U32("touchscreen-size-x", 1665),
208 PROPERTY_ENTRY_U32("touchscreen-size-y", 1140),
209 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
210 PROPERTY_ENTRY_BOOL("silead,home-button"),
211 PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-chuwi-hi8.fw"),
212 { }
213};
214
215static const struct silead_ts_dmi_data chuwi_hi8_data = {
216 .acpi_name = "MSSL0001:00",
217 .properties = chuwi_hi8_props,
218};
219
Hans de Goedef1905b92017-12-20 11:30:09 +0100220static const struct property_entry chuwi_vi8_props[] = {
221 PROPERTY_ENTRY_U32("touchscreen-size-x", 1724),
222 PROPERTY_ENTRY_U32("touchscreen-size-y", 1140),
223 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
224 PROPERTY_ENTRY_STRING("firmware-name", "gsl3676-chuwi-vi8.fw"),
225 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
226 PROPERTY_ENTRY_BOOL("silead,home-button"),
227 { }
228};
229
230static const struct silead_ts_dmi_data chuwi_vi8_data = {
231 .acpi_name = "MSSL1680:00",
232 .properties = chuwi_vi8_props,
233};
234
Hans de Goedecef9dd82017-01-23 18:35:30 +0100235static const struct dmi_system_id silead_ts_dmi_table[] = {
236 {
237 /* CUBE iwork8 Air */
238 .driver_data = (void *)&cube_iwork8_air_data,
239 .matches = {
240 DMI_MATCH(DMI_SYS_VENDOR, "cube"),
241 DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
242 DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
243 },
244 },
245 {
246 /* Jumper EZpad mini3 */
247 .driver_data = (void *)&jumper_ezpad_mini3_data,
248 .matches = {
249 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
250 /* jumperx.T87.KFBNEEA02 with the version-nr dropped */
251 DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
252 },
253 },
Hans de Goede6b8e7d82017-03-22 16:55:54 +0100254 {
255 /* DEXP Ursus 7W */
256 .driver_data = (void *)&dexp_ursus_7w_data,
257 .matches = {
258 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
259 DMI_MATCH(DMI_PRODUCT_NAME, "7W"),
260 },
261 },
Hans de Goede5b7bb3a2017-04-09 11:07:44 +0200262 {
Bernhard Übelackerf4c12d42017-11-26 19:32:58 +0100263 /* TrekStor SurfTab twin 10.1 ST10432-8 */
264 .driver_data = (void *)&surftab_twin_10_1_st10432_8_data,
265 .matches = {
266 DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"),
267 DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab twin 10.1"),
268 },
269 },
270 {
Hans de Goede5b7bb3a2017-04-09 11:07:44 +0200271 /* Trekstor Surftab Wintron 7.0 ST70416-6 */
272 .driver_data = (void *)&surftab_wintron70_st70416_6_data,
273 .matches = {
274 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
275 DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"),
276 /* Exact match, different versions need different fw */
277 DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"),
278 },
279 },
Hans de Goeded9ca30b2017-05-07 14:35:15 +0200280 {
Hans de Goedec3a73ed2017-07-12 13:15:11 +0200281 /* Ployer Momo7w (same hardware as the Trekstor ST70416-6) */
282 .driver_data = (void *)&surftab_wintron70_st70416_6_data,
283 .matches = {
284 DMI_MATCH(DMI_SYS_VENDOR, "Shenzhen PLOYER"),
285 DMI_MATCH(DMI_PRODUCT_NAME, "MOMO7W"),
286 /* Exact match, different versions need different fw */
287 DMI_MATCH(DMI_BIOS_VERSION, "MOMO.G.WI71C.MABMRBA02"),
288 },
289 },
290 {
Hans de Goeded9ca30b2017-05-07 14:35:15 +0200291 /* GP-electronic T701 */
292 .driver_data = (void *)&gp_electronic_t701_data,
293 .matches = {
294 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
295 DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
296 DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
297 },
298 },
Hans de Goede13fadfa2017-06-15 08:48:32 +0200299 {
300 /* Pipo W2S */
301 .driver_data = (void *)&pipo_w2s_data,
302 .matches = {
303 DMI_MATCH(DMI_SYS_VENDOR, "PIPO"),
304 DMI_MATCH(DMI_PRODUCT_NAME, "W2S"),
305 },
306 },
Hans de Goedef4d342c2017-06-15 08:48:31 +0200307 {
308 /* Point of View mobii wintab p800w */
309 .driver_data = (void *)&pov_mobii_wintab_p800w_data,
310 .matches = {
311 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
312 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
313 DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
314 /* Above matches are too generic, add bios-date match */
315 DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
316 },
317 },
Hans de Goede4edfc542017-07-01 12:15:22 +0200318 {
319 /* I.T.Works TW891 */
320 .driver_data = (void *)&itworks_tw891_data,
321 .matches = {
322 DMI_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
323 DMI_MATCH(DMI_PRODUCT_NAME, "TW891"),
324 },
325 },
Hans de Goede485f2a52017-10-04 15:30:12 +0200326 {
327 /* Chuwi Hi8 Pro */
328 .driver_data = (void *)&chuwi_hi8_pro_data,
329 .matches = {
330 DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"),
331 DMI_MATCH(DMI_PRODUCT_NAME, "X1D3_C806N"),
332 },
333 },
Sergey Tshovrebov3fcf2b22017-10-27 12:27:07 +0200334 {
335 /* Digma Citi E200 */
336 .driver_data = (void *)&digma_citi_e200_data,
337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "Digma"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "CITI E200"),
340 DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
341 },
342 },
Nerijus Baliunas170e9a52017-12-11 00:02:13 +0200343 {
344 /* Onda oBook 20 Plus */
345 .driver_data = (void *)&onda_obook_20_plus_data,
346 .matches = {
347 DMI_MATCH(DMI_SYS_VENDOR, "ONDA"),
348 DMI_MATCH(DMI_PRODUCT_NAME, "OBOOK 20 PLUS"),
349 },
350 },
Maruyama Shoheid2d541e2017-12-20 11:30:08 +0100351 {
352 /* Chuwi Hi8 */
353 .driver_data = (void *)&chuwi_hi8_data,
354 .matches = {
355 DMI_MATCH(DMI_SYS_VENDOR, "ilife"),
356 DMI_MATCH(DMI_PRODUCT_NAME, "S806"),
357 },
358 },
Hans de Goedef1905b92017-12-20 11:30:09 +0100359 {
360 /* Chuwi Vi8 (CWI506) */
361 .driver_data = (void *)&chuwi_vi8_data,
362 .matches = {
363 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
364 DMI_MATCH(DMI_PRODUCT_NAME, "i86"),
365 DMI_MATCH(DMI_BIOS_VERSION, "CHUWI.D86JLBNR"),
366 },
367 },
Hans de Goedecef9dd82017-01-23 18:35:30 +0100368 { },
369};
370
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700371static const struct silead_ts_dmi_data *silead_ts_data;
372
Dmitry Torokhove1053962017-04-03 20:25:13 -0700373static void silead_ts_dmi_add_props(struct i2c_client *client)
Hans de Goedecef9dd82017-01-23 18:35:30 +0100374{
Dmitry Torokhove1053962017-04-03 20:25:13 -0700375 struct device *dev = &client->dev;
Hans de Goedecef9dd82017-01-23 18:35:30 +0100376 int error;
377
Hans de Goedecef9dd82017-01-23 18:35:30 +0100378 if (has_acpi_companion(dev) &&
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700379 !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
380 error = device_add_properties(dev, silead_ts_data->properties);
Hans de Goedecef9dd82017-01-23 18:35:30 +0100381 if (error)
382 dev_err(dev, "failed to add properties: %d\n", error);
383 }
384}
385
386static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
387 unsigned long action, void *data)
388{
389 struct device *dev = data;
Dmitry Torokhove1053962017-04-03 20:25:13 -0700390 struct i2c_client *client;
Hans de Goedecef9dd82017-01-23 18:35:30 +0100391
392 switch (action) {
393 case BUS_NOTIFY_ADD_DEVICE:
Dmitry Torokhove1053962017-04-03 20:25:13 -0700394 client = i2c_verify_client(dev);
395 if (client)
396 silead_ts_dmi_add_props(client);
Hans de Goedecef9dd82017-01-23 18:35:30 +0100397 break;
398
399 default:
400 break;
401 }
402
403 return 0;
404}
405
406static struct notifier_block silead_ts_dmi_notifier = {
407 .notifier_call = silead_ts_dmi_notifier_call,
408};
409
410static int __init silead_ts_dmi_init(void)
411{
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700412 const struct dmi_system_id *dmi_id;
Hans de Goedecef9dd82017-01-23 18:35:30 +0100413 int error;
414
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700415 dmi_id = dmi_first_match(silead_ts_dmi_table);
416 if (!dmi_id)
417 return 0; /* Not an error */
418
419 silead_ts_data = dmi_id->driver_data;
420
Hans de Goedecef9dd82017-01-23 18:35:30 +0100421 error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
422 if (error)
423 pr_err("%s: failed to register i2c bus notifier: %d\n",
424 __func__, error);
425
426 return error;
427}
428
429/*
430 * We are registering out notifier after i2c core is initialized and i2c bus
431 * itself is ready (which happens at postcore initcall level), but before
432 * ACPI starts enumerating devices (at subsys initcall level).
433 */
434arch_initcall(silead_ts_dmi_init);