summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorShantanu Jain <shjain@codeaurora.org>2015-05-15 18:54:18 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2016-07-31 23:16:48 -0700
commit8b724a99b7bc7128556e51205761433df602bd83 (patch)
treeec9087b9d438e3abf66940cc04d28e817c1dad3a /drivers/input
parent59a666fb58df2df86746e8e920e8789cbf899ec3 (diff)
input: it7258_ts_i2c: add debugfs support for suspend/resume
Add debugfs support for suspend and resume test for ITE tech touchscreen driver. Change-Id: I5a3d55c7c8e4b8f594fd7924c61ac1e5b5ad1965 Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/it7258_ts_i2c.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/it7258_ts_i2c.c b/drivers/input/touchscreen/it7258_ts_i2c.c
index 6c1e3a7a4b4d..c2b77472446b 100644
--- a/drivers/input/touchscreen/it7258_ts_i2c.c
+++ b/drivers/input/touchscreen/it7258_ts_i2c.c
@@ -25,11 +25,13 @@
#include <linux/regulator/consumer.h>
#include <linux/of_gpio.h>
#include <linux/fb.h>
+#include <linux/debugfs.h>
#define MAX_BUFFER_SIZE 144
#define DEVICE_NAME "IT7260"
#define SCREEN_X_RESOLUTION 320
#define SCREEN_Y_RESOLUTION 320
+#define DEBUGFS_DIR_NAME "ts_debug"
/* all commands writes go to this idx */
#define BUF_COMMAND 0x20
@@ -157,6 +159,7 @@ struct IT7260_ts_data {
#ifdef CONFIG_FB
struct notifier_block fb_notif;
#endif
+ struct dentry *dir;
};
static int8_t fwUploadResult;
@@ -170,6 +173,26 @@ static struct IT7260_ts_data *gl_ts;
#define LOGE(...) pr_err(DEVICE_NAME ": " __VA_ARGS__)
#define LOGI(...) printk(DEVICE_NAME ": " __VA_ARGS__)
+static int IT7260_debug_suspend_set(void *_data, u64 val)
+{
+ if (val)
+ IT7260_ts_suspend(&gl_ts->client->dev);
+ else
+ IT7260_ts_resume(&gl_ts->client->dev);
+
+ return 0;
+}
+
+static int IT7260_debug_suspend_get(void *_data, u64 *val)
+{
+ *val = isDeviceSuspend;
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(debug_suspend_fops, IT7260_debug_suspend_get,
+ IT7260_debug_suspend_set, "%lld\n");
+
/* internal use func - does not make sure chip is ready before read */
static bool i2cReadNoReadyCheck(uint8_t bufferIndex, uint8_t *dataBuffer,
uint16_t dataLength)
@@ -814,6 +837,7 @@ static int IT7260_ts_probe(struct i2c_client *client,
uint8_t rsp[2];
int ret = -1;
int rc;
+ struct dentry *temp;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
LOGE("need I2C_FUNC_I2C\n");
@@ -989,8 +1013,36 @@ static int IT7260_ts_probe(struct i2c_client *client,
i2cReadNoReadyCheck(BUF_RESPONSE, rsp, sizeof(rsp));
mdelay(10);
+ gl_ts->dir = debugfs_create_dir(DEBUGFS_DIR_NAME, NULL);
+ if (gl_ts->dir == NULL || IS_ERR(gl_ts->dir)) {
+ dev_err(&client->dev,
+ "%s: Failed to create debugfs directory, rc = %ld\n",
+ __func__, PTR_ERR(gl_ts->dir));
+ ret = PTR_ERR(gl_ts->dir);
+ goto err_create_debugfs_dir;
+ }
+
+ temp = debugfs_create_file("suspend", S_IRUSR | S_IWUSR, gl_ts->dir,
+ gl_ts, &debug_suspend_fops);
+ if (temp == NULL || IS_ERR(temp)) {
+ dev_err(&client->dev,
+ "%s: Failed to create suspend debugfs file, rc = %ld\n",
+ __func__, PTR_ERR(temp));
+ ret = PTR_ERR(temp);
+ goto err_create_debugfs_file;
+ }
+
return 0;
+err_create_debugfs_file:
+ debugfs_remove_recursive(gl_ts->dir);
+err_create_debugfs_dir:
+#if defined(CONFIG_FB)
+ if (fb_unregister_client(&gl_ts->fb_notif))
+ dev_err(&client->dev, "Error occurred while unregistering fb_notifier.\n");
+#endif
+ sysfs_remove_group(&(client->dev.kobj), &it7260_attr_group);
+
err_sysfs_grp_create_2:
free_irq(client->irq, gl_ts);
@@ -1014,10 +1066,12 @@ err_out:
static int IT7260_ts_remove(struct i2c_client *client)
{
+ debugfs_remove_recursive(gl_ts->dir);
#if defined(CONFIG_FB)
if (fb_unregister_client(&gl_ts->fb_notif))
dev_err(&client->dev, "Error occurred while unregistering fb_notifier.\n");
#endif
+ sysfs_remove_group(&(client->dev.kobj), &it7260_attr_group);
devicePresent = false;
return 0;
}