silead_dmi.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. #include <linux/acpi.h>
  15. #include <linux/device.h>
  16. #include <linux/dmi.h>
  17. #include <linux/i2c.h>
  18. #include <linux/notifier.h>
  19. #include <linux/property.h>
  20. #include <linux/string.h>
  21. struct silead_ts_dmi_data {
  22. const char *acpi_name;
  23. const struct property_entry *properties;
  24. };
  25. static const struct property_entry cube_iwork8_air_props[] = {
  26. PROPERTY_ENTRY_U32("touchscreen-size-x", 1660),
  27. PROPERTY_ENTRY_U32("touchscreen-size-y", 900),
  28. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  29. PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-cube-iwork8-air.fw"),
  30. PROPERTY_ENTRY_U32("silead,max-fingers", 10),
  31. { }
  32. };
  33. static const struct silead_ts_dmi_data cube_iwork8_air_data = {
  34. .acpi_name = "MSSL1680:00",
  35. .properties = cube_iwork8_air_props,
  36. };
  37. static const struct property_entry jumper_ezpad_mini3_props[] = {
  38. PROPERTY_ENTRY_U32("touchscreen-size-x", 1700),
  39. PROPERTY_ENTRY_U32("touchscreen-size-y", 1150),
  40. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  41. PROPERTY_ENTRY_STRING("firmware-name", "gsl3676-jumper-ezpad-mini3.fw"),
  42. PROPERTY_ENTRY_U32("silead,max-fingers", 10),
  43. { }
  44. };
  45. static const struct silead_ts_dmi_data jumper_ezpad_mini3_data = {
  46. .acpi_name = "MSSL1680:00",
  47. .properties = jumper_ezpad_mini3_props,
  48. };
  49. static const struct property_entry dexp_ursus_7w_props[] = {
  50. PROPERTY_ENTRY_U32("touchscreen-size-x", 890),
  51. PROPERTY_ENTRY_U32("touchscreen-size-y", 630),
  52. PROPERTY_ENTRY_STRING("firmware-name", "gsl1686-dexp-ursus-7w.fw"),
  53. PROPERTY_ENTRY_U32("silead,max-fingers", 10),
  54. { }
  55. };
  56. static const struct silead_ts_dmi_data dexp_ursus_7w_data = {
  57. .acpi_name = "MSSL1680:00",
  58. .properties = dexp_ursus_7w_props,
  59. };
  60. static const struct property_entry surftab_wintron70_st70416_6_props[] = {
  61. PROPERTY_ENTRY_U32("touchscreen-size-x", 884),
  62. PROPERTY_ENTRY_U32("touchscreen-size-y", 632),
  63. PROPERTY_ENTRY_STRING("firmware-name",
  64. "gsl1686-surftab-wintron70-st70416-6.fw"),
  65. PROPERTY_ENTRY_U32("silead,max-fingers", 10),
  66. { }
  67. };
  68. static const struct silead_ts_dmi_data surftab_wintron70_st70416_6_data = {
  69. .acpi_name = "MSSL1680:00",
  70. .properties = surftab_wintron70_st70416_6_props,
  71. };
  72. static const struct property_entry gp_electronic_t701_props[] = {
  73. PROPERTY_ENTRY_U32("touchscreen-size-x", 960),
  74. PROPERTY_ENTRY_U32("touchscreen-size-y", 640),
  75. PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
  76. PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
  77. PROPERTY_ENTRY_STRING("firmware-name",
  78. "gsl1680-gp-electronic-t701.fw"),
  79. { }
  80. };
  81. static const struct silead_ts_dmi_data gp_electronic_t701_data = {
  82. .acpi_name = "MSSL1680:00",
  83. .properties = gp_electronic_t701_props,
  84. };
  85. static const struct property_entry pipo_w2s_props[] = {
  86. PROPERTY_ENTRY_U32("touchscreen-size-x", 1660),
  87. PROPERTY_ENTRY_U32("touchscreen-size-y", 880),
  88. PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
  89. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  90. PROPERTY_ENTRY_STRING("firmware-name",
  91. "gsl1680-pipo-w2s.fw"),
  92. { }
  93. };
  94. static const struct silead_ts_dmi_data pipo_w2s_data = {
  95. .acpi_name = "MSSL1680:00",
  96. .properties = pipo_w2s_props,
  97. };
  98. static const struct property_entry pov_mobii_wintab_p800w_props[] = {
  99. PROPERTY_ENTRY_U32("touchscreen-size-x", 1800),
  100. PROPERTY_ENTRY_U32("touchscreen-size-y", 1150),
  101. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  102. PROPERTY_ENTRY_STRING("firmware-name",
  103. "gsl3692-pov-mobii-wintab-p800w.fw"),
  104. { }
  105. };
  106. static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_data = {
  107. .acpi_name = "MSSL1680:00",
  108. .properties = pov_mobii_wintab_p800w_props,
  109. };
  110. static const struct property_entry itworks_tw891_props[] = {
  111. PROPERTY_ENTRY_U32("touchscreen-size-x", 1600),
  112. PROPERTY_ENTRY_U32("touchscreen-size-y", 890),
  113. PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
  114. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  115. PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-itworks-tw891.fw"),
  116. { }
  117. };
  118. static const struct silead_ts_dmi_data itworks_tw891_data = {
  119. .acpi_name = "MSSL1680:00",
  120. .properties = itworks_tw891_props,
  121. };
  122. static const struct property_entry chuwi_hi8_pro_props[] = {
  123. PROPERTY_ENTRY_U32("touchscreen-size-x", 1728),
  124. PROPERTY_ENTRY_U32("touchscreen-size-y", 1148),
  125. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  126. PROPERTY_ENTRY_STRING("firmware-name", "gsl3680-chuwi-hi8-pro.fw"),
  127. { }
  128. };
  129. static const struct silead_ts_dmi_data chuwi_hi8_pro_data = {
  130. .acpi_name = "MSSL1680:00",
  131. .properties = chuwi_hi8_pro_props,
  132. };
  133. static const struct property_entry digma_citi_e200_props[] = {
  134. PROPERTY_ENTRY_U32("touchscreen-size-x", 1980),
  135. PROPERTY_ENTRY_U32("touchscreen-size-y", 1500),
  136. PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
  137. PROPERTY_ENTRY_STRING("firmware-name",
  138. "gsl1686-digma_citi_e200.fw"),
  139. PROPERTY_ENTRY_U32("silead,max-fingers", 10),
  140. PROPERTY_ENTRY_BOOL("silead,home-button"),
  141. { }
  142. };
  143. static const struct silead_ts_dmi_data digma_citi_e200_data = {
  144. .acpi_name = "MSSL1680:00",
  145. .properties = digma_citi_e200_props,
  146. };
  147. static const struct dmi_system_id silead_ts_dmi_table[] = {
  148. {
  149. /* CUBE iwork8 Air */
  150. .driver_data = (void *)&cube_iwork8_air_data,
  151. .matches = {
  152. DMI_MATCH(DMI_SYS_VENDOR, "cube"),
  153. DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
  154. DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
  155. },
  156. },
  157. {
  158. /* Jumper EZpad mini3 */
  159. .driver_data = (void *)&jumper_ezpad_mini3_data,
  160. .matches = {
  161. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  162. /* jumperx.T87.KFBNEEA02 with the version-nr dropped */
  163. DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
  164. },
  165. },
  166. {
  167. /* DEXP Ursus 7W */
  168. .driver_data = (void *)&dexp_ursus_7w_data,
  169. .matches = {
  170. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  171. DMI_MATCH(DMI_PRODUCT_NAME, "7W"),
  172. },
  173. },
  174. {
  175. /* Trekstor Surftab Wintron 7.0 ST70416-6 */
  176. .driver_data = (void *)&surftab_wintron70_st70416_6_data,
  177. .matches = {
  178. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  179. DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"),
  180. /* Exact match, different versions need different fw */
  181. DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"),
  182. },
  183. },
  184. {
  185. /* Ployer Momo7w (same hardware as the Trekstor ST70416-6) */
  186. .driver_data = (void *)&surftab_wintron70_st70416_6_data,
  187. .matches = {
  188. DMI_MATCH(DMI_SYS_VENDOR, "Shenzhen PLOYER"),
  189. DMI_MATCH(DMI_PRODUCT_NAME, "MOMO7W"),
  190. /* Exact match, different versions need different fw */
  191. DMI_MATCH(DMI_BIOS_VERSION, "MOMO.G.WI71C.MABMRBA02"),
  192. },
  193. },
  194. {
  195. /* GP-electronic T701 */
  196. .driver_data = (void *)&gp_electronic_t701_data,
  197. .matches = {
  198. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  199. DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
  200. DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
  201. },
  202. },
  203. {
  204. /* Pipo W2S */
  205. .driver_data = (void *)&pipo_w2s_data,
  206. .matches = {
  207. DMI_MATCH(DMI_SYS_VENDOR, "PIPO"),
  208. DMI_MATCH(DMI_PRODUCT_NAME, "W2S"),
  209. },
  210. },
  211. {
  212. /* Point of View mobii wintab p800w */
  213. .driver_data = (void *)&pov_mobii_wintab_p800w_data,
  214. .matches = {
  215. DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
  216. DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
  217. DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
  218. /* Above matches are too generic, add bios-date match */
  219. DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
  220. },
  221. },
  222. {
  223. /* I.T.Works TW891 */
  224. .driver_data = (void *)&itworks_tw891_data,
  225. .matches = {
  226. DMI_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
  227. DMI_MATCH(DMI_PRODUCT_NAME, "TW891"),
  228. },
  229. },
  230. {
  231. /* Chuwi Hi8 Pro */
  232. .driver_data = (void *)&chuwi_hi8_pro_data,
  233. .matches = {
  234. DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"),
  235. DMI_MATCH(DMI_PRODUCT_NAME, "X1D3_C806N"),
  236. },
  237. },
  238. {
  239. /* Digma Citi E200 */
  240. .driver_data = (void *)&digma_citi_e200_data,
  241. .matches = {
  242. DMI_MATCH(DMI_SYS_VENDOR, "Digma"),
  243. DMI_MATCH(DMI_PRODUCT_NAME, "CITI E200"),
  244. DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
  245. },
  246. },
  247. { },
  248. };
  249. static const struct silead_ts_dmi_data *silead_ts_data;
  250. static void silead_ts_dmi_add_props(struct i2c_client *client)
  251. {
  252. struct device *dev = &client->dev;
  253. int error;
  254. if (has_acpi_companion(dev) &&
  255. !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
  256. error = device_add_properties(dev, silead_ts_data->properties);
  257. if (error)
  258. dev_err(dev, "failed to add properties: %d\n", error);
  259. }
  260. }
  261. static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
  262. unsigned long action, void *data)
  263. {
  264. struct device *dev = data;
  265. struct i2c_client *client;
  266. switch (action) {
  267. case BUS_NOTIFY_ADD_DEVICE:
  268. client = i2c_verify_client(dev);
  269. if (client)
  270. silead_ts_dmi_add_props(client);
  271. break;
  272. default:
  273. break;
  274. }
  275. return 0;
  276. }
  277. static struct notifier_block silead_ts_dmi_notifier = {
  278. .notifier_call = silead_ts_dmi_notifier_call,
  279. };
  280. static int __init silead_ts_dmi_init(void)
  281. {
  282. const struct dmi_system_id *dmi_id;
  283. int error;
  284. dmi_id = dmi_first_match(silead_ts_dmi_table);
  285. if (!dmi_id)
  286. return 0; /* Not an error */
  287. silead_ts_data = dmi_id->driver_data;
  288. error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
  289. if (error)
  290. pr_err("%s: failed to register i2c bus notifier: %d\n",
  291. __func__, error);
  292. return error;
  293. }
  294. /*
  295. * We are registering out notifier after i2c core is initialized and i2c bus
  296. * itself is ready (which happens at postcore initcall level), but before
  297. * ACPI starts enumerating devices (at subsys initcall level).
  298. */
  299. arch_initcall(silead_ts_dmi_init);