summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMao Li <maol@codeaurora.org>2015-09-17 16:29:57 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-08-30 22:17:01 -0700
commit4d840dce08381cfc547251ffdd472b7efee52151 (patch)
treeaed1355dd2a1a246fe5190549a8d09d1f53d42f6 /drivers
parentd0d1f78347ce9755da60335549e5ced1a5775ca3 (diff)
input: ft5x06_ts: add sysfs to access touch module info
Add sysfs under sys/kernel/ts_info to access touch vendor name, model number, firmware version. Change-Id: I531c7fa7db2b7140e5b9c7bb31831d221c734e3e Signed-off-by: Mao Li <maol@codeaurora.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/touchscreen/ft5x06_ts.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/input/touchscreen/ft5x06_ts.c b/drivers/input/touchscreen/ft5x06_ts.c
index 8335479f266e..b02e8ecf8608 100644
--- a/drivers/input/touchscreen/ft5x06_ts.c
+++ b/drivers/input/touchscreen/ft5x06_ts.c
@@ -30,6 +30,12 @@
#include <linux/firmware.h>
#include <linux/debugfs.h>
#include <linux/input/ft5x06_ts.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
+
#if defined(CONFIG_FB)
#include <linux/notifier.h>
@@ -142,6 +148,9 @@
#define FT_FW_FILE_MAJ_VER_FT6X36(x) ((x)->data[0x10a])
#define FT_FW_FILE_VENDOR_ID_FT6X36(x) ((x)->data[0x108])
+#define FT_SYSFS_TS_INFO "ts_info"
+
+
/**
* Application data verification will be run before upgrade flow.
* Firmware image stores some flags with negative and positive value
@@ -242,6 +251,7 @@ struct ft5x06_ts_data {
u32 tch_data_len;
u8 fw_ver[3];
u8 fw_vendor_id;
+ struct kobject ts_info_kobj;
#if defined(CONFIG_FB)
struct notifier_block fb_notif;
#elif defined(CONFIG_HAS_EARLYSUSPEND)
@@ -1585,6 +1595,23 @@ static ssize_t ft5x06_fw_name_store(struct device *dev,
static DEVICE_ATTR(fw_name, 0664, ft5x06_fw_name_show, ft5x06_fw_name_store);
+
+static ssize_t ft5x06_ts_info_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct ft5x06_ts_data *data = container_of(kobj,
+ struct ft5x06_ts_data, ts_info_kobj);
+ return snprintf(buf, FT_INFO_MAX_LEN,
+ "vendor name = Focaltech\n"
+ "model = 0x%x\n"
+ "fw_verion = %d.%d.%d\n",
+ data->family_id, data->fw_ver[0],
+ data->fw_ver[1], data->fw_ver[2]);
+}
+
+static struct kobj_attribute ts_info_attribute = __ATTR(ts_info,
+ 0664, ft5x06_ts_info_show, NULL);
+
static bool ft5x06_debug_addr_is_valid(int addr)
{
if (addr < 0 || addr > 0xFF) {
@@ -1933,7 +1960,6 @@ static int ft5x06_ts_probe(struct i2c_client *client,
u8 reg_value;
u8 reg_addr;
int err, len;
-
if (client->dev.of_node) {
pdata = devm_kzalloc(&client->dev,
sizeof(struct ft5x06_ts_platform_data), GFP_KERNEL);
@@ -2219,6 +2245,20 @@ static int ft5x06_ts_probe(struct i2c_client *client,
dev_dbg(&client->dev, "touch threshold = %d\n", reg_value * 4);
+ /*creation touch panel info kobj*/
+ data->ts_info_kobj = *(kobject_create_and_add(FT_SYSFS_TS_INFO,
+ kernel_kobj));
+ if (!&(data->ts_info_kobj)) {
+ dev_err(&client->dev, "kob creation failed .\n");
+ } else {
+ err = sysfs_create_file(&(data->ts_info_kobj),
+ &ts_info_attribute.attr);
+ if (err) {
+ kobject_put(&(data->ts_info_kobj));
+ dev_err(&client->dev, "sysfs create fail .\n");
+ }
+ }
+
ft5x06_update_fw_ver(data);
ft5x06_update_fw_vendor_id(data);
@@ -2243,7 +2283,6 @@ static int ft5x06_ts_probe(struct i2c_client *client,
data->early_suspend.resume = ft5x06_ts_late_resume;
register_early_suspend(&data->early_suspend);
#endif
-
return 0;
free_debug_dir:
@@ -2360,7 +2399,7 @@ static int ft5x06_ts_remove(struct i2c_client *client)
ft5x06_power_init(data, false);
input_unregister_device(data->input_dev);
-
+ kobject_put(&(data->ts_info_kobj));
return 0;
}