Commit cf520c64 authored by Johnny Chuang's avatar Johnny Chuang Committed by Dmitry Torokhov

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: default avatarJohnny Chuang <johnny.chuang@emc.com.tw>
Link: https://lore.kernel.org/r/1588754932-5902-1-git-send-email-johnny.chuang.emc@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 5fc70e35
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
/* FW read command, 0x53 0x?? 0x0, 0x01 */ /* FW read command, 0x53 0x?? 0x0, 0x01 */
#define E_ELAN_INFO_FW_VER 0x00 #define E_ELAN_INFO_FW_VER 0x00
#define E_ELAN_INFO_BC_VER 0x10 #define E_ELAN_INFO_BC_VER 0x10
#define E_ELAN_INFO_REK 0xE0
#define E_ELAN_INFO_TEST_VER 0xE0 #define E_ELAN_INFO_TEST_VER 0xE0
#define E_ELAN_INFO_FW_ID 0xF0 #define E_ELAN_INFO_FW_ID 0xF0
#define E_INFO_OSR 0xD6 #define E_INFO_OSR 0xD6
...@@ -1010,7 +1011,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) ...@@ -1010,7 +1011,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
*/ */
static ssize_t calibrate_store(struct device *dev, static ssize_t calibrate_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct elants_data *ts = i2c_get_clientdata(client); struct elants_data *ts = i2c_get_clientdata(client);
...@@ -1056,8 +1057,32 @@ static ssize_t show_iap_mode(struct device *dev, ...@@ -1056,8 +1057,32 @@ static ssize_t show_iap_mode(struct device *dev,
"Normal" : "Recovery"); "Normal" : "Recovery");
} }
static ssize_t show_calibration_count(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
const u8 cmd[] = { CMD_HEADER_READ, E_ELAN_INFO_REK, 0x00, 0x01 };
u8 resp[HEADER_SIZE];
u16 rek_count;
int error;
error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
resp, sizeof(resp));
if (error) {
dev_err(&client->dev,
"read ReK status error=%d, buf=%*phC\n",
error, (int)sizeof(resp), resp);
return sprintf(buf, "%d\n", error);
}
rek_count = get_unaligned_be16(&resp[2]);
return sprintf(buf, "0x%04x\n", rek_count);
}
static DEVICE_ATTR_WO(calibrate); static DEVICE_ATTR_WO(calibrate);
static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL); static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
static DEVICE_ATTR(calibration_count, S_IRUGO, show_calibration_count, NULL);
static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw); static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
struct elants_version_attribute { struct elants_version_attribute {
...@@ -1113,6 +1138,7 @@ static struct attribute *elants_attributes[] = { ...@@ -1113,6 +1138,7 @@ static struct attribute *elants_attributes[] = {
&dev_attr_calibrate.attr, &dev_attr_calibrate.attr,
&dev_attr_update_fw.attr, &dev_attr_update_fw.attr,
&dev_attr_iap_mode.attr, &dev_attr_iap_mode.attr,
&dev_attr_calibration_count.attr,
&elants_ver_attr_fw_version.dattr.attr, &elants_ver_attr_fw_version.dattr.attr,
&elants_ver_attr_hw_version.dattr.attr, &elants_ver_attr_hw_version.dattr.attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment