hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/input/mouse/elan_i2c_smbus.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Elan I2C/SMBus Touchpad driver - SMBus interface
34 *
....@@ -8,10 +9,6 @@
89 * Based on cyapa driver:
910 * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
1011 * copyright (c) 2011-2012 Google, Inc.
11
- *
12
- * This program is free software; you can redistribute it and/or modify it
13
- * under the terms of the GNU General Public License version 2 as published
14
- * by the Free Software Foundation.
1512 *
1613 * Trademarks are the property of their respective owners.
1714 */
....@@ -48,6 +45,7 @@
4845 #define ETP_SMBUS_CALIBRATE_QUERY 0xC5
4946
5047 #define ETP_SMBUS_REPORT_LEN 32
48
+#define ETP_SMBUS_REPORT_LEN2 7
5149 #define ETP_SMBUS_REPORT_OFFSET 2
5250 #define ETP_SMBUS_HELLOPACKET_LEN 5
5351 #define ETP_SMBUS_IAP_PASSWORD 0x1234
....@@ -150,7 +148,7 @@
150148 }
151149
152150 static int elan_smbus_get_version(struct i2c_client *client,
153
- bool iap, u8 *version)
151
+ u8 pattern, bool iap, u8 *version)
154152 {
155153 int error;
156154 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
....@@ -169,9 +167,8 @@
169167 return 0;
170168 }
171169
172
-static int elan_smbus_get_sm_version(struct i2c_client *client,
173
- u16 *ic_type, u8 *version,
174
- u8 *clickpad)
170
+static int elan_smbus_get_sm_version(struct i2c_client *client, u8 pattern,
171
+ u16 *ic_type, u8 *version, u8 *clickpad)
175172 {
176173 int error;
177174 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
....@@ -343,7 +340,8 @@
343340 return 0;
344341 }
345342
346
-static int elan_smbus_prepare_fw_update(struct i2c_client *client)
343
+static int elan_smbus_prepare_fw_update(struct i2c_client *client, u16 ic_type,
344
+ u8 iap_version, u16 fw_page_size)
347345 {
348346 struct device *dev = &client->dev;
349347 int len;
....@@ -417,7 +415,7 @@
417415 }
418416
419417
420
-static int elan_smbus_write_fw_block(struct i2c_client *client,
418
+static int elan_smbus_write_fw_block(struct i2c_client *client, u16 fw_page_size,
421419 const u8 *page, u16 checksum, int idx)
422420 {
423421 struct device *dev = &client->dev;
....@@ -432,7 +430,7 @@
432430 */
433431 error = i2c_smbus_write_block_data(client,
434432 ETP_SMBUS_WRITE_FW_BLOCK,
435
- ETP_FW_PAGE_SIZE / 2,
433
+ fw_page_size / 2,
436434 page);
437435 if (error) {
438436 dev_err(dev, "Failed to write page %d (part %d): %d\n",
....@@ -442,8 +440,8 @@
442440
443441 error = i2c_smbus_write_block_data(client,
444442 ETP_SMBUS_WRITE_FW_BLOCK,
445
- ETP_FW_PAGE_SIZE / 2,
446
- page + ETP_FW_PAGE_SIZE / 2);
443
+ fw_page_size / 2,
444
+ page + fw_page_size / 2);
447445 if (error) {
448446 dev_err(dev, "Failed to write page %d (part %d): %d\n",
449447 idx, 2, error);
....@@ -472,7 +470,21 @@
472470 return 0;
473471 }
474472
475
-static int elan_smbus_get_report(struct i2c_client *client, u8 *report)
473
+static int elan_smbus_get_report_features(struct i2c_client *client, u8 pattern,
474
+ unsigned int *features,
475
+ unsigned int *report_len)
476
+{
477
+ /*
478
+ * SMBus controllers with pattern 2 lack area info, as newer
479
+ * high-precision packets use that space for coordinates.
480
+ */
481
+ *features = pattern <= 0x01 ? ETP_FEATURE_REPORT_MK : 0;
482
+ *report_len = ETP_SMBUS_REPORT_LEN;
483
+ return 0;
484
+}
485
+
486
+static int elan_smbus_get_report(struct i2c_client *client,
487
+ u8 *report, unsigned int report_len)
476488 {
477489 int len;
478490
....@@ -486,10 +498,13 @@
486498 return len;
487499 }
488500
489
- if (len != ETP_SMBUS_REPORT_LEN) {
501
+ if (report[ETP_REPORT_ID_OFFSET] == ETP_TP_REPORT_ID2)
502
+ report_len = ETP_SMBUS_REPORT_LEN2;
503
+
504
+ if (len != report_len) {
490505 dev_err(&client->dev,
491506 "wrong report length (%d vs %d expected)\n",
492
- len, ETP_SMBUS_REPORT_LEN);
507
+ len, report_len);
493508 return -EIO;
494509 }
495510
....@@ -537,6 +552,7 @@
537552 .write_fw_block = elan_smbus_write_fw_block,
538553 .finish_fw_update = elan_smbus_finish_fw_update,
539554
555
+ .get_report_features = elan_smbus_get_report_features,
540556 .get_report = elan_smbus_get_report,
541557 .get_pattern = elan_smbus_get_pattern,
542558 };