All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: elan_i2c - Optimize update speed for IC Type 0x19.
@ 2026-07-29  6:19 Jingle Wu 吳金國
  2026-08-13  0:42 ` Dmitry.torokhov@gmail.com
  0 siblings, 1 reply; 2+ messages in thread
From: Jingle Wu 吳金國 @ 2026-07-29  6:19 UTC (permalink / raw)
  To: Linux-kernel@vger.kernel.org, Linux-input@vger.kernel.org,
	Dmitry.torokhov@gmail.com

Reduce update time by optimizing the update sequence and removing unnecessary delays.

Signed-off-by: Jingle Wu mailto:jingle.wu@emc.com.tw
---
 drivers/input/mouse/elan_i2c.h       |  3 ++-
 drivers/input/mouse/elan_i2c_core.c  | 20 +++++++++++++++-----
 drivers/input/mouse/elan_i2c_i2c.c   |  5 +++--
 drivers/input/mouse/elan_i2c_smbus.c |  3 ++-
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 3c84deefa327..555824e57743 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -102,7 +102,8 @@ struct elan_transport_ops {
 	int (*prepare_fw_update)(struct i2c_client *client, u16 ic_type,
 				 u8 iap_version, u16 fw_page_size);
 	int (*write_fw_block)(struct i2c_client *client, u16 fw_page_size,
-			      const u8 *page, u16 checksum, int idx);
+			      u16 fw_page_delay, const u8 *page, u16 checksum,
+			      int idx);
 	int (*finish_fw_update)(struct i2c_client *client,
 				struct completion *reset_done);
 
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index f93dd545d66b..46421687fb35 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -86,6 +86,7 @@ struct elan_tp_data {
 	u16			ic_type;
 	u16			fw_validpage_count;
 	u16			fw_page_size;
+	u16			fw_page_delay;
 	u32			fw_signature_address;
 
 	u8			min_baseline;
@@ -127,8 +128,11 @@ static u32 elan_i2c_lookup_quirks(u16 ic_type, u16 product_id)
 }
 
 static int elan_get_fwinfo(u16 ic_type, u8 iap_version, u16 *validpage_count,
-			   u32 *signature_address, u16 *page_size)
+			   u32 *signature_address, u16 *page_size,
+			   u16 *page_delay)
 {
+	*page_delay = 30;
+
 	switch (ic_type) {
 	case 0x00:
 	case 0x06:
@@ -164,6 +168,7 @@ static int elan_get_fwinfo(u16 ic_type, u8 iap_version, u16 *validpage_count,
 		break;
 	case 0x19:
 		*validpage_count = 2032;
+		*page_delay = 10;
 		break;
 	default:
 		/* unknown ic type clear value */
@@ -179,6 +184,7 @@ static int elan_get_fwinfo(u16 ic_type, u8 iap_version, u16 *validpage_count,
 	if ((ic_type == 0x14 || ic_type == 0x15) && iap_version >= 2) {
 		*validpage_count /= 8;
 		*page_size = ETP_FW_PAGE_SIZE_512;
+		*page_delay = 50;
 	} else if (ic_type >= 0x0D && iap_version >= 1) {
 		*validpage_count /= 2;
 		*page_size = ETP_FW_PAGE_SIZE_128;
@@ -368,7 +374,8 @@ static int elan_query_device_info(struct elan_tp_data *data)
 	error = elan_get_fwinfo(data->ic_type, data->iap_version,
 				&data->fw_validpage_count,
 				&data->fw_signature_address,
-				&data->fw_page_size);
+				&data->fw_page_size,
+				&data->fw_page_delay);
 	if (error)
 		dev_warn(&data->client->dev,
 			 "unexpected iap version %#04x (ic type: %#04x), firmware update will not work\n",
@@ -479,14 +486,16 @@ static int elan_query_device_parameters(struct elan_tp_data *data)
  **********************************************************
  */
 static int elan_write_fw_block(struct elan_tp_data *data, u16 page_size,
-			       const u8 *page, u16 checksum, int idx)
+			       u16 page_delay, const u8 *page, u16 checksum,
+			       int idx)
 {
 	int retry = ETP_RETRY_COUNT;
 	int error;
 
 	do {
 		error = data->ops->write_fw_block(data->client, page_size,
-						  page, checksum, idx);
+						  page_delay, page, checksum,
+						  idx);
 		if (!error)
 			return 0;
 
@@ -525,7 +534,8 @@ static int __elan_update_firmware(struct elan_tp_data *data,
 			checksum += ((page[j + 1] << 8) | page[j]);
 
 		error = elan_write_fw_block(data, data->fw_page_size,
-					    page, checksum, i);
+					    data->fw_page_delay, page, checksum,
+					    i);
 		if (error) {
 			dev_err(dev, "write page %d fail: %d\n", i, error);
 			return error;
diff --git a/drivers/input/mouse/elan_i2c_i2c.c b/drivers/input/mouse/elan_i2c_i2c.c
index 88d4070d4b44..56a745c0555b 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -625,7 +625,8 @@ static int elan_i2c_prepare_fw_update(struct i2c_client *client, u16 ic_type,
 }
 
 static int elan_i2c_write_fw_block(struct i2c_client *client, u16 fw_page_size,
-				   const u8 *page, u16 checksum, int idx)
+				   u16 fw_page_delay, const u8 *page, u16 checksum,
+				   int idx)
 {
 	struct device *dev = &client->dev;
 	u8 val[3];
@@ -650,7 +651,7 @@ static int elan_i2c_write_fw_block(struct i2c_client *client, u16 fw_page_size,
 	}
 
 	/* Wait for F/W to update one page ROM data. */
-	msleep(fw_page_size == ETP_FW_PAGE_SIZE_512 ? 50 : 35);
+	msleep(fw_page_delay);
 
 	error = elan_i2c_read_cmd(client, ETP_I2C_IAP_CTRL_CMD, val);
 	if (error) {
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index 6dc148b9d959..0287441cda46 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -416,7 +416,8 @@ static int elan_smbus_prepare_fw_update(struct i2c_client *client, u16 ic_type,
 
 
 static int elan_smbus_write_fw_block(struct i2c_client *client, u16 fw_page_size,
-				     const u8 *page, u16 checksum, int idx)
+				     u16 fw_page_delay, const u8 *page, u16 checksum,
+				     int idx)
 {
 	struct device *dev = &client->dev;
 	int error;
-- 
2.34.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-13  0:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29  6:19 [PATCH] Input: elan_i2c - Optimize update speed for IC Type 0x19 Jingle Wu 吳金國
2026-08-13  0:42 ` Dmitry.torokhov@gmail.com

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.