]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/platform/x86/silead_dmi.c
Merge tag 'trace-v4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[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 struct property_entry *properties;
26 };
27
28 static 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 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 dmi_system_id silead_ts_dmi_table[] = {
57 {
58 /* CUBE iwork8 Air */
59 .driver_data = (void *)&cube_iwork8_air_data,
60 .matches = {
61 DMI_MATCH(DMI_SYS_VENDOR, "cube"),
62 DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"),
63 DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
64 },
65 },
66 {
67 /* Jumper EZpad mini3 */
68 .driver_data = (void *)&jumper_ezpad_mini3_data,
69 .matches = {
70 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
71 /* jumperx.T87.KFBNEEA02 with the version-nr dropped */
72 DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
73 },
74 },
75 { },
76 };
77
78 static void silead_ts_dmi_add_props(struct device *dev)
79 {
80 struct i2c_client *client = to_i2c_client(dev);
81 const struct dmi_system_id *dmi_id;
82 const struct silead_ts_dmi_data *ts_data;
83 int error;
84
85 dmi_id = dmi_first_match(silead_ts_dmi_table);
86 if (!dmi_id)
87 return;
88
89 ts_data = dmi_id->driver_data;
90 if (has_acpi_companion(dev) &&
91 !strncmp(ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
92 error = device_add_properties(dev, ts_data->properties);
93 if (error)
94 dev_err(dev, "failed to add properties: %d\n", error);
95 }
96 }
97
98 static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
99 unsigned long action, void *data)
100 {
101 struct device *dev = data;
102
103 switch (action) {
104 case BUS_NOTIFY_ADD_DEVICE:
105 silead_ts_dmi_add_props(dev);
106 break;
107
108 default:
109 break;
110 }
111
112 return 0;
113 }
114
115 static struct notifier_block silead_ts_dmi_notifier = {
116 .notifier_call = silead_ts_dmi_notifier_call,
117 };
118
119 static int __init silead_ts_dmi_init(void)
120 {
121 int error;
122
123 error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
124 if (error)
125 pr_err("%s: failed to register i2c bus notifier: %d\n",
126 __func__, error);
127
128 return error;
129 }
130
131 /*
132 * We are registering out notifier after i2c core is initialized and i2c bus
133 * itself is ready (which happens at postcore initcall level), but before
134 * ACPI starts enumerating devices (at subsys initcall level).
135 */
136 arch_initcall(silead_ts_dmi_init);