silead_dmi.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 dmi_system_id silead_ts_dmi_table[] = {
  73. {
  74. /* CUBE iwork8 Air */
  75. .driver_data = (void *)&cube_iwork8_air_data,
  76. .matches = {
  77. DMI_MATCH(DMI_SYS_VENDOR, "cube"),
  78. DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
  79. DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
  80. },
  81. },
  82. {
  83. /* Jumper EZpad mini3 */
  84. .driver_data = (void *)&jumper_ezpad_mini3_data,
  85. .matches = {
  86. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  87. /* jumperx.T87.KFBNEEA02 with the version-nr dropped */
  88. DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
  89. },
  90. },
  91. {
  92. /* DEXP Ursus 7W */
  93. .driver_data = (void *)&dexp_ursus_7w_data,
  94. .matches = {
  95. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  96. DMI_MATCH(DMI_PRODUCT_NAME, "7W"),
  97. },
  98. },
  99. {
  100. /* Trekstor Surftab Wintron 7.0 ST70416-6 */
  101. .driver_data = (void *)&surftab_wintron70_st70416_6_data,
  102. .matches = {
  103. DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
  104. DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"),
  105. /* Exact match, different versions need different fw */
  106. DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"),
  107. },
  108. },
  109. { },
  110. };
  111. static const struct silead_ts_dmi_data *silead_ts_data;
  112. static void silead_ts_dmi_add_props(struct i2c_client *client)
  113. {
  114. struct device *dev = &client->dev;
  115. int error;
  116. if (has_acpi_companion(dev) &&
  117. !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
  118. error = device_add_properties(dev, silead_ts_data->properties);
  119. if (error)
  120. dev_err(dev, "failed to add properties: %d\n", error);
  121. }
  122. }
  123. static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
  124. unsigned long action, void *data)
  125. {
  126. struct device *dev = data;
  127. struct i2c_client *client;
  128. switch (action) {
  129. case BUS_NOTIFY_ADD_DEVICE:
  130. client = i2c_verify_client(dev);
  131. if (client)
  132. silead_ts_dmi_add_props(client);
  133. break;
  134. default:
  135. break;
  136. }
  137. return 0;
  138. }
  139. static struct notifier_block silead_ts_dmi_notifier = {
  140. .notifier_call = silead_ts_dmi_notifier_call,
  141. };
  142. static int __init silead_ts_dmi_init(void)
  143. {
  144. const struct dmi_system_id *dmi_id;
  145. int error;
  146. dmi_id = dmi_first_match(silead_ts_dmi_table);
  147. if (!dmi_id)
  148. return 0; /* Not an error */
  149. silead_ts_data = dmi_id->driver_data;
  150. error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
  151. if (error)
  152. pr_err("%s: failed to register i2c bus notifier: %d\n",
  153. __func__, error);
  154. return error;
  155. }
  156. /*
  157. * We are registering out notifier after i2c core is initialized and i2c bus
  158. * itself is ready (which happens at postcore initcall level), but before
  159. * ACPI starts enumerating devices (at subsys initcall level).
  160. */
  161. arch_initcall(silead_ts_dmi_init);