Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: silead - add workaround for x86 BIOS-es which bring the chip up in a stuck state

Some buggy BIOS-es bring up the touchscreen-controller in a stuck
state where it blocks the I2C bus. Specifically this happens on
the Jumper EZpad 7 tablet model.

After much poking at this problem I have found that the following steps
are necessary to unstuck the chip / bus:

1. Turn off the Silead chip.
2. Try to do an I2C transfer with the chip, this will fail in response to
which the I2C-bus-driver will call: i2c_recover_bus() which will unstuck
the I2C-bus. Note the unstuck-ing of the I2C bus only works if we first
drop the chip of the bus by turning it off.
3. Turn the chip back on.

On the x86/ACPI systems were this problem is seen, step 1. and 3. require
making ACPI calls and dealing with ACPI Power Resources. This commit adds
a workaround which runtime-suspends the chip to turn it off, leaving it up
to the ACPI subsystem to deal with all the ACPI specific details.

There is no good way to detect this bug, so the workaround gets activated
by a new "silead,stuck-controller-bug" boolean device-property. Since this
is only used on x86/ACPI, this will be set by model specific device-props
set by drivers/platform/x86/touchscreen_dmi.c. Therefor this new
device-property is not documented in the DT-bindings.

Dmesg will contain the following messages on systems where the workaround
is activated:

[ 54.309029] silead_ts i2c-MSSL1680:00: [Firmware Bug]: Stuck I2C bus: please ignore the next 'controller timed out' error
[ 55.373593] i2c_designware 808622C1:04: controller timed out
[ 55.582186] silead_ts i2c-MSSL1680:00: Silead chip ID: 0x80360000

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210405202745.16777-1-hdegoede@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Hans de Goede and committed by
Dmitry Torokhov
e4791877 65299e8b

+40 -4
+40 -4
drivers/input/touchscreen/silead.c
··· 20 20 #include <linux/input/mt.h> 21 21 #include <linux/input/touchscreen.h> 22 22 #include <linux/pm.h> 23 + #include <linux/pm_runtime.h> 23 24 #include <linux/irq.h> 24 25 #include <linux/regulator/consumer.h> 25 26 ··· 336 335 337 336 error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_ID, 338 337 sizeof(chip_id), (u8 *)&chip_id); 339 - if (error < 0) { 340 - dev_err(&client->dev, "Chip ID read error %d\n", error); 338 + if (error < 0) 341 339 return error; 342 - } 343 340 344 341 data->chip_id = le32_to_cpu(chip_id); 345 342 dev_info(&client->dev, "Silead chip ID: 0x%8X", data->chip_id); ··· 350 351 int error; 351 352 u32 status; 352 353 354 + /* 355 + * Some buggy BIOS-es bring up the chip in a stuck state where it 356 + * blocks the I2C bus. The following steps are necessary to 357 + * unstuck the chip / bus: 358 + * 1. Turn off the Silead chip. 359 + * 2. Try to do an I2C transfer with the chip, this will fail in 360 + * response to which the I2C-bus-driver will call: 361 + * i2c_recover_bus() which will unstuck the I2C-bus. Note the 362 + * unstuck-ing of the I2C bus only works if we first drop the 363 + * chip off the bus by turning it off. 364 + * 3. Turn the chip back on. 365 + * 366 + * On the x86/ACPI systems were this problem is seen, step 1. and 367 + * 3. require making ACPI calls and dealing with ACPI Power 368 + * Resources. The workaround below runtime-suspends the chip to 369 + * turn it off, leaving it up to the ACPI subsystem to deal with 370 + * this. 371 + */ 372 + 373 + if (device_property_read_bool(&client->dev, 374 + "silead,stuck-controller-bug")) { 375 + pm_runtime_set_active(&client->dev); 376 + pm_runtime_enable(&client->dev); 377 + pm_runtime_allow(&client->dev); 378 + 379 + pm_runtime_suspend(&client->dev); 380 + 381 + dev_warn(&client->dev, FW_BUG "Stuck I2C bus: please ignore the next 'controller timed out' error\n"); 382 + silead_ts_get_id(client); 383 + 384 + /* The forbid will also resume the device */ 385 + pm_runtime_forbid(&client->dev); 386 + pm_runtime_disable(&client->dev); 387 + } 388 + 353 389 silead_ts_set_power(client, SILEAD_POWER_OFF); 354 390 silead_ts_set_power(client, SILEAD_POWER_ON); 355 391 356 392 error = silead_ts_get_id(client); 357 - if (error) 393 + if (error) { 394 + dev_err(&client->dev, "Chip ID read error %d\n", error); 358 395 return error; 396 + } 359 397 360 398 error = silead_ts_init(client); 361 399 if (error)