Skip to content

Commit e1141b0

Browse files
Marek Vasutdtor
authored andcommitted
Input: ili210x - probe even if no resolution information
Probe the touch controller driver even if resolution information is not available. This can happen e.g. in case the touch controller suffered a failed firmware update and is stuck in bootloader mode. Signed-off-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20230217025200.203833-1-marex@denx.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 5672bd3 commit e1141b0

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

drivers/input/touchscreen/ili210x.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,33 @@ static int ili251x_firmware_update_resolution(struct device *dev)
370370

371371
/* The firmware update blob might have changed the resolution. */
372372
error = priv->chip->read_reg(client, REG_PANEL_INFO, &rs, sizeof(rs));
373-
if (error)
374-
return error;
373+
if (!error) {
374+
resx = le16_to_cpup((__le16 *)rs);
375+
resy = le16_to_cpup((__le16 *)(rs + 2));
375376

376-
resx = le16_to_cpup((__le16 *)rs);
377-
resy = le16_to_cpup((__le16 *)(rs + 2));
377+
/* The value reported by the firmware is invalid. */
378+
if (!resx || resx == 0xffff || !resy || resy == 0xffff)
379+
error = -EINVAL;
380+
}
378381

379-
/* The value reported by the firmware is invalid. */
380-
if (!resx || resx == 0xffff || !resy || resy == 0xffff)
381-
return -EINVAL;
382+
/*
383+
* In case of error, the firmware might be stuck in bootloader mode,
384+
* e.g. after a failed firmware update. Set maximum resolution, but
385+
* do not fail to probe, so the user can re-trigger the firmware
386+
* update and recover the touch controller.
387+
*/
388+
if (error) {
389+
dev_warn(dev, "Invalid resolution reported by controller.\n");
390+
resx = 16384;
391+
resy = 16384;
392+
}
382393

383394
input_abs_set_max(priv->input, ABS_X, resx - 1);
384395
input_abs_set_max(priv->input, ABS_Y, resy - 1);
385396
input_abs_set_max(priv->input, ABS_MT_POSITION_X, resx - 1);
386397
input_abs_set_max(priv->input, ABS_MT_POSITION_Y, resy - 1);
387398

388-
return 0;
399+
return error;
389400
}
390401

391402
static ssize_t ili251x_firmware_update_firmware_version(struct device *dev)
@@ -977,11 +988,10 @@ static int ili210x_i2c_probe(struct i2c_client *client)
977988
if (priv->chip->has_pressure_reg)
978989
input_set_abs_params(input, ABS_MT_PRESSURE, 0, 0xa, 0, 0);
979990
error = ili251x_firmware_update_cached_state(dev);
980-
if (error) {
981-
dev_err(dev, "Unable to cache firmware information, err: %d\n",
982-
error);
983-
return error;
984-
}
991+
if (error)
992+
dev_warn(dev, "Unable to cache firmware information, err: %d\n",
993+
error);
994+
985995
touchscreen_parse_properties(input, true, &priv->prop);
986996

987997
error = input_mt_init_slots(input, priv->chip->max_touches,

0 commit comments

Comments
 (0)