silead_dmi.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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_STRING("firmware-name",
  76. "gsl1680-gp-electronic-t701.fw"),
  77. { }
  78. };
  79. static const struct silead_ts_dmi_data gp_electronic_t701_data = {
  80. .acpi_name = "MSSL1680:00",
  81. .properties = gp_electronic_t701_props,
  82. };
  83. static const struct property_entry pipo_w2s_props[] = {
  84. PROPERTY_ENTRY_U32("touchscreen-size-x", 1660),
  85. PROPERTY_ENTRY_U32("touchscreen-size-y", 880),
  86. PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
  87. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  88. PROPERTY_ENTRY_STRING("firmware-name",
  89. "gsl1680-pipo-w2s.fw"),
  90. { }
  91. };
  92. static const struct silead_ts_dmi_data pipo_w2s_data = {
  93. .acpi_name = "MSSL1680:00",
  94. .properties = pipo_w2s_props,
  95. };
  96. static const struct property_entry pov_mobii_wintab_p800w_props[] = {
  97. PROPERTY_ENTRY_U32("touchscreen-size-x", 1800),
  98. PROPERTY_ENTRY_U32("touchscreen-size-y", 1150),
  99. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  100. PROPERTY_ENTRY_STRING("firmware-name",
  101. "gsl3692-pov-mobii-wintab-p800w.fw"),
  102. { }
  103. };
  104. static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_data = {
  105. .acpi_name = "MSSL1680:00",
  106. .properties = pov_mobii_wintab_p800w_props,
  107. };
  108. static const struct property_entry itworks_tw891_props[] = {
  109. PROPERTY_ENTRY_U32("touchscreen-size-x", 1600),
  110. PROPERTY_ENTRY_U32("touchscreen-size-y", 890),
  111. PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"),
  112. PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
  113. PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-itworks-tw891.fw"),
  114. { }
  115. };
  116. static const struct silead_ts_dmi_data itworks_tw891_data = {
  117. .acpi_name = "MSSL1680:00",
  118. .properties = itworks_tw891_props,
  119. };
  120. static const struct dmi_system_id silead_ts_dmi_table[] = {
  121. {
  122. /* CUBE iwork8 Air */
  123. .driver_data = (void *)&cube_iwork8_air_data,
  124. .matches = {
  125. DMI_MATCH(DMI_SYS_VENDOR, "cube"),
  126. DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
  127. DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
  128. },
  129. },
  130. {
  131. /* Jumper EZpad mini3 */
  132. .driver_data = (void *)&jumper_ezpad_mini3_data,
  133. .matches = {
  134. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  135. /* jumperx.T87.KFBNEEA02 with the version-nr dropped */
  136. DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
  137. },
  138. },
  139. {
  140. /* DEXP Ursus 7W */
  141. .driver_data = (void *)&dexp_ursus_7w_data,
  142. .matches = {
  143. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  144. DMI_MATCH(DMI_PRODUCT_NAME, "7W"),
  145. },
  146. },
  147. {
  148. /* Trekstor Surftab Wintron 7.0 ST70416-6 */
  149. .driver_data = (void *)&surftab_wintron70_st70416_6_data,
  150. .matches = {
  151. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  152. DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"),
  153. /* Exact match, different versions need different fw */
  154. DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"),
  155. },
  156. },
  157. {
  158. /* Ployer Momo7w (same hardware as the Trekstor ST70416-6) */
  159. .driver_data = (void *)&surftab_wintron70_st70416_6_data,
  160. .matches = {
  161. DMI_MATCH(DMI_SYS_VENDOR, "Shenzhen PLOYER"),
  162. DMI_MATCH(DMI_PRODUCT_NAME, "MOMO7W"),
  163. /* Exact match, different versions need different fw */
  164. DMI_MATCH(DMI_BIOS_VERSION, "MOMO.G.WI71C.MABMRBA02"),
  165. },
  166. },
  167. {
  168. /* GP-electronic T701 */
  169. .driver_data = (void *)&gp_electronic_t701_data,
  170. .matches = {
  171. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  172. DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
  173. DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
  174. },
  175. },
  176. {
  177. /* Pipo W2S */
  178. .driver_data = (void *)&pipo_w2s_data,
  179. .matches = {
  180. DMI_MATCH(DMI_SYS_VENDOR, "PIPO"),
  181. DMI_MATCH(DMI_PRODUCT_NAME, "W2S"),
  182. },
  183. },
  184. {
  185. /* Point of View mobii wintab p800w */
  186. .driver_data = (void *)&pov_mobii_wintab_p800w_data,
  187. .matches = {
  188. DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
  189. DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
  190. DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"),
  191. /* Above matches are too generic, add bios-date match */
  192. DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"),
  193. },
  194. },
  195. {
  196. /* I.T.Works TW891 */
  197. .driver_data = (void *)&itworks_tw891_data,
  198. .matches = {
  199. DMI_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."),
  200. DMI_MATCH(DMI_PRODUCT_NAME, "TW891"),
  201. },
  202. },
  203. { },
  204. };
  205. static const struct silead_ts_dmi_data *silead_ts_data;
  206. static void silead_ts_dmi_add_props(struct i2c_client *client)
  207. {
  208. struct device *dev = &client->dev;
  209. int error;
  210. if (has_acpi_companion(dev) &&
  211. !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
  212. error = device_add_properties(dev, silead_ts_data->properties);
  213. if (error)
  214. dev_err(dev, "failed to add properties: %d\n", error);
  215. }
  216. }
  217. static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
  218. unsigned long action, void *data)
  219. {
  220. struct device *dev = data;
  221. struct i2c_client *client;
  222. switch (action) {
  223. case BUS_NOTIFY_ADD_DEVICE:
  224. client = i2c_verify_client(dev);
  225. if (client)
  226. silead_ts_dmi_add_props(client);
  227. break;
  228. default:
  229. break;
  230. }
  231. return 0;
  232. }
  233. static struct notifier_block silead_ts_dmi_notifier = {
  234. .notifier_call = silead_ts_dmi_notifier_call,
  235. };
  236. static int __init silead_ts_dmi_init(void)
  237. {
  238. const struct dmi_system_id *dmi_id;
  239. int error;
  240. dmi_id = dmi_first_match(silead_ts_dmi_table);
  241. if (!dmi_id)
  242. return 0; /* Not an error */
  243. silead_ts_data = dmi_id->driver_data;
  244. error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
  245. if (error)
  246. pr_err("%s: failed to register i2c bus notifier: %d\n",
  247. __func__, error);
  248. return error;
  249. }
  250. /*
  251. * We are registering out notifier after i2c core is initialized and i2c bus
  252. * itself is ready (which happens at postcore initcall level), but before
  253. * ACPI starts enumerating devices (at subsys initcall level).
  254. */
  255. arch_initcall(silead_ts_dmi_init);