[PATCH v4 3/4] Input: atmel_mxt_ts - add option to disable firmware loading

From: Andrej Valek
Date: Tue Nov 10 2020 - 13:16:38 EST


Firmware file loadind for mXT336U controller takes too much time (~60s).
There is no check that configuration is the same which is already present.
This happens always during boot, which makes touchscreen unusable.

Add there an option to prevent firmware file loading, but keep it enabled
by default.

Signed-off-by: Andrej Valek <andrej.valek@xxxxxxxxxxx>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 98f17fa3a8926..491d5088d2826 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -311,6 +311,7 @@ struct mxt_data {
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
bool use_retrigen_workaround;
+ bool cfg_loading_disabled;

/* Cached parameters from object table */
u16 T5_address;
@@ -2191,9 +2192,15 @@ static int mxt_initialize(struct mxt_data *data)
if (error)
return error;

- error = request_firmware_nowait(THIS_MODULE, true, MXT_CFG_NAME,
- &client->dev, GFP_KERNEL, data,
- mxt_config_cb);
+ /* Load firmware if enabled */
+ if (!data->cfg_loading_disabled) {
+ error = request_firmware_nowait(THIS_MODULE, true, MXT_CFG_NAME,
+ &client->dev, GFP_KERNEL, data,
+ mxt_config_cb);
+ } else {
+ mxt_config_cb(NULL, data);
+ }
+
if (error) {
dev_err(&client->dev, "Failed to invoke firmware loader: %d\n",
error);
@@ -3158,6 +3165,10 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
msleep(MXT_RESET_INVALID_CHG);
}

+ /* prevent firmware flashing for each start */
+ data->cfg_loading_disabled = device_property_read_bool(&client->dev,
+ "atmel,do-not-load-fw");
+
error = mxt_initialize(data);
if (error)
return error;
--
2.20.1