Expose model and fw_version via sysfs. Also query the model
in probe to make sure, that the I2C communication with the
device works before successfully probing the driver.
Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
---
drivers/input/touchscreen/exc3000.c | 136 ++++++++++++++++++++++++++++
1 file changed, 136 insertions(+)
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index 7d695022082c..4c9f132629b9 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -41,6 +41,11 @@ struct exc3000_data {
struct touchscreen_properties prop;
struct timer_list timer;
u8 buf[2 * EXC3000_LEN_FRAME];
+ char model[11];
+ char fw_version[6];
+static void exc3000_query_interrupt(struct exc3000_data *data)
+{
+ u8 *buf = data->buf;
+ int err;
+
+ data->query_result = 0;
+
+ err = i2c_master_recv(data->client, buf, EXC3000_LEN_FRAME);
+ if (err < 0) {
+ data->query_result = err;
+ goto out;
+ }
+
+ if (buf[0] == 0x42 && buf[4] == 'E') {
+ memcpy(data->model, buf+5, 10);
+ data->model[10] = '\0';
+ goto out;
+ } else if (buf[0] == 0x42 && buf[4] == 'D') {
+ memcpy(data->fw_version, buf+5, 5);
+ data->fw_version[5] = '\0';
+ goto out;
+ }
+
+static DEVICE_ATTR(fw_version, S_IRUGO, exc3000_get_fw_version, NULL);
+
+ input->dev.groups = exc3000_attribute_groups;
+ for (retry = 0; retry < 3; ++retry) {
+ error = exc3000_get_model(data);
+ if (!error) {
+ break;
+ }
+ dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n", retry + 1, error);
+ }
+