Skip to content

Commit 273ec6b

Browse files
jwrdegoededtor
authored andcommitted
Input: goodix - restore config on resume if necessary
Some devices, e.g the Trekstor Primetab S11B, lose there config over a suspend/resume cycle (likely the controller loses power during suspend). This commit reads back the config version on resume and if matches the expected config version it resets the controller and resends the config we read back and saved at probe time. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1786317 BugLink: nexus511/gpd-ubuntu-packages#10 BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199207 Reviewed-by: Bastien Nocera <[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]>
1 parent 1a67448 commit 273ec6b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/input/touchscreen/goodix.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ static int __maybe_unused goodix_resume(struct device *dev)
12681268
{
12691269
struct i2c_client *client = to_i2c_client(dev);
12701270
struct goodix_ts_data *ts = i2c_get_clientdata(client);
1271+
u8 config_ver;
12711272
int error;
12721273

12731274
if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) {
@@ -1289,6 +1290,27 @@ static int __maybe_unused goodix_resume(struct device *dev)
12891290
if (error)
12901291
return error;
12911292

1293+
error = goodix_i2c_read(ts->client, ts->chip->config_addr,
1294+
&config_ver, 1);
1295+
if (error)
1296+
dev_warn(dev, "Error reading config version: %d, resetting controller\n",
1297+
error);
1298+
else if (config_ver != ts->config[0])
1299+
dev_info(dev, "Config version mismatch %d != %d, resetting controller\n",
1300+
config_ver, ts->config[0]);
1301+
1302+
if (error != 0 || config_ver != ts->config[0]) {
1303+
error = goodix_reset(ts);
1304+
if (error) {
1305+
dev_err(dev, "Controller reset failed.\n");
1306+
return error;
1307+
}
1308+
1309+
error = goodix_send_cfg(ts, ts->config, ts->chip->config_len);
1310+
if (error)
1311+
return error;
1312+
}
1313+
12921314
error = goodix_request_irq(ts);
12931315
if (error)
12941316
return error;

0 commit comments

Comments
 (0)