2 * Silead touchscreen driver DMI based configuration code
4 * Copyright (c) 2017 Red Hat Inc.
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.
12 * Hans de Goede <hdegoede@redhat.com>
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>
23 struct silead_ts_dmi_data
{
24 const char *acpi_name
;
25 struct property_entry
*properties
;
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),
37 static const struct silead_ts_dmi_data cube_iwork8_air_data
= {
38 .acpi_name
= "MSSL1680:00",
39 .properties
= cube_iwork8_air_props
,
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),
51 static const struct silead_ts_dmi_data jumper_ezpad_mini3_data
= {
52 .acpi_name
= "MSSL1680:00",
53 .properties
= jumper_ezpad_mini3_props
,
56 static const struct dmi_system_id silead_ts_dmi_table
[] = {
59 .driver_data
= (void *)&cube_iwork8_air_data
,
61 DMI_MATCH(DMI_SYS_VENDOR
, "cube"),
62 DMI_MATCH(DMI_PRODUCT_NAME
, "i1-TF"),
63 DMI_MATCH(DMI_BOARD_NAME
, "Cherry Trail CR"),
67 /* Jumper EZpad mini3 */
68 .driver_data
= (void *)&jumper_ezpad_mini3_data
,
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"),
78 static void silead_ts_dmi_add_props(struct device
*dev
)
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
;
85 dmi_id
= dmi_first_match(silead_ts_dmi_table
);
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
);
94 dev_err(dev
, "failed to add properties: %d\n", error
);
98 static int silead_ts_dmi_notifier_call(struct notifier_block
*nb
,
99 unsigned long action
, void *data
)
101 struct device
*dev
= data
;
104 case BUS_NOTIFY_ADD_DEVICE
:
105 silead_ts_dmi_add_props(dev
);
115 static struct notifier_block silead_ts_dmi_notifier
= {
116 .notifier_call
= silead_ts_dmi_notifier_call
,
119 static int __init
silead_ts_dmi_init(void)
123 error
= bus_register_notifier(&i2c_bus_type
, &silead_ts_dmi_notifier
);
125 pr_err("%s: failed to register i2c bus notifier: %d\n",
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).
136 arch_initcall(silead_ts_dmi_init
);