Skip to content

Commit c2742ef

Browse files
jwrdegoedegregkh
authored andcommitted
Input: elants_i2c - do not bind to i2c-hid compatible ACPI instantiated devices
[ Upstream commit 65299e8 ] Several users have been reporting that elants_i2c gives several errors during probe and that their touchscreen does not work on their Lenovo AMD based laptops with a touchscreen with a ELAN0001 ACPI hardware-id: [ 0.550596] elants_i2c i2c-ELAN0001:00: i2c-ELAN0001:00 supply vcc33 not found, using dummy regulator [ 0.551836] elants_i2c i2c-ELAN0001:00: i2c-ELAN0001:00 supply vccio not found, using dummy regulator [ 0.560932] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (77 77 77 77): -121 [ 0.562427] elants_i2c i2c-ELAN0001:00: software reset failed: -121 [ 0.595925] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (77 77 77 77): -121 [ 0.597974] elants_i2c i2c-ELAN0001:00: software reset failed: -121 [ 0.621893] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (77 77 77 77): -121 [ 0.622504] elants_i2c i2c-ELAN0001:00: software reset failed: -121 [ 0.632650] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (4d 61 69 6e): -121 [ 0.634256] elants_i2c i2c-ELAN0001:00: boot failed: -121 [ 0.699212] elants_i2c i2c-ELAN0001:00: invalid 'hello' packet: 00 00 ff ff [ 1.630506] elants_i2c i2c-ELAN0001:00: Failed to read fw id: -121 [ 1.645508] elants_i2c i2c-ELAN0001:00: unknown packet 00 00 ff ff Despite these errors, the elants_i2c driver stays bound to the device (it returns 0 from its probe method despite the errors), blocking the i2c-hid driver from binding. Manually unbinding the elants_i2c driver and binding the i2c-hid driver makes the touchscreen work. Check if the ACPI-fwnode for the touchscreen contains one of the i2c-hid compatiblity-id strings and if it has the I2C-HID spec's DSM to get the HID descriptor address, If it has both then make elants_i2c not bind, so that the i2c-hid driver can bind. This assumes that non of the (older) elan touchscreens which actually need the elants_i2c driver falsely advertise an i2c-hid compatiblity-id + DSM in their ACPI-fwnodes. If some of them actually do have this false advertising, then this change may lead to regressions. While at it also drop the unnecessary DEVICE_NAME prefixing of the "I2C check functionality error", dev_err already outputs the driver-name. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207759 Acked-by: Benjamin Tissoires <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4800a98 commit c2742ef

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

drivers/input/touchscreen/elants_i2c.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/of.h>
3939
#include <linux/gpio/consumer.h>
4040
#include <linux/regulator/consumer.h>
41+
#include <linux/uuid.h>
4142
#include <asm/unaligned.h>
4243

4344
/* Device, Driver information */
@@ -1224,6 +1225,40 @@ static void elants_i2c_power_off(void *_data)
12241225
}
12251226
}
12261227

1228+
#ifdef CONFIG_ACPI
1229+
static const struct acpi_device_id i2c_hid_ids[] = {
1230+
{"ACPI0C50", 0 },
1231+
{"PNP0C50", 0 },
1232+
{ },
1233+
};
1234+
1235+
static const guid_t i2c_hid_guid =
1236+
GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555,
1237+
0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE);
1238+
1239+
static bool elants_acpi_is_hid_device(struct device *dev)
1240+
{
1241+
acpi_handle handle = ACPI_HANDLE(dev);
1242+
union acpi_object *obj;
1243+
1244+
if (acpi_match_device_ids(ACPI_COMPANION(dev), i2c_hid_ids))
1245+
return false;
1246+
1247+
obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL, ACPI_TYPE_INTEGER);
1248+
if (obj) {
1249+
ACPI_FREE(obj);
1250+
return true;
1251+
}
1252+
1253+
return false;
1254+
}
1255+
#else
1256+
static bool elants_acpi_is_hid_device(struct device *dev)
1257+
{
1258+
return false;
1259+
}
1260+
#endif
1261+
12271262
static int elants_i2c_probe(struct i2c_client *client,
12281263
const struct i2c_device_id *id)
12291264
{
@@ -1232,9 +1267,14 @@ static int elants_i2c_probe(struct i2c_client *client,
12321267
unsigned long irqflags;
12331268
int error;
12341269

1270+
/* Don't bind to i2c-hid compatible devices, these are handled by the i2c-hid drv. */
1271+
if (elants_acpi_is_hid_device(&client->dev)) {
1272+
dev_warn(&client->dev, "This device appears to be an I2C-HID device, not binding\n");
1273+
return -ENODEV;
1274+
}
1275+
12351276
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
1236-
dev_err(&client->dev,
1237-
"%s: i2c check functionality error\n", DEVICE_NAME);
1277+
dev_err(&client->dev, "I2C check functionality error\n");
12381278
return -ENXIO;
12391279
}
12401280

0 commit comments

Comments
 (0)