Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.2.
  1/*
  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;
 25	const struct property_entry *properties;
 26};
 27
 28static const struct property_entry cube_iwork8_air_props[] = {
 29	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
 42static const struct property_entry jumper_ezpad_mini3_props[] = {
 43	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
 56static 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),
 61	PROPERTY_ENTRY_BOOL("silead,home-button"),
 62	{ }
 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
 70static 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
 85static 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),
 91	PROPERTY_ENTRY_BOOL("silead,home-button"),
 92	{ }
 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
100static const struct property_entry gp_electronic_t701_props[] = {
101	PROPERTY_ENTRY_U32("touchscreen-size-x", 960),
102	PROPERTY_ENTRY_U32("touchscreen-size-y", 640),
103	PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
104	PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
105	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
115static 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
130static 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"),
136	PROPERTY_ENTRY_BOOL("silead,home-button"),
137	{ }
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
145static 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
159static 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"),
164	PROPERTY_ENTRY_BOOL("silead,home-button"),
165	{ }
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
173static 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
189static 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
206static 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
220static 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
235static const struct property_entry trekstor_primebook_c13_props[] = {
236	PROPERTY_ENTRY_U32("touchscreen-size-x", 2624),
237	PROPERTY_ENTRY_U32("touchscreen-size-y", 1920),
238	PROPERTY_ENTRY_STRING("firmware-name",
239			      "gsl1680-trekstor-primebook-c13.fw"),
240	PROPERTY_ENTRY_U32("silead,max-fingers", 10),
241	PROPERTY_ENTRY_BOOL("silead,home-button"),
242	{ }
243};
244
245static const struct silead_ts_dmi_data trekstor_primebook_c13_data = {
246	.acpi_name	= "MSSL1680:00",
247	.properties	= trekstor_primebook_c13_props,
248};
249
250static const struct property_entry teclast_x98plus2_props[] = {
251	PROPERTY_ENTRY_U32("touchscreen-size-x", 2048),
252	PROPERTY_ENTRY_U32("touchscreen-size-y", 1280),
253	PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
254	PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
255	PROPERTY_ENTRY_STRING("firmware-name",
256			      "gsl1686-teclast_x98plus2.fw"),
257	PROPERTY_ENTRY_U32("silead,max-fingers", 10),
258	{ }
259};
260
261static const struct silead_ts_dmi_data teclast_x98plus2_data = {
262	.acpi_name	= "MSSL1680:00",
263	.properties	= teclast_x98plus2_props,
264};
265
266static const struct property_entry teclast_x3_plus_props[] = {
267	PROPERTY_ENTRY_U32("touchscreen-size-x", 1980),
268	PROPERTY_ENTRY_U32("touchscreen-size-y", 1500),
269	PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-teclast-x3-plus.fw"),
270	PROPERTY_ENTRY_U32("silead,max-fingers", 10),
271	PROPERTY_ENTRY_BOOL("silead,home-button"),
272	{ }
273};
274
275static const struct silead_ts_dmi_data teclast_x3_plus_data = {
276	.acpi_name	= "MSSL1680:00",
277	.properties	= teclast_x3_plus_props,
278};
279
280static const struct dmi_system_id silead_ts_dmi_table[] = {
281	{
282		/* CUBE iwork8 Air */
283		.driver_data = (void *)&cube_iwork8_air_data,
284		.matches = {
285			DMI_MATCH(DMI_SYS_VENDOR, "cube"),
286			DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
287			DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
288		},
289	},
290	{
291		/* Jumper EZpad mini3 */
292		.driver_data = (void *)&jumper_ezpad_mini3_data,
293		.matches = {
294			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
295			/* jumperx.T87.KFBNEEA02 with the version-nr dropped */
296			DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
297		},
298	},
299	{
300		/* DEXP Ursus 7W */
301		.driver_data = (void *)&dexp_ursus_7w_data,
302		.matches = {
303			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
304			DMI_MATCH(DMI_PRODUCT_NAME, "7W"),
305		},
306	},
307	{
308		/* TrekStor SurfTab twin 10.1 ST10432-8 */
309		.driver_data = (void *)&surftab_twin_10_1_st10432_8_data,
310		.matches = {
311			DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"),
312			DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab twin 10.1"),
313		},
314	},
315	{
316		/* Trekstor Surftab Wintron 7.0 ST70416-6 */
317		.driver_data = (void *)&surftab_wintron70_st70416_6_data,
318		.matches = {
319			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
320			DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"),
321			/* Exact match, different versions need different fw */
322			DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"),
323		},
324	},
325	{
326		/* Trekstor Surftab Wintron 7.0 ST70416-6, newer BIOS */
327		.driver_data = (void *)&surftab_wintron70_st70416_6_data,
328		.matches = {
329			DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"),
330			DMI_MATCH(DMI_PRODUCT_NAME,
331					     "SurfTab wintron 7.0 ST70416-6"),
332			/* Exact match, different versions need different fw */
333			DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA05"),
334		},
335	},
336	{
337		/* Ployer Momo7w (same hardware as the Trekstor ST70416-6) */
338		.driver_data = (void *)&surftab_wintron70_st70416_6_data,
339		.matches = {
340			DMI_MATCH(DMI_SYS_VENDOR, "Shenzhen PLOYER"),
341			DMI_MATCH(DMI_PRODUCT_NAME, "MOMO7W"),
342			/* Exact match, different versions need different fw */
343			DMI_MATCH(DMI_BIOS_VERSION, "MOMO.G.WI71C.MABMRBA02"),
344		},
345	},
346	{
347		/* GP-electronic T701 */
348		.driver_data = (void *)&gp_electronic_t701_data,
349		.matches = {
350			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
351			DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
352			DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
353		},
354	},
355	{
356		/* Pipo W2S */
357		.driver_data = (void *)&pipo_w2s_data,
358		.matches = {
359			DMI_MATCH(DMI_SYS_VENDOR, "PIPO"),
360			DMI_MATCH(DMI_PRODUCT_NAME, "W2S"),
361		},
362	},
363	{
364		/* Point of View mobii wintab p800w */
365		.driver_data = (void *)&pov_mobii_wintab_p800w_data,
366		.matches = {
367			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
368			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
369			DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
370			/* Above matches are too generic, add bios-date match */
371			DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
372		},
373	},
374	{
375		/* I.T.Works TW891 */
376		.driver_data = (void *)&itworks_tw891_data,
377		.matches = {
378			DMI_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
379			DMI_MATCH(DMI_PRODUCT_NAME, "TW891"),
380		},
381	},
382	{
383		/* Chuwi Hi8 Pro */
384		.driver_data = (void *)&chuwi_hi8_pro_data,
385		.matches = {
386			DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"),
387			DMI_MATCH(DMI_PRODUCT_NAME, "X1D3_C806N"),
388		},
389	},
390	{
391		/* Digma Citi E200 */
392		.driver_data = (void *)&digma_citi_e200_data,
393		.matches = {
394			DMI_MATCH(DMI_SYS_VENDOR, "Digma"),
395			DMI_MATCH(DMI_PRODUCT_NAME, "CITI E200"),
396			DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
397		},
398	},
399	{
400		/* Onda oBook 20 Plus */
401		.driver_data = (void *)&onda_obook_20_plus_data,
402		.matches = {
403			DMI_MATCH(DMI_SYS_VENDOR, "ONDA"),
404			DMI_MATCH(DMI_PRODUCT_NAME, "OBOOK 20 PLUS"),
405		},
406	},
407	{
408		/* Chuwi Hi8 */
409		.driver_data = (void *)&chuwi_hi8_data,
410		.matches = {
411			DMI_MATCH(DMI_SYS_VENDOR, "ilife"),
412			DMI_MATCH(DMI_PRODUCT_NAME, "S806"),
413		},
414	},
415	{
416		/* Chuwi Vi8 (CWI506) */
417		.driver_data = (void *)&chuwi_vi8_data,
418		.matches = {
419			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
420			DMI_MATCH(DMI_PRODUCT_NAME, "i86"),
421			DMI_MATCH(DMI_BIOS_VERSION, "CHUWI.D86JLBNR"),
422		},
423	},
424	{
425		/* Trekstor Primebook C13 */
426		.driver_data = (void *)&trekstor_primebook_c13_data,
427		.matches = {
428			DMI_MATCH(DMI_SYS_VENDOR, "TREKSTOR"),
429			DMI_MATCH(DMI_PRODUCT_NAME, "Primebook C13"),
430		},
431	},
432	{
433		/* Teclast X98 Plus II */
434		.driver_data = (void *)&teclast_x98plus2_data,
435		.matches = {
436			DMI_MATCH(DMI_SYS_VENDOR, "TECLAST"),
437			DMI_MATCH(DMI_PRODUCT_NAME, "X98 Plus II"),
438		},
439	},
440	{
441		/* Teclast X3 Plus */
442		.driver_data = (void *)&teclast_x3_plus_data,
443		.matches = {
444			DMI_MATCH(DMI_SYS_VENDOR, "TECLAST"),
445			DMI_MATCH(DMI_PRODUCT_NAME, "X3 Plus"),
446			DMI_MATCH(DMI_BOARD_NAME, "X3 Plus"),
447		},
448	},
449	{
450		/* I.T.Works TW701 */
451		.driver_data = (void *)&surftab_wintron70_st70416_6_data,
452		.matches = {
453			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
454			DMI_MATCH(DMI_PRODUCT_NAME, "i71c"),
455			DMI_MATCH(DMI_BIOS_VERSION, "itWORKS.G.WI71C.JGBMRB"),
456		},
457	},
458	{
459		/* Yours Y8W81, same case and touchscreen as Chuwi Vi8 */
460		.driver_data = (void *)&chuwi_vi8_data,
461		.matches = {
462			DMI_MATCH(DMI_SYS_VENDOR, "YOURS"),
463			DMI_MATCH(DMI_PRODUCT_NAME, "Y8W81"),
464		},
465	},
466	{ },
467};
468
469static const struct silead_ts_dmi_data *silead_ts_data;
470
471static void silead_ts_dmi_add_props(struct i2c_client *client)
472{
473	struct device *dev = &client->dev;
474	int error;
475
476	if (has_acpi_companion(dev) &&
477	    !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
478		error = device_add_properties(dev, silead_ts_data->properties);
479		if (error)
480			dev_err(dev, "failed to add properties: %d\n", error);
481	}
482}
483
484static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
485				       unsigned long action, void *data)
486{
487	struct device *dev = data;
488	struct i2c_client *client;
489
490	switch (action) {
491	case BUS_NOTIFY_ADD_DEVICE:
492		client = i2c_verify_client(dev);
493		if (client)
494			silead_ts_dmi_add_props(client);
495		break;
496
497	default:
498		break;
499	}
500
501	return 0;
502}
503
504static struct notifier_block silead_ts_dmi_notifier = {
505	.notifier_call = silead_ts_dmi_notifier_call,
506};
507
508static int __init silead_ts_dmi_init(void)
509{
510	const struct dmi_system_id *dmi_id;
511	int error;
512
513	dmi_id = dmi_first_match(silead_ts_dmi_table);
514	if (!dmi_id)
515		return 0; /* Not an error */
516
517	silead_ts_data = dmi_id->driver_data;
518
519	error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
520	if (error)
521		pr_err("%s: failed to register i2c bus notifier: %d\n",
522			__func__, error);
523
524	return error;
525}
526
527/*
528 * We are registering out notifier after i2c core is initialized and i2c bus
529 * itself is ready (which happens at postcore initcall level), but before
530 * ACPI starts enumerating devices (at subsys initcall level).
531 */
532arch_initcall(silead_ts_dmi_init);