Skip to contentSkip to conversation

Firmware loading option

PATCH In review Andrej Valek 4 participants 29 messages Oct 29, 2020 – Nov 23, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Firmware loading option

Add option to prevent firmware/configuration loading during each boot.

Andrej Valek (3):
Input: goodix - add option to disable firmware loading
dt-bindings: goodix
Input: atmel_mxt_ts - add option to disable firmware loading

 .../bindings/input/touchscreen/goodix.yaml      |  1 +
 drivers/input/touchscreen/atmel_mxt_ts.c        | 17 ++++++++++++++---
 drivers/input/touchscreen/goodix.c              |  4 +++-
 3 files changed, 18 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 Input: goodix - add option to disable firmware loading

Firmware file loadind for GT911 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.

---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +3 -1
index 02c75ea385e08..44336ecd2acdf 100644
@@ -941,7 +941,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	default:
 		if (ts->gpiod_int && ts->gpiod_rst) {
 			ts->reset_controller_at_probe = true;
-			ts->load_cfg_from_disk = true;
+			/* Prevent cfg loading for each start */
+			ts->load_cfg_from_disk = !device_property_read_bool(dev,
+						 "touchscreen-do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
Signature · 1 line
2.20.1
maintainer
#2 lore raw

Re: [PATCH 1/3] Input: goodix - add option to disable firmware loading

Hi Andrej,

Quoted 6 lines · Andrej Valek

Firmware file loadind for GT911 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.

I thought that Goodix was losing firmware loading at poweroff. Is this not the case with this model?

Adding Hans as he was working with this driver/code.

Quoted 24 lines
---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +3 -1
index 02c75ea385e08..44336ecd2acdf 100644
@@ -941,7 +941,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	default:
 		if (ts->gpiod_int && ts->gpiod_rst) {
 			ts->reset_controller_at_probe = true;
-			ts->load_cfg_from_disk = true;
+			/* Prevent cfg loading for each start */
+			ts->load_cfg_from_disk = !device_property_read_bool(dev,
+						 "touchscreen-do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
Signature · 1 line
2.20.1

Thanks.

Signature · 1 line
Dmitry
#3 lore raw

RE: [PATCH 1/3] Input: goodix - add option to disable firmware loading

Hello Dmitry,

No, I don't think so, that this is the case. Because, when I disabled the FW configuration loading device is working as well. To be honest, I don't need a new configuration for each boot 😊.

Regards,
Andrej

Quoted 44 lines

Hi Andrej,

Quoted 6 lines · Andrej Valek

Firmware file loadind for GT911 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.

I thought that Goodix was losing firmware loading at poweroff. Is this not the case with this model?

Adding Hans as he was working with this driver/code.

Quoted 23 lines
---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +3 -2
index 02c75ea385e08..44336ecd2acdf 100644
@@ -941,7 +941,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	default:
 		if (ts->gpiod_int && ts->gpiod_rst) {
 			ts->reset_controller_at_probe = true;
-			ts->load_cfg_from_disk = true;
+			/* Prevent cfg loading for each start */
+			ts->load_cfg_from_disk = !device_property_read_bool(dev,
+						 "touchscreen-do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
--
Quoted 2 lines

2.20.1

Thanks.

--
Dmitry

#4 lore raw

Re: [PATCH 1/3] Input: goodix - add option to disable firmware loading

In reply to Dmitry Torokhov

Hi,

Quoted 7 lines · Dmitry Torokhov

Hi Andrej,

Quoted 4 lines · Andrej Valek

Firmware file loadind for GT911 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.

Quoted 5 lines
Quoted 2 lines

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

I thought that Goodix was losing firmware loading at poweroff. Is this not the case with this model?

So first of all there are 2 sorts of firmware involved with the Goodix touchscreen controllers, the actual firmware and a block of config data for that firmware which I presume adjusts it for the specific (model of) the digitizer which is attached.

ATM the mainline Linux driver does not support models where the actual firmware itself needs to be loaded (because they only have RAM, so they come up without firmware).

I do have one model tablet with a ROM-less goodix touchpad controller, so if I ever find the time I might add support for loading the actual firmware.

So what we are talking about here is just loading the config data and I'm a bit surprised that this take so long.

Quoted 1 line

Adding Hans as he was working with this driver/code.

With all that said I have no objection to this change.

Regards,

Hans

Quoted 28 lines
Quoted 25 lines
---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +3 -1
index 02c75ea385e08..44336ecd2acdf 100644
@@ -941,7 +941,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	default:
 		if (ts->gpiod_int && ts->gpiod_rst) {
 			ts->reset_controller_at_probe = true;
-			ts->load_cfg_from_disk = true;
+			/* Prevent cfg loading for each start */
+			ts->load_cfg_from_disk = !device_property_read_bool(dev,
+						 "touchscreen-do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
Signature · 1 line
2.20.1

Thanks.

#5 lore raw

RE: [PATCH 1/3] Input: goodix - add option to disable firmware loading

Hi Hans,

I am not saying, that just configuration loading took such a long time. Thu full process including configuration and FW loading takes it.

Means that I would like to prevent this situation, but keep the old scenario as a default behavior.

Regards,
Andrej

Quoted 63 lines

Hi,

Quoted 2 lines · Dmitry Torokhov

Hi Andrej,

Quoted 9 lines · Andrej Valek
Quoted 6 lines

Firmware file loadind for GT911 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.

I thought that Goodix was losing firmware loading at poweroff. Is this not the case with this model?

So first of all there are 2 sorts of firmware involved with the Goodix touchscreen controllers, the actual firmware and a > block of config data for that firmware which I presume adjusts it for the specific (model of) the digitizer which is attached.

ATM the mainline Linux driver does not support models where the actual firmware itself needs to be loaded (because they only have RAM, so they come up without firmware).

I do have one model tablet with a ROM-less goodix touchpad controller, so if I ever find the time I might add support for loading the actual firmware.

So what we are talking about here is just loading the config data and I'm a bit surprised that this take so long.

Quoted 1 line

Adding Hans as he was working with this driver/code.

With all that said I have no objection to this change.

Regards,

Hans

Quoted 29 lines
Quoted 24 lines
---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +3 -2
index 02c75ea385e08..44336ecd2acdf 100644
@@ -941,7 +941,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	default:
 		if (ts->gpiod_int && ts->gpiod_rst) {
 			ts->reset_controller_at_probe = true;
-			ts->load_cfg_from_disk = true;
+			/* Prevent cfg loading for each start */
+			ts->load_cfg_from_disk = !device_property_read_bool(dev,
+						 "touchscreen-do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
--
Quoted 2 lines

2.20.1

Thanks.

maintainer
#6 lore raw

Re: [PATCH 1/3] Input: goodix - add option to disable firmware loading

In reply to Hans de Goede
Quoted 25 lines · Hans de Goede

Hi,

Quoted 7 lines · Dmitry Torokhov

Hi Andrej,

Quoted 4 lines · Andrej Valek

Firmware file loadind for GT911 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.

Quoted 5 lines
Quoted 2 lines

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

I thought that Goodix was losing firmware loading at poweroff. Is this not the case with this model?

So first of all there are 2 sorts of firmware involved with the Goodix touchscreen controllers, the actual firmware and a block of config data for that firmware which I presume adjusts it for the specific (model of) the digitizer which is attached.

ATM the mainline Linux driver does not support models where the actual firmware itself needs to be loaded (because they only have RAM, so they come up without firmware).

Quoted 6 lines

I do have one model tablet with a ROM-less goodix touchpad controller, so if I ever find the time I might add support for loading the actual firmware.

So what we are talking about here is just loading the config data and I'm a bit surprised that this take so long.

So I am still confused about this: is the config stored in RAM or NVRAM? I.e. do we actually need to re-load it every time on boot, or it supposed to be flashed only when it is changed (or lost)?

Thanks.

Signature · 1 line
Dmitry
#7 lore raw

Re: [PATCH 1/3] Input: goodix - add option to disable firmware loading

Hi,

Quoted 30 lines · Dmitry Torokhov
Quoted 29 lines · Hans de Goede

Hi,

Quoted 7 lines · Dmitry Torokhov

Hi Andrej,

Quoted 4 lines · Andrej Valek

Firmware file loadind for GT911 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.

Quoted 5 lines
Quoted 2 lines

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

I thought that Goodix was losing firmware loading at poweroff. Is this not the case with this model?

So first of all there are 2 sorts of firmware involved with the Goodix touchscreen controllers, the actual firmware and a block of config data for that firmware which I presume adjusts it for the specific (model of) the digitizer which is attached.

ATM the mainline Linux driver does not support models where the actual firmware itself needs to be loaded (because they only have RAM, so they come up without firmware).

I do have one model tablet with a ROM-less goodix touchpad controller, so if I ever find the time I might add support for loading the actual firmware.

Quoted 6 lines
Quoted 2 lines

So what we are talking about here is just loading the config data and I'm a bit surprised that this take so long.

So I am still confused about this: is the config stored in RAM or NVRAM? I.e. do we actually need to re-load it every time on boot, or it supposed to be flashed only when it is changed (or lost)?

I only know about these touchscreens on x86, where we have a BIOS muddling the waters.

We have seen devices which loose the config over suspend/resume, which suggests it is in RAM. I recently added a fix for these which saves the config at boot, which suggests that at least on the device model with the suspend/resume issue the config is loaded into the chip by the BIOS.

But I'm not sure that this is the case everywhere. Most other models likely have the config in NVRAM.

I guess this is the same as with the firmware, and it differs per model. I know for sure that their are RAM only models which need the firmware loaded at boot, these are mostly found on ARM devs, but I have one X86 devices (which currently does not work) which also has RAM only and thus needs Linux to load the firmware (which is not supported atm). These RAM only models, presumably also have only RAM for the config.

Regards,

Hans

#8 lore raw

PATCH v3 1/4 Input: goodix - add option to disable firmware loading

In reply to Andrej Valek

Firmware file loadind for GT911 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.

---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +3 -1
index 02c75ea385e08..52eb2ccb0de9a 100644
@@ -941,7 +941,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	default:
 		if (ts->gpiod_int && ts->gpiod_rst) {
 			ts->reset_controller_at_probe = true;
-			ts->load_cfg_from_disk = true;
+			/* Prevent cfg loading for each start */
+			ts->load_cfg_from_disk = !device_property_read_bool(dev,
+						 "goodix,do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
Signature · 1 line
2.20.1
#9 lore raw

PATCH v4 1/4 Input: goodix - add option to disable firmware loading

In reply to Andrej Valek

Firmware file loadind for GT911 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.

---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +3 -1
index 02c75ea385e08..52eb2ccb0de9a 100644
@@ -941,7 +941,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	default:
 		if (ts->gpiod_int && ts->gpiod_rst) {
 			ts->reset_controller_at_probe = true;
-			ts->load_cfg_from_disk = true;
+			/* Prevent cfg loading for each start */
+			ts->load_cfg_from_disk = !device_property_read_bool(dev,
+						 "goodix,do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
Signature · 1 line
2.20.1
#10 lore raw

PATCH 2/3 dt-bindings: goodix

In reply to Andrej Valek

Add information about option how to disable FW loading for each boot.

---
 Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +1 -0
index da5b0d87e16d0..e7d9404c86abf 100644
@@ -53,6 +53,7 @@ properties:
   touchscreen-size-x: true
   touchscreen-size-y: true
   touchscreen-swapped-x-y: true
+  touchscreen-do-not-load-fw: false
 
 additionalProperties: false
 
Signature · 1 line
2.20.1
maintainer
#11 lore raw

Re: [PATCH 2/3] dt-bindings: goodix

Quoted 1 line · Andrej Valek

Add information about option how to disable FW loading for each boot.

Please fix your subject.

Quoted 11 lines
---
 Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +0 -0
index da5b0d87e16d0..e7d9404c86abf 100644

Documentation/devicetree/bindings/input/touchscreen/goodix.yaml properties: · line 56

Quoted 4 lines
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +1 -0
@@ -53,6 +53,7 @@ properties:
   touchscreen-size-x: true
   touchscreen-size-y: true
   touchscreen-swapped-x-y: true
+  touchscreen-do-not-load-fw: false

This is not a generic touchscreen property. It needs a vendor prefix.

Quoted 6 lines
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +0 -0
 additionalProperties: false
 
Signature · 1 line
2.20.1
#12 lore raw

PATCH v3 2/4 dt-bindings: touchscreen: goodix: add info about disabling FW loading

In reply to Andrej Valek

Add information about option how to disable FW loading for each boot.

---
 Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +1 -0
index da5b0d87e16d0..b61e019ff1a0b 100644
@@ -53,6 +53,7 @@ properties:
   touchscreen-size-x: true
   touchscreen-size-y: true
   touchscreen-swapped-x-y: true
+  goodix,do-not-load-fw: false
 
 additionalProperties: false
 
Signature · 1 line
2.20.1
maintainer
#13 lore raw

Re: [PATCH v3 2/4] dt-bindings: touchscreen: goodix: add info about disabling FW loading

Quoted 7 lines · Andrej Valek

Add information about option how to disable FW loading for each boot.

---
 Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 1 +
 1 file changed, 1 insertion(+)

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml: properties:goodix,do-not-load-fw: False is not of type 'object' /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml: ignoring, error in schema: properties: goodix,do-not-load-fw
warning: no schema found in file: ./Documentation/devicetree/bindings/input/touchscreen/goodix.yaml

See https://patchwork.ozlabs.org/patch/1397438

The base for the patch is generally the last rc1. Any dependencies should be noted.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#14 lore raw

PATCH v4 2/4 dt-bindings: touchscreen: goodix: add info about disabling FW loading

In reply to Andrej Valek

Add information about option how to disable FW loading for each boot.

---
 .../devicetree/bindings/input/touchscreen/goodix.yaml         | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +4 -0
index da5b0d87e16d0..379ef69a54d31 100644
@@ -54,6 +54,10 @@ properties:
   touchscreen-size-y: true
   touchscreen-swapped-x-y: true
 
+  goodix,do-not-load-fw:
+    description: Disable FW/CFG loading
+    type: boolean
+
 additionalProperties: false
 
 required:
Signature · 1 line
2.20.1
maintainer Acked-by on v4 2/4
#15 lore raw

Re: [PATCH v4 2/4] dt-bindings: touchscreen: goodix: add info about disabling FW loading

Quoted 7 lines · Andrej Valek

Add information about option how to disable FW loading for each boot.

---
 .../devicetree/bindings/input/touchscreen/goodix.yaml         | 4 ++++
 1 file changed, 4 insertions(+)
#16 lore raw

PATCH 3/3 Input: atmel_mxt_ts - add option to disable firmware loading

In reply to Andrej Valek

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.

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +14 -3
index 98f17fa3a8926..4656aaf532777 100644
@@ -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,
+						"touchscreen-do-not-load-fw");
+
 	error = mxt_initialize(data);
 	if (error)
 		return error;
Signature · 1 line
2.20.1
#17 lore raw

PATCH v3 3/4 Input: atmel_mxt_ts - add option to disable firmware loading

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.

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +14 -3
index 98f17fa3a8926..491d5088d2826 100644
@@ -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;
Signature · 1 line
2.20.1
#18 lore raw

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

In reply to Andrej Valek

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.

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +14 -3
index 98f17fa3a8926..491d5088d2826 100644
@@ -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;
Signature · 1 line
2.20.1
maintainer
#19 lore raw

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

Hi Andrej,

Quoted 6 lines · Andrej Valek

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.

Automatically updating firmware and config on driver probe was a mistake, and I am planning on removing the code altogether and expect userspace to determine if flashing is needed and request it explicitly, so this option is not really needed.

Thanks.

Signature · 1 line
Dmitry
#20 lore raw

PATCH v2 1/3 Input: st1232 - add support resolution reading

In reply to Andrej Valek

Hard-coding resolution for st1633 device was wrong. Some of LCDs like YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But the resolution is not 320x480 as was hard-coded.
Add new function which reads correct resolution directly from register.

---
 drivers/input/touchscreen/st1232.c | 52 +++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 16 deletions(-)
drivers/input/touchscreen/st1232.c +36 -16
index 63b29c7279e2..1b4b139c8533 100644
@@ -26,15 +26,14 @@
 #define ST1232_TS_NAME	"st1232-ts"
 #define ST1633_TS_NAME	"st1633-ts"
 
+#define REG_XY_RESOLUTION	0x04
+#define REG_XY_COORDINATES	0x12
 #define ST_TS_MAX_FINGERS	10
 
 struct st_chip_info {
 	bool	have_z;
-	u16	max_x;
-	u16	max_y;
 	u16	max_area;
 	u16	max_fingers;
-	u8	start_reg;
 };
 
 struct st1232_ts_data {
@@ -48,15 +47,14 @@ struct st1232_ts_data {
 	u8 *read_buf;
 };
 
-static int st1232_ts_read_data(struct st1232_ts_data *ts)
+static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
 {
 	struct i2c_client *client = ts->client;
-	u8 start_reg = ts->chip_info->start_reg;
 	struct i2c_msg msg[] = {
 		{
 			.addr	= client->addr,
-			.len	= sizeof(start_reg),
-			.buf	= &start_reg,
+			.len	= sizeof(reg),
+			.buf	= &reg,
 		},
 		{
 			.addr	= client->addr,
@@ -74,6 +72,25 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts)
 	return 0;
 }
 
+static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
+				     u16 *max_y)
+{
+	u8 *buf;
+	int error;
+
+	/* select resolution register */
+	error = st1232_ts_read_data(ts, REG_XY_RESOLUTION);
+	if (error)
+		return error;
+
+	buf = ts->read_buf;
+
+	*max_x = ((buf[0] & 0x0070) << 4) | buf[1];
+	*max_y = ((buf[0] & 0x0007) << 8) | buf[2];
+
+	return 0;
+}
+
 static int st1232_ts_parse_and_report(struct st1232_ts_data *ts)
 {
 	struct input_dev *input = ts->input_dev;
@@ -123,7 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
 	int count;
 	int error;
 
-	error = st1232_ts_read_data(ts);
+	error = st1232_ts_read_data(ts, REG_XY_COORDINATES);
 	if (error)
 		goto out;
 
@@ -157,20 +174,14 @@ static void st1232_ts_power_off(void *data)
 
 static const struct st_chip_info st1232_chip_info = {
 	.have_z		= true,
-	.max_x		= 0x31f, /* 800 - 1 */
-	.max_y		= 0x1df, /* 480 -1 */
 	.max_area	= 0xff,
 	.max_fingers	= 2,
-	.start_reg	= 0x12,
 };
 
 static const struct st_chip_info st1633_chip_info = {
 	.have_z		= false,
-	.max_x		= 0x13f, /* 320 - 1 */
-	.max_y		= 0x1df, /* 480 -1 */
 	.max_area	= 0x00,
 	.max_fingers	= 5,
-	.start_reg	= 0x12,
 };
 
 static int st1232_ts_probe(struct i2c_client *client,
@@ -179,6 +190,7 @@ static int st1232_ts_probe(struct i2c_client *client,
 	const struct st_chip_info *match;
 	struct st1232_ts_data *ts;
 	struct input_dev *input_dev;
+	u16 max_x, max_y;
 	int error;
 
 	match = device_get_match_data(&client->dev);
@@ -239,14 +251,22 @@ static int st1232_ts_probe(struct i2c_client *client,
 	input_dev->name = "st1232-touchscreen";
 	input_dev->id.bustype = BUS_I2C;
 
+	/* read resolution from chip */
+	error = st1232_ts_read_resolution(ts, &max_x, &max_y);
+	if (error) {
+		dev_err(&client->dev,
+			"Failed to read resolution: %d\n", error);
+		return error;
+	}
+
 	if (ts->chip_info->have_z)
 		input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
 				     ts->chip_info->max_area, 0, 0);
 
 	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
-			     0, ts->chip_info->max_x, 0, 0);
+			     0, max_x, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
-			     0, ts->chip_info->max_y, 0, 0);
+			     0, max_y, 0, 0);
 
 	touchscreen_parse_properties(input_dev, true, &ts->prop);
 
Signature · 1 line
2.20.1
#21 lore raw

PATCH v3 4/4 Input: st1232 - add support resolution reading

Hard-coding resolution for st1633 device was wrong. Some of LCDs like YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But the resolution is not 320x480 as was hard-coded.
Add new function which reads correct resolution directly from register.

---
 drivers/input/touchscreen/st1232.c | 52 +++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 16 deletions(-)
drivers/input/touchscreen/st1232.c +36 -16
index 63b29c7279e29..1b4b139c85330 100644
@@ -26,15 +26,14 @@
 #define ST1232_TS_NAME	"st1232-ts"
 #define ST1633_TS_NAME	"st1633-ts"
 
+#define REG_XY_RESOLUTION	0x04
+#define REG_XY_COORDINATES	0x12
 #define ST_TS_MAX_FINGERS	10
 
 struct st_chip_info {
 	bool	have_z;
-	u16	max_x;
-	u16	max_y;
 	u16	max_area;
 	u16	max_fingers;
-	u8	start_reg;
 };
 
 struct st1232_ts_data {
@@ -48,15 +47,14 @@ struct st1232_ts_data {
 	u8 *read_buf;
 };
 
-static int st1232_ts_read_data(struct st1232_ts_data *ts)
+static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
 {
 	struct i2c_client *client = ts->client;
-	u8 start_reg = ts->chip_info->start_reg;
 	struct i2c_msg msg[] = {
 		{
 			.addr	= client->addr,
-			.len	= sizeof(start_reg),
-			.buf	= &start_reg,
+			.len	= sizeof(reg),
+			.buf	= &reg,
 		},
 		{
 			.addr	= client->addr,
@@ -74,6 +72,25 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts)
 	return 0;
 }
 
+static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
+				     u16 *max_y)
+{
+	u8 *buf;
+	int error;
+
+	/* select resolution register */
+	error = st1232_ts_read_data(ts, REG_XY_RESOLUTION);
+	if (error)
+		return error;
+
+	buf = ts->read_buf;
+
+	*max_x = ((buf[0] & 0x0070) << 4) | buf[1];
+	*max_y = ((buf[0] & 0x0007) << 8) | buf[2];
+
+	return 0;
+}
+
 static int st1232_ts_parse_and_report(struct st1232_ts_data *ts)
 {
 	struct input_dev *input = ts->input_dev;
@@ -123,7 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
 	int count;
 	int error;
 
-	error = st1232_ts_read_data(ts);
+	error = st1232_ts_read_data(ts, REG_XY_COORDINATES);
 	if (error)
 		goto out;
 
@@ -157,20 +174,14 @@ static void st1232_ts_power_off(void *data)
 
 static const struct st_chip_info st1232_chip_info = {
 	.have_z		= true,
-	.max_x		= 0x31f, /* 800 - 1 */
-	.max_y		= 0x1df, /* 480 -1 */
 	.max_area	= 0xff,
 	.max_fingers	= 2,
-	.start_reg	= 0x12,
 };
 
 static const struct st_chip_info st1633_chip_info = {
 	.have_z		= false,
-	.max_x		= 0x13f, /* 320 - 1 */
-	.max_y		= 0x1df, /* 480 -1 */
 	.max_area	= 0x00,
 	.max_fingers	= 5,
-	.start_reg	= 0x12,
 };
 
 static int st1232_ts_probe(struct i2c_client *client,
@@ -179,6 +190,7 @@ static int st1232_ts_probe(struct i2c_client *client,
 	const struct st_chip_info *match;
 	struct st1232_ts_data *ts;
 	struct input_dev *input_dev;
+	u16 max_x, max_y;
 	int error;
 
 	match = device_get_match_data(&client->dev);
@@ -239,14 +251,22 @@ static int st1232_ts_probe(struct i2c_client *client,
 	input_dev->name = "st1232-touchscreen";
 	input_dev->id.bustype = BUS_I2C;
 
+	/* read resolution from chip */
+	error = st1232_ts_read_resolution(ts, &max_x, &max_y);
+	if (error) {
+		dev_err(&client->dev,
+			"Failed to read resolution: %d\n", error);
+		return error;
+	}
+
 	if (ts->chip_info->have_z)
 		input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
 				     ts->chip_info->max_area, 0, 0);
 
 	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
-			     0, ts->chip_info->max_x, 0, 0);
+			     0, max_x, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
-			     0, ts->chip_info->max_y, 0, 0);
+			     0, max_y, 0, 0);
 
 	touchscreen_parse_properties(input_dev, true, &ts->prop);
 
Signature · 1 line
2.20.1
#22 lore raw

PATCH v4 4/4 Input: st1232 - add support resolution reading

In reply to Andrej Valek

Hard-coding resolution for st1633 device was wrong. Some of LCDs like YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But the resolution is not 320x480 as was hard-coded.
Add new function which reads correct resolution directly from register.

---
 drivers/input/touchscreen/st1232.c | 52 +++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 16 deletions(-)
drivers/input/touchscreen/st1232.c +36 -16
index 63b29c7279e29..1b4b139c85330 100644
@@ -26,15 +26,14 @@
 #define ST1232_TS_NAME	"st1232-ts"
 #define ST1633_TS_NAME	"st1633-ts"
 
+#define REG_XY_RESOLUTION	0x04
+#define REG_XY_COORDINATES	0x12
 #define ST_TS_MAX_FINGERS	10
 
 struct st_chip_info {
 	bool	have_z;
-	u16	max_x;
-	u16	max_y;
 	u16	max_area;
 	u16	max_fingers;
-	u8	start_reg;
 };
 
 struct st1232_ts_data {
@@ -48,15 +47,14 @@ struct st1232_ts_data {
 	u8 *read_buf;
 };
 
-static int st1232_ts_read_data(struct st1232_ts_data *ts)
+static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
 {
 	struct i2c_client *client = ts->client;
-	u8 start_reg = ts->chip_info->start_reg;
 	struct i2c_msg msg[] = {
 		{
 			.addr	= client->addr,
-			.len	= sizeof(start_reg),
-			.buf	= &start_reg,
+			.len	= sizeof(reg),
+			.buf	= &reg,
 		},
 		{
 			.addr	= client->addr,
@@ -74,6 +72,25 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts)
 	return 0;
 }
 
+static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
+				     u16 *max_y)
+{
+	u8 *buf;
+	int error;
+
+	/* select resolution register */
+	error = st1232_ts_read_data(ts, REG_XY_RESOLUTION);
+	if (error)
+		return error;
+
+	buf = ts->read_buf;
+
+	*max_x = ((buf[0] & 0x0070) << 4) | buf[1];
+	*max_y = ((buf[0] & 0x0007) << 8) | buf[2];
+
+	return 0;
+}
+
 static int st1232_ts_parse_and_report(struct st1232_ts_data *ts)
 {
 	struct input_dev *input = ts->input_dev;
@@ -123,7 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
 	int count;
 	int error;
 
-	error = st1232_ts_read_data(ts);
+	error = st1232_ts_read_data(ts, REG_XY_COORDINATES);
 	if (error)
 		goto out;
 
@@ -157,20 +174,14 @@ static void st1232_ts_power_off(void *data)
 
 static const struct st_chip_info st1232_chip_info = {
 	.have_z		= true,
-	.max_x		= 0x31f, /* 800 - 1 */
-	.max_y		= 0x1df, /* 480 -1 */
 	.max_area	= 0xff,
 	.max_fingers	= 2,
-	.start_reg	= 0x12,
 };
 
 static const struct st_chip_info st1633_chip_info = {
 	.have_z		= false,
-	.max_x		= 0x13f, /* 320 - 1 */
-	.max_y		= 0x1df, /* 480 -1 */
 	.max_area	= 0x00,
 	.max_fingers	= 5,
-	.start_reg	= 0x12,
 };
 
 static int st1232_ts_probe(struct i2c_client *client,
@@ -179,6 +190,7 @@ static int st1232_ts_probe(struct i2c_client *client,
 	const struct st_chip_info *match;
 	struct st1232_ts_data *ts;
 	struct input_dev *input_dev;
+	u16 max_x, max_y;
 	int error;
 
 	match = device_get_match_data(&client->dev);
@@ -239,14 +251,22 @@ static int st1232_ts_probe(struct i2c_client *client,
 	input_dev->name = "st1232-touchscreen";
 	input_dev->id.bustype = BUS_I2C;
 
+	/* read resolution from chip */
+	error = st1232_ts_read_resolution(ts, &max_x, &max_y);
+	if (error) {
+		dev_err(&client->dev,
+			"Failed to read resolution: %d\n", error);
+		return error;
+	}
+
 	if (ts->chip_info->have_z)
 		input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
 				     ts->chip_info->max_area, 0, 0);
 
 	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
-			     0, ts->chip_info->max_x, 0, 0);
+			     0, max_x, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
-			     0, ts->chip_info->max_y, 0, 0);
+			     0, max_y, 0, 0);
 
 	touchscreen_parse_properties(input_dev, true, &ts->prop);
 
Signature · 1 line
2.20.1
#23 lore raw

v2 cover Firmware loading option

In reply to Andrej Valek

Add option to prevent firmware/configuration loading during each boot.

Andrej Valek (3):
Input: st1232 - add support resolution reading
dt-bindings: goodix
Input: goodix - add option to disable firmware loading

 .../bindings/input/touchscreen/goodix.yaml    |  2 +-
 drivers/input/touchscreen/goodix.c            |  2 +-
 drivers/input/touchscreen/st1232.c            | 52 +++++++++++++------
 3 files changed, 38 insertions(+), 18 deletions(-)
Signature · 1 line
2.20.1
#24 lore raw

PATCH v2 2/3 dt-bindings: goodix

In reply to Andrej Valek

Add information about option how to disable FW loading for each boot.

---
 Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +1 -1
index e7d9404c86ab..8b0fa25ae96e 100644
@@ -53,7 +53,7 @@ properties:
   touchscreen-size-x: true
   touchscreen-size-y: true
   touchscreen-swapped-x-y: true
-  touchscreen-do-not-load-fw: false
+  goodix-do-not-load-fw: false
 
 additionalProperties: false
 
Signature · 1 line
2.20.1
maintainer
#25 lore raw

Re: [PATCH v2 2/3] dt-bindings: goodix

Quoted 1 line · Andrej Valek

Add information about option how to disable FW loading for each boot.

Again, fix your subject.

Quoted 11 lines
---
 Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +0 -0
index e7d9404c86ab..8b0fa25ae96e 100644

Documentation/devicetree/bindings/input/touchscreen/goodix.yaml properties: · line 56

Quoted 5 lines
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +1 -1
@@ -53,7 +53,7 @@ properties:
   touchscreen-size-x: true
   touchscreen-size-y: true
   touchscreen-swapped-x-y: true
-  touchscreen-do-not-load-fw: false
+  goodix-do-not-load-fw: false

Why is this incremental on v1?

And that's not how vendor prefixes on properties work.

#26 lore raw

PATCH v2 3/3 Input: goodix - add option to disable firmware loading

In reply to Andrej Valek

Firmware file loadind for GT911 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.

---
 drivers/input/touchscreen/goodix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/goodix.c +1 -1
index 44336ecd2acd..41f8eb8963b1 100644
@@ -943,7 +943,7 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 			ts->reset_controller_at_probe = true;
 			/* Prevent cfg loading for each start */
 			ts->load_cfg_from_disk = !device_property_read_bool(dev,
-						 "touchscreen-do-not-load-fw");
+						 "goodix-do-not-load-fw");
 			ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO;
 		}
 	}
Signature · 1 line
2.20.1
#27 lore raw

v3 cover Firmware loading option

In reply to Andrej Valek

Add option to prevent firmware/configuration loading during each boot.

Andrej Valek (4):
Input: goodix - add option to disable firmware loading
dt-bindings: touchscreen: goodix: add info about disabling FW loading
Input: atmel_mxt_ts - add option to disable firmware loading
Input: st1232 - add support resolution reading

 .../bindings/input/touchscreen/goodix.yaml    |  1 +
 drivers/input/touchscreen/atmel_mxt_ts.c      | 17 ++++--
 drivers/input/touchscreen/goodix.c            |  4 +-
 drivers/input/touchscreen/st1232.c            | 52 +++++++++++++------
 4 files changed, 54 insertions(+), 20 deletions(-)
Signature · 1 line
2.20.1
#28 lore raw

v4 cover Firmware loading option

In reply to Andrej Valek

Add option to prevent firmware/configuration loading during each boot.

Andrej Valek (4):
Input: goodix - add option to disable firmware loading
dt-bindings: touchscreen: goodix: add info about disabling FW loading
Input: atmel_mxt_ts - add option to disable firmware loading
Input: st1232 - add support resolution reading

 .../bindings/input/touchscreen/goodix.yaml    |  4 ++
 drivers/input/touchscreen/atmel_mxt_ts.c      | 17 ++++--
 drivers/input/touchscreen/goodix.c            |  4 +-
 drivers/input/touchscreen/st1232.c            | 52 +++++++++++++------
 4 files changed, 57 insertions(+), 20 deletions(-)
Signature · 1 line
2.20.1