|
87 | 87 | /* FW read command, 0x53 0x?? 0x0, 0x01 */
|
88 | 88 | #define E_ELAN_INFO_FW_VER 0x00
|
89 | 89 | #define E_ELAN_INFO_BC_VER 0x10
|
| 90 | +#define E_ELAN_INFO_REK 0xE0 |
90 | 91 | #define E_ELAN_INFO_TEST_VER 0xE0
|
91 | 92 | #define E_ELAN_INFO_FW_ID 0xF0
|
92 | 93 | #define E_INFO_OSR 0xD6
|
@@ -1010,7 +1011,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
|
1010 | 1011 | */
|
1011 | 1012 | static ssize_t calibrate_store(struct device *dev,
|
1012 | 1013 | struct device_attribute *attr,
|
1013 |
| - const char *buf, size_t count) |
| 1014 | + const char *buf, size_t count) |
1014 | 1015 | {
|
1015 | 1016 | struct i2c_client *client = to_i2c_client(dev);
|
1016 | 1017 | struct elants_data *ts = i2c_get_clientdata(client);
|
@@ -1056,8 +1057,32 @@ static ssize_t show_iap_mode(struct device *dev,
|
1056 | 1057 | "Normal" : "Recovery");
|
1057 | 1058 | }
|
1058 | 1059 |
|
| 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 | + |
1059 | 1083 | static DEVICE_ATTR_WO(calibrate);
|
1060 | 1084 | static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
|
| 1085 | +static DEVICE_ATTR(calibration_count, S_IRUGO, show_calibration_count, NULL); |
1061 | 1086 | static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
|
1062 | 1087 |
|
1063 | 1088 | struct elants_version_attribute {
|
@@ -1113,6 +1138,7 @@ static struct attribute *elants_attributes[] = {
|
1113 | 1138 | &dev_attr_calibrate.attr,
|
1114 | 1139 | &dev_attr_update_fw.attr,
|
1115 | 1140 | &dev_attr_iap_mode.attr,
|
| 1141 | + &dev_attr_calibration_count.attr, |
1116 | 1142 |
|
1117 | 1143 | &elants_ver_attr_fw_version.dattr.attr,
|
1118 | 1144 | &elants_ver_attr_hw_version.dattr.attr,
|
|
0 commit comments