blob: 1157a7b646d66c17682e985eb22d81e6bea7ab45 [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),
61 { }
62};
63
64static const struct silead_ts_dmi_data dexp_ursus_7w_data = {
65 .acpi_name = "MSSL1680:00",
66 .properties = dexp_ursus_7w_props,
67};
68
Hans de Goede5b7bb3a2017-04-09 11:07:44 +020069static const struct property_entry surftab_wintron70_st70416_6_props[] = {
70 PROPERTY_ENTRY_U32("touchscreen-size-x", 884),
71 PROPERTY_ENTRY_U32("touchscreen-size-y", 632),
72 PROPERTY_ENTRY_STRING("firmware-name",
73 "gsl1686-surftab-wintron70-st70416-6.fw"),
74 PROPERTY_ENTRY_U32("silead,max-fingers", 10),
75 { }
76};
77
78static const struct silead_ts_dmi_data surftab_wintron70_st70416_6_data = {
79 .acpi_name = "MSSL1680:00",
80 .properties = surftab_wintron70_st70416_6_props,
81};
82
Hans de Goeded9ca30b2017-05-07 14:35:15 +020083static const struct property_entry gp_electronic_t701_props[] = {
84 PROPERTY_ENTRY_U32("touchscreen-size-x", 960),
85 PROPERTY_ENTRY_U32("touchscreen-size-y", 640),
86 PROPERTY_ENTRY_STRING("firmware-name",
87 "gsl1680-gp-electronic-t701.fw"),
88 { }
89};
90
91static const struct silead_ts_dmi_data gp_electronic_t701_data = {
92 .acpi_name = "MSSL1680:00",
93 .properties = gp_electronic_t701_props,
94};
95
Hans de Goede13fadfa2017-06-15 08:48:32 +020096static const struct property_entry pipo_w2s_props[] = {
97 PROPERTY_ENTRY_U32("touchscreen-size-x", 1660),
98 PROPERTY_ENTRY_U32("touchscreen-size-y", 880),
99 PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
100 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
101 PROPERTY_ENTRY_STRING("firmware-name",
102 "gsl1680-pipo-w2s.fw"),
103 { }
104};
105
106static const struct silead_ts_dmi_data pipo_w2s_data = {
107 .acpi_name = "MSSL1680:00",
108 .properties = pipo_w2s_props,
109};
110
Hans de Goedef4d342c2017-06-15 08:48:31 +0200111static const struct property_entry pov_mobii_wintab_p800w_props[] = {
112 PROPERTY_ENTRY_U32("touchscreen-size-x", 1800),
113 PROPERTY_ENTRY_U32("touchscreen-size-y", 1150),
114 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
115 PROPERTY_ENTRY_STRING("firmware-name",
116 "gsl3692-pov-mobii-wintab-p800w.fw"),
117 { }
118};
119
120static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_data = {
121 .acpi_name = "MSSL1680:00",
122 .properties = pov_mobii_wintab_p800w_props,
123};
124
Hans de Goede4edfc542017-07-01 12:15:22 +0200125static const struct property_entry itworks_tw891_props[] = {
126 PROPERTY_ENTRY_U32("touchscreen-size-x", 1600),
127 PROPERTY_ENTRY_U32("touchscreen-size-y", 890),
128 PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
129 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
130 PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-itworks-tw891.fw"),
131 { }
132};
133
134static const struct silead_ts_dmi_data itworks_tw891_data = {
135 .acpi_name = "MSSL1680:00",
136 .properties = itworks_tw891_props,
137};
138
Hans de Goedecef9dd82017-01-23 18:35:30 +0100139static const struct dmi_system_id silead_ts_dmi_table[] = {
140 {
141 /* CUBE iwork8 Air */
142 .driver_data = (void *)&cube_iwork8_air_data,
143 .matches = {
144 DMI_MATCH(DMI_SYS_VENDOR, "cube"),
145 DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
146 DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
147 },
148 },
149 {
150 /* Jumper EZpad mini3 */
151 .driver_data = (void *)&jumper_ezpad_mini3_data,
152 .matches = {
153 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
154 /* jumperx.T87.KFBNEEA02 with the version-nr dropped */
155 DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
156 },
157 },
Hans de Goede6b8e7d82017-03-22 16:55:54 +0100158 {
159 /* DEXP Ursus 7W */
160 .driver_data = (void *)&dexp_ursus_7w_data,
161 .matches = {
162 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
163 DMI_MATCH(DMI_PRODUCT_NAME, "7W"),
164 },
165 },
Hans de Goede5b7bb3a2017-04-09 11:07:44 +0200166 {
167 /* Trekstor Surftab Wintron 7.0 ST70416-6 */
168 .driver_data = (void *)&surftab_wintron70_st70416_6_data,
169 .matches = {
170 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
171 DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"),
172 /* Exact match, different versions need different fw */
173 DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"),
174 },
175 },
Hans de Goeded9ca30b2017-05-07 14:35:15 +0200176 {
Hans de Goedec3a73ed2017-07-12 13:15:11 +0200177 /* Ployer Momo7w (same hardware as the Trekstor ST70416-6) */
178 .driver_data = (void *)&surftab_wintron70_st70416_6_data,
179 .matches = {
180 DMI_MATCH(DMI_SYS_VENDOR, "Shenzhen PLOYER"),
181 DMI_MATCH(DMI_PRODUCT_NAME, "MOMO7W"),
182 /* Exact match, different versions need different fw */
183 DMI_MATCH(DMI_BIOS_VERSION, "MOMO.G.WI71C.MABMRBA02"),
184 },
185 },
186 {
Hans de Goeded9ca30b2017-05-07 14:35:15 +0200187 /* GP-electronic T701 */
188 .driver_data = (void *)&gp_electronic_t701_data,
189 .matches = {
190 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
191 DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
192 DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
193 },
194 },
Hans de Goede13fadfa2017-06-15 08:48:32 +0200195 {
196 /* Pipo W2S */
197 .driver_data = (void *)&pipo_w2s_data,
198 .matches = {
199 DMI_MATCH(DMI_SYS_VENDOR, "PIPO"),
200 DMI_MATCH(DMI_PRODUCT_NAME, "W2S"),
201 },
202 },
Hans de Goedef4d342c2017-06-15 08:48:31 +0200203 {
204 /* Point of View mobii wintab p800w */
205 .driver_data = (void *)&pov_mobii_wintab_p800w_data,
206 .matches = {
207 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
208 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
209 DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
210 /* Above matches are too generic, add bios-date match */
211 DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
212 },
213 },
Hans de Goede4edfc542017-07-01 12:15:22 +0200214 {
215 /* I.T.Works TW891 */
216 .driver_data = (void *)&itworks_tw891_data,
217 .matches = {
218 DMI_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
219 DMI_MATCH(DMI_PRODUCT_NAME, "TW891"),
220 },
221 },
Hans de Goedecef9dd82017-01-23 18:35:30 +0100222 { },
223};
224
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700225static const struct silead_ts_dmi_data *silead_ts_data;
226
Dmitry Torokhove1053962017-04-03 20:25:13 -0700227static void silead_ts_dmi_add_props(struct i2c_client *client)
Hans de Goedecef9dd82017-01-23 18:35:30 +0100228{
Dmitry Torokhove1053962017-04-03 20:25:13 -0700229 struct device *dev = &client->dev;
Hans de Goedecef9dd82017-01-23 18:35:30 +0100230 int error;
231
Hans de Goedecef9dd82017-01-23 18:35:30 +0100232 if (has_acpi_companion(dev) &&
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700233 !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
234 error = device_add_properties(dev, silead_ts_data->properties);
Hans de Goedecef9dd82017-01-23 18:35:30 +0100235 if (error)
236 dev_err(dev, "failed to add properties: %d\n", error);
237 }
238}
239
240static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
241 unsigned long action, void *data)
242{
243 struct device *dev = data;
Dmitry Torokhove1053962017-04-03 20:25:13 -0700244 struct i2c_client *client;
Hans de Goedecef9dd82017-01-23 18:35:30 +0100245
246 switch (action) {
247 case BUS_NOTIFY_ADD_DEVICE:
Dmitry Torokhove1053962017-04-03 20:25:13 -0700248 client = i2c_verify_client(dev);
249 if (client)
250 silead_ts_dmi_add_props(client);
Hans de Goedecef9dd82017-01-23 18:35:30 +0100251 break;
252
253 default:
254 break;
255 }
256
257 return 0;
258}
259
260static struct notifier_block silead_ts_dmi_notifier = {
261 .notifier_call = silead_ts_dmi_notifier_call,
262};
263
264static int __init silead_ts_dmi_init(void)
265{
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700266 const struct dmi_system_id *dmi_id;
Hans de Goedecef9dd82017-01-23 18:35:30 +0100267 int error;
268
Dmitry Torokhovf22265b2017-04-03 20:25:14 -0700269 dmi_id = dmi_first_match(silead_ts_dmi_table);
270 if (!dmi_id)
271 return 0; /* Not an error */
272
273 silead_ts_data = dmi_id->driver_data;
274
Hans de Goedecef9dd82017-01-23 18:35:30 +0100275 error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
276 if (error)
277 pr_err("%s: failed to register i2c bus notifier: %d\n",
278 __func__, error);
279
280 return error;
281}
282
283/*
284 * We are registering out notifier after i2c core is initialized and i2c bus
285 * itself is ready (which happens at postcore initcall level), but before
286 * ACPI starts enumerating devices (at subsys initcall level).
287 */
288arch_initcall(silead_ts_dmi_init);