Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e781db6a authored by Mao Li's avatar Mao Li Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarMao Li <maol@codeaurora.org>
parent 85f074ae
Loading
Loading
Loading
Loading
+42 −3
Original line number Diff line number Diff line
@@ -31,6 +31,12 @@
#include <linux/debugfs.h>
#include <linux/sensors.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>
@@ -156,6 +162,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
@@ -257,6 +266,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)
@@ -1743,6 +1753,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) {
@@ -2096,7 +2123,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);
@@ -2431,6 +2457,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);

@@ -2455,7 +2495,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:
@@ -2602,7 +2641,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;
}