]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/platform/x86/silead_dmi.c
scsi: qedf: Fix a potential NULL pointer dereference
[mirror_ubuntu-artful-kernel.git] / drivers / platform / x86 / silead_dmi.c
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
23 struct silead_ts_dmi_data {
24 const char *acpi_name;
25 const struct property_entry *properties;
26 };
27
28 static 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
37 static const struct silead_ts_dmi_data cube_iwork8_air_data = {
38 .acpi_name = "MSSL1680:00",
39 .properties = cube_iwork8_air_props,
40 };
41
42 static 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
51 static const struct silead_ts_dmi_data jumper_ezpad_mini3_data = {
52 .acpi_name = "MSSL1680:00",
53 .properties = jumper_ezpad_mini3_props,
54 };
55
56 static 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
64 static const struct silead_ts_dmi_data dexp_ursus_7w_data = {
65 .acpi_name = "MSSL1680:00",
66 .properties = dexp_ursus_7w_props,
67 };
68
69 static 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
78 static 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
83 static 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
91 static const struct silead_ts_dmi_data gp_electronic_t701_data = {
92 .acpi_name = "MSSL1680:00",
93 .properties = gp_electronic_t701_props,
94 };
95
96 static 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
106 static const struct silead_ts_dmi_data pipo_w2s_data = {
107 .acpi_name = "MSSL1680:00",
108 .properties = pipo_w2s_props,
109 };
110
111 static 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
120 static 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
125 static const struct dmi_system_id silead_ts_dmi_table[] = {
126 {
127 /* CUBE iwork8 Air */
128 .driver_data = (void *)&cube_iwork8_air_data,
129 .matches = {
130 DMI_MATCH(DMI_SYS_VENDOR, "cube"),
131 DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
132 DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
133 },
134 },
135 {
136 /* Jumper EZpad mini3 */
137 .driver_data = (void *)&jumper_ezpad_mini3_data,
138 .matches = {
139 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
140 /* jumperx.T87.KFBNEEA02 with the version-nr dropped */
141 DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
142 },
143 },
144 {
145 /* DEXP Ursus 7W */
146 .driver_data = (void *)&dexp_ursus_7w_data,
147 .matches = {
148 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
149 DMI_MATCH(DMI_PRODUCT_NAME, "7W"),
150 },
151 },
152 {
153 /* Trekstor Surftab Wintron 7.0 ST70416-6 */
154 .driver_data = (void *)&surftab_wintron70_st70416_6_data,
155 .matches = {
156 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
157 DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"),
158 /* Exact match, different versions need different fw */
159 DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"),
160 },
161 },
162 {
163 /* GP-electronic T701 */
164 .driver_data = (void *)&gp_electronic_t701_data,
165 .matches = {
166 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
167 DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
168 DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
169 },
170 },
171 {
172 /* Pipo W2S */
173 .driver_data = (void *)&pipo_w2s_data,
174 .matches = {
175 DMI_MATCH(DMI_SYS_VENDOR, "PIPO"),
176 DMI_MATCH(DMI_PRODUCT_NAME, "W2S"),
177 },
178 },
179 {
180 /* Point of View mobii wintab p800w */
181 .driver_data = (void *)&pov_mobii_wintab_p800w_data,
182 .matches = {
183 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
184 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
185 DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
186 /* Above matches are too generic, add bios-date match */
187 DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
188 },
189 },
190 { },
191 };
192
193 static const struct silead_ts_dmi_data *silead_ts_data;
194
195 static void silead_ts_dmi_add_props(struct i2c_client *client)
196 {
197 struct device *dev = &client->dev;
198 int error;
199
200 if (has_acpi_companion(dev) &&
201 !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
202 error = device_add_properties(dev, silead_ts_data->properties);
203 if (error)
204 dev_err(dev, "failed to add properties: %d\n", error);
205 }
206 }
207
208 static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
209 unsigned long action, void *data)
210 {
211 struct device *dev = data;
212 struct i2c_client *client;
213
214 switch (action) {
215 case BUS_NOTIFY_ADD_DEVICE:
216 client = i2c_verify_client(dev);
217 if (client)
218 silead_ts_dmi_add_props(client);
219 break;
220
221 default:
222 break;
223 }
224
225 return 0;
226 }
227
228 static struct notifier_block silead_ts_dmi_notifier = {
229 .notifier_call = silead_ts_dmi_notifier_call,
230 };
231
232 static int __init silead_ts_dmi_init(void)
233 {
234 const struct dmi_system_id *dmi_id;
235 int error;
236
237 dmi_id = dmi_first_match(silead_ts_dmi_table);
238 if (!dmi_id)
239 return 0; /* Not an error */
240
241 silead_ts_data = dmi_id->driver_data;
242
243 error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
244 if (error)
245 pr_err("%s: failed to register i2c bus notifier: %d\n",
246 __func__, error);
247
248 return error;
249 }
250
251 /*
252 * We are registering out notifier after i2c core is initialized and i2c bus
253 * itself is ready (which happens at postcore initcall level), but before
254 * ACPI starts enumerating devices (at subsys initcall level).
255 */
256 arch_initcall(silead_ts_dmi_init);