Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 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; |
Hans de Goede | ae31115 | 2017-03-22 16:55:53 +0100 | [diff] [blame] | 25 | const struct property_entry *properties; |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 26 | }; |
| 27 | |
Hans de Goede | ae31115 | 2017-03-22 16:55:53 +0100 | [diff] [blame] | 28 | static const struct property_entry cube_iwork8_air_props[] = { |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 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 | |
Hans de Goede | ae31115 | 2017-03-22 16:55:53 +0100 | [diff] [blame] | 42 | static const struct property_entry jumper_ezpad_mini3_props[] = { |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 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 | |
Hans de Goede | 6b8e7d8 | 2017-03-22 16:55:54 +0100 | [diff] [blame] | 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 | |
Hans de Goede | 5b7bb3a | 2017-04-09 11:07:44 +0200 | [diff] [blame] | 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 | |
Hans de Goede | d9ca30b | 2017-05-07 14:35:15 +0200 | [diff] [blame] | 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), |
Hans de Goede | 5c24c05 | 2017-10-19 09:44:14 +0200 | [diff] [blame] | 86 | PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"), |
| 87 | PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), |
Hans de Goede | d9ca30b | 2017-05-07 14:35:15 +0200 | [diff] [blame] | 88 | PROPERTY_ENTRY_STRING("firmware-name", |
| 89 | "gsl1680-gp-electronic-t701.fw"), |
| 90 | { } |
| 91 | }; |
| 92 | |
| 93 | static const struct silead_ts_dmi_data gp_electronic_t701_data = { |
| 94 | .acpi_name = "MSSL1680:00", |
| 95 | .properties = gp_electronic_t701_props, |
| 96 | }; |
| 97 | |
Hans de Goede | 13fadfa | 2017-06-15 08:48:32 +0200 | [diff] [blame] | 98 | static const struct property_entry pipo_w2s_props[] = { |
| 99 | PROPERTY_ENTRY_U32("touchscreen-size-x", 1660), |
| 100 | PROPERTY_ENTRY_U32("touchscreen-size-y", 880), |
| 101 | PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"), |
| 102 | PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), |
| 103 | PROPERTY_ENTRY_STRING("firmware-name", |
| 104 | "gsl1680-pipo-w2s.fw"), |
| 105 | { } |
| 106 | }; |
| 107 | |
| 108 | static const struct silead_ts_dmi_data pipo_w2s_data = { |
| 109 | .acpi_name = "MSSL1680:00", |
| 110 | .properties = pipo_w2s_props, |
| 111 | }; |
| 112 | |
Hans de Goede | f4d342c | 2017-06-15 08:48:31 +0200 | [diff] [blame] | 113 | static const struct property_entry pov_mobii_wintab_p800w_props[] = { |
| 114 | PROPERTY_ENTRY_U32("touchscreen-size-x", 1800), |
| 115 | PROPERTY_ENTRY_U32("touchscreen-size-y", 1150), |
| 116 | PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), |
| 117 | PROPERTY_ENTRY_STRING("firmware-name", |
| 118 | "gsl3692-pov-mobii-wintab-p800w.fw"), |
| 119 | { } |
| 120 | }; |
| 121 | |
| 122 | static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_data = { |
| 123 | .acpi_name = "MSSL1680:00", |
| 124 | .properties = pov_mobii_wintab_p800w_props, |
| 125 | }; |
| 126 | |
Hans de Goede | 4edfc54 | 2017-07-01 12:15:22 +0200 | [diff] [blame] | 127 | static const struct property_entry itworks_tw891_props[] = { |
| 128 | PROPERTY_ENTRY_U32("touchscreen-size-x", 1600), |
| 129 | PROPERTY_ENTRY_U32("touchscreen-size-y", 890), |
| 130 | PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), |
| 131 | PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), |
| 132 | PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-itworks-tw891.fw"), |
| 133 | { } |
| 134 | }; |
| 135 | |
| 136 | static const struct silead_ts_dmi_data itworks_tw891_data = { |
| 137 | .acpi_name = "MSSL1680:00", |
| 138 | .properties = itworks_tw891_props, |
| 139 | }; |
| 140 | |
Hans de Goede | 485f2a5 | 2017-10-04 15:30:12 +0200 | [diff] [blame] | 141 | static const struct property_entry chuwi_hi8_pro_props[] = { |
| 142 | PROPERTY_ENTRY_U32("touchscreen-size-x", 1728), |
| 143 | PROPERTY_ENTRY_U32("touchscreen-size-y", 1148), |
| 144 | PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), |
| 145 | PROPERTY_ENTRY_STRING("firmware-name", "gsl3680-chuwi-hi8-pro.fw"), |
| 146 | { } |
| 147 | }; |
| 148 | |
| 149 | static const struct silead_ts_dmi_data chuwi_hi8_pro_data = { |
| 150 | .acpi_name = "MSSL1680:00", |
| 151 | .properties = chuwi_hi8_pro_props, |
| 152 | }; |
| 153 | |
Sergey Tshovrebov | 3fcf2b2 | 2017-10-27 12:27:07 +0200 | [diff] [blame^] | 154 | static const struct property_entry digma_citi_e200_props[] = { |
| 155 | PROPERTY_ENTRY_U32("touchscreen-size-x", 1980), |
| 156 | PROPERTY_ENTRY_U32("touchscreen-size-y", 1500), |
| 157 | PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), |
| 158 | PROPERTY_ENTRY_STRING("firmware-name", |
| 159 | "gsl1686-digma_citi_e200.fw"), |
| 160 | PROPERTY_ENTRY_U32("silead,max-fingers", 10), |
| 161 | PROPERTY_ENTRY_BOOL("silead,home-button"), |
| 162 | { } |
| 163 | }; |
| 164 | |
| 165 | static const struct silead_ts_dmi_data digma_citi_e200_data = { |
| 166 | .acpi_name = "MSSL1680:00", |
| 167 | .properties = digma_citi_e200_props, |
| 168 | }; |
| 169 | |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 170 | static const struct dmi_system_id silead_ts_dmi_table[] = { |
| 171 | { |
| 172 | /* CUBE iwork8 Air */ |
| 173 | .driver_data = (void *)&cube_iwork8_air_data, |
| 174 | .matches = { |
| 175 | DMI_MATCH(DMI_SYS_VENDOR, "cube"), |
| 176 | DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"), |
| 177 | DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"), |
| 178 | }, |
| 179 | }, |
| 180 | { |
| 181 | /* Jumper EZpad mini3 */ |
| 182 | .driver_data = (void *)&jumper_ezpad_mini3_data, |
| 183 | .matches = { |
| 184 | DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 185 | /* jumperx.T87.KFBNEEA02 with the version-nr dropped */ |
| 186 | DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"), |
| 187 | }, |
| 188 | }, |
Hans de Goede | 6b8e7d8 | 2017-03-22 16:55:54 +0100 | [diff] [blame] | 189 | { |
| 190 | /* DEXP Ursus 7W */ |
| 191 | .driver_data = (void *)&dexp_ursus_7w_data, |
| 192 | .matches = { |
| 193 | DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 194 | DMI_MATCH(DMI_PRODUCT_NAME, "7W"), |
| 195 | }, |
| 196 | }, |
Hans de Goede | 5b7bb3a | 2017-04-09 11:07:44 +0200 | [diff] [blame] | 197 | { |
| 198 | /* Trekstor Surftab Wintron 7.0 ST70416-6 */ |
| 199 | .driver_data = (void *)&surftab_wintron70_st70416_6_data, |
| 200 | .matches = { |
| 201 | DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 202 | DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"), |
| 203 | /* Exact match, different versions need different fw */ |
| 204 | DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"), |
| 205 | }, |
| 206 | }, |
Hans de Goede | d9ca30b | 2017-05-07 14:35:15 +0200 | [diff] [blame] | 207 | { |
Hans de Goede | c3a73ed | 2017-07-12 13:15:11 +0200 | [diff] [blame] | 208 | /* Ployer Momo7w (same hardware as the Trekstor ST70416-6) */ |
| 209 | .driver_data = (void *)&surftab_wintron70_st70416_6_data, |
| 210 | .matches = { |
| 211 | DMI_MATCH(DMI_SYS_VENDOR, "Shenzhen PLOYER"), |
| 212 | DMI_MATCH(DMI_PRODUCT_NAME, "MOMO7W"), |
| 213 | /* Exact match, different versions need different fw */ |
| 214 | DMI_MATCH(DMI_BIOS_VERSION, "MOMO.G.WI71C.MABMRBA02"), |
| 215 | }, |
| 216 | }, |
| 217 | { |
Hans de Goede | d9ca30b | 2017-05-07 14:35:15 +0200 | [diff] [blame] | 218 | /* GP-electronic T701 */ |
| 219 | .driver_data = (void *)&gp_electronic_t701_data, |
| 220 | .matches = { |
| 221 | DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 222 | DMI_MATCH(DMI_PRODUCT_NAME, "T701"), |
| 223 | DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"), |
| 224 | }, |
| 225 | }, |
Hans de Goede | 13fadfa | 2017-06-15 08:48:32 +0200 | [diff] [blame] | 226 | { |
| 227 | /* Pipo W2S */ |
| 228 | .driver_data = (void *)&pipo_w2s_data, |
| 229 | .matches = { |
| 230 | DMI_MATCH(DMI_SYS_VENDOR, "PIPO"), |
| 231 | DMI_MATCH(DMI_PRODUCT_NAME, "W2S"), |
| 232 | }, |
| 233 | }, |
Hans de Goede | f4d342c | 2017-06-15 08:48:31 +0200 | [diff] [blame] | 234 | { |
| 235 | /* Point of View mobii wintab p800w */ |
| 236 | .driver_data = (void *)&pov_mobii_wintab_p800w_data, |
| 237 | .matches = { |
| 238 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 239 | DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 240 | DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"), |
| 241 | /* Above matches are too generic, add bios-date match */ |
| 242 | DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"), |
| 243 | }, |
| 244 | }, |
Hans de Goede | 4edfc54 | 2017-07-01 12:15:22 +0200 | [diff] [blame] | 245 | { |
| 246 | /* I.T.Works TW891 */ |
| 247 | .driver_data = (void *)&itworks_tw891_data, |
| 248 | .matches = { |
| 249 | DMI_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."), |
| 250 | DMI_MATCH(DMI_PRODUCT_NAME, "TW891"), |
| 251 | }, |
| 252 | }, |
Hans de Goede | 485f2a5 | 2017-10-04 15:30:12 +0200 | [diff] [blame] | 253 | { |
| 254 | /* Chuwi Hi8 Pro */ |
| 255 | .driver_data = (void *)&chuwi_hi8_pro_data, |
| 256 | .matches = { |
| 257 | DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"), |
| 258 | DMI_MATCH(DMI_PRODUCT_NAME, "X1D3_C806N"), |
| 259 | }, |
| 260 | }, |
Sergey Tshovrebov | 3fcf2b2 | 2017-10-27 12:27:07 +0200 | [diff] [blame^] | 261 | { |
| 262 | /* Digma Citi E200 */ |
| 263 | .driver_data = (void *)&digma_citi_e200_data, |
| 264 | .matches = { |
| 265 | DMI_MATCH(DMI_SYS_VENDOR, "Digma"), |
| 266 | DMI_MATCH(DMI_PRODUCT_NAME, "CITI E200"), |
| 267 | DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"), |
| 268 | }, |
| 269 | }, |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 270 | { }, |
| 271 | }; |
| 272 | |
Dmitry Torokhov | f22265b | 2017-04-03 20:25:14 -0700 | [diff] [blame] | 273 | static const struct silead_ts_dmi_data *silead_ts_data; |
| 274 | |
Dmitry Torokhov | e105396 | 2017-04-03 20:25:13 -0700 | [diff] [blame] | 275 | static void silead_ts_dmi_add_props(struct i2c_client *client) |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 276 | { |
Dmitry Torokhov | e105396 | 2017-04-03 20:25:13 -0700 | [diff] [blame] | 277 | struct device *dev = &client->dev; |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 278 | int error; |
| 279 | |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 280 | if (has_acpi_companion(dev) && |
Dmitry Torokhov | f22265b | 2017-04-03 20:25:14 -0700 | [diff] [blame] | 281 | !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) { |
| 282 | error = device_add_properties(dev, silead_ts_data->properties); |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 283 | if (error) |
| 284 | dev_err(dev, "failed to add properties: %d\n", error); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | static int silead_ts_dmi_notifier_call(struct notifier_block *nb, |
| 289 | unsigned long action, void *data) |
| 290 | { |
| 291 | struct device *dev = data; |
Dmitry Torokhov | e105396 | 2017-04-03 20:25:13 -0700 | [diff] [blame] | 292 | struct i2c_client *client; |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 293 | |
| 294 | switch (action) { |
| 295 | case BUS_NOTIFY_ADD_DEVICE: |
Dmitry Torokhov | e105396 | 2017-04-03 20:25:13 -0700 | [diff] [blame] | 296 | client = i2c_verify_client(dev); |
| 297 | if (client) |
| 298 | silead_ts_dmi_add_props(client); |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 299 | break; |
| 300 | |
| 301 | default: |
| 302 | break; |
| 303 | } |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | static struct notifier_block silead_ts_dmi_notifier = { |
| 309 | .notifier_call = silead_ts_dmi_notifier_call, |
| 310 | }; |
| 311 | |
| 312 | static int __init silead_ts_dmi_init(void) |
| 313 | { |
Dmitry Torokhov | f22265b | 2017-04-03 20:25:14 -0700 | [diff] [blame] | 314 | const struct dmi_system_id *dmi_id; |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 315 | int error; |
| 316 | |
Dmitry Torokhov | f22265b | 2017-04-03 20:25:14 -0700 | [diff] [blame] | 317 | dmi_id = dmi_first_match(silead_ts_dmi_table); |
| 318 | if (!dmi_id) |
| 319 | return 0; /* Not an error */ |
| 320 | |
| 321 | silead_ts_data = dmi_id->driver_data; |
| 322 | |
Hans de Goede | cef9dd8 | 2017-01-23 18:35:30 +0100 | [diff] [blame] | 323 | error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier); |
| 324 | if (error) |
| 325 | pr_err("%s: failed to register i2c bus notifier: %d\n", |
| 326 | __func__, error); |
| 327 | |
| 328 | return error; |
| 329 | } |
| 330 | |
| 331 | /* |
| 332 | * We are registering out notifier after i2c core is initialized and i2c bus |
| 333 | * itself is ready (which happens at postcore initcall level), but before |
| 334 | * ACPI starts enumerating devices (at subsys initcall level). |
| 335 | */ |
| 336 | arch_initcall(silead_ts_dmi_init); |