Skip to content

Commit cf520c6

Browse files
ElanJohnnyChuangdtor
authored andcommitted
Input: elants_i2c - provide an attribute to show calibration count
There is an non-touch case by non-calibration after update firmware. Elan could know calibrate or not by calibration count. The value of '0xffff' means we didn't calibrate after update firmware. If calibrate success, it will plus one and change to '0x0000'. Signed-off-by: Johnny Chuang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 5fc70e3 commit cf520c6

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/input/touchscreen/elants_i2c.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
/* FW read command, 0x53 0x?? 0x0, 0x01 */
8888
#define E_ELAN_INFO_FW_VER 0x00
8989
#define E_ELAN_INFO_BC_VER 0x10
90+
#define E_ELAN_INFO_REK 0xE0
9091
#define E_ELAN_INFO_TEST_VER 0xE0
9192
#define E_ELAN_INFO_FW_ID 0xF0
9293
#define E_INFO_OSR 0xD6
@@ -1010,7 +1011,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
10101011
*/
10111012
static ssize_t calibrate_store(struct device *dev,
10121013
struct device_attribute *attr,
1013-
const char *buf, size_t count)
1014+
const char *buf, size_t count)
10141015
{
10151016
struct i2c_client *client = to_i2c_client(dev);
10161017
struct elants_data *ts = i2c_get_clientdata(client);
@@ -1056,8 +1057,32 @@ static ssize_t show_iap_mode(struct device *dev,
10561057
"Normal" : "Recovery");
10571058
}
10581059

1060+
static ssize_t show_calibration_count(struct device *dev,
1061+
struct device_attribute *attr, char *buf)
1062+
{
1063+
struct i2c_client *client = to_i2c_client(dev);
1064+
const u8 cmd[] = { CMD_HEADER_READ, E_ELAN_INFO_REK, 0x00, 0x01 };
1065+
u8 resp[HEADER_SIZE];
1066+
u16 rek_count;
1067+
int error;
1068+
1069+
error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
1070+
resp, sizeof(resp));
1071+
if (error) {
1072+
dev_err(&client->dev,
1073+
"read ReK status error=%d, buf=%*phC\n",
1074+
error, (int)sizeof(resp), resp);
1075+
return sprintf(buf, "%d\n", error);
1076+
}
1077+
1078+
rek_count = get_unaligned_be16(&resp[2]);
1079+
1080+
return sprintf(buf, "0x%04x\n", rek_count);
1081+
}
1082+
10591083
static DEVICE_ATTR_WO(calibrate);
10601084
static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
1085+
static DEVICE_ATTR(calibration_count, S_IRUGO, show_calibration_count, NULL);
10611086
static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
10621087

10631088
struct elants_version_attribute {
@@ -1113,6 +1138,7 @@ static struct attribute *elants_attributes[] = {
11131138
&dev_attr_calibrate.attr,
11141139
&dev_attr_update_fw.attr,
11151140
&dev_attr_iap_mode.attr,
1141+
&dev_attr_calibration_count.attr,
11161142

11171143
&elants_ver_attr_fw_version.dattr.attr,
11181144
&elants_ver_attr_hw_version.dattr.attr,

0 commit comments

Comments
 (0)