summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorShantanu Jain <shjain@codeaurora.org>2013-11-13 20:12:16 +0530
committerAbinaya P <abinayap@codeaurora.org>2016-09-26 16:09:42 +0530
commitcf29d5ea8207fd31e15fe1c4dad06cecde2a352e (patch)
treebbcecff833cfb2b210232bd1ce51b2dc477f1f7b /drivers/input
parent740bb381f6998d34eac9547b26c3ab17a72a9821 (diff)
input: touchscreen: Add debugfs support for suspend/resume.
Add debugfs entry for suspend/resume that allow suspending/ resuming of Goodix CTP driver from userspace. Also change the return type of goodix_ts_resume and goodix_ts_suspend functions and set the status of gtp_is_suspended in the last of above functions. Change-Id: Ic2b1b2562b63ccecdf15bdc64ad7e45996d196d3 Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/gt9xx/gt9xx.c83
-rw-r--r--drivers/input/touchscreen/gt9xx/gt9xx.h1
2 files changed, 79 insertions, 5 deletions
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.c b/drivers/input/touchscreen/gt9xx/gt9xx.c
index 2c7c338e566f..b214ca358e39 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx.c
+++ b/drivers/input/touchscreen/gt9xx/gt9xx.c
@@ -47,6 +47,7 @@
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/input/mt.h>
+#include <linux/debugfs.h>
#define GOODIX_DEV_NAME "Goodix-CTP"
#define CFG_MAX_TOUCH_POINTS 5
@@ -83,7 +84,9 @@ static int goodix_power_on(struct goodix_ts_data *ts);
#if defined(CONFIG_FB)
static int fb_notifier_callback(struct notifier_block *self,
- unsigned long event, void *data);
+ unsigned long event, void *data);
+static int goodix_ts_suspend(struct device *dev);
+static int goodix_ts_resume(struct device *dev);
#elif defined(CONFIG_HAS_EARLYSUSPEND)
static void goodix_ts_early_suspend(struct early_suspend *h);
static void goodix_ts_late_resume(struct early_suspend *h);
@@ -110,6 +113,9 @@ static u8 chip_gt9xxs; /* true if ic is gt9xxs, like gt915s */
u8 grp_cfg_version;
struct i2c_client *i2c_connect_client;
+#define GTP_DEBUGFS_DIR "ts_debug"
+#define GTP_DEBUGFS_FILE_SUSPEND "suspend"
+
/*******************************************************
Function:
Read data from the i2c slave device.
@@ -1556,6 +1562,56 @@ static const struct attribute_group gtp_attr_grp = {
.attrs = gtp_attrs,
};
+static int gtp_debug_suspend_set(void *_data, u64 val)
+{
+ struct goodix_ts_data *ts = _data;
+
+ mutex_lock(&ts->input_dev->mutex);
+ if (val)
+ goodix_ts_suspend(&ts->client->dev);
+ else
+ goodix_ts_resume(&ts->client->dev);
+ mutex_unlock(&ts->input_dev->mutex);
+
+ return 0;
+}
+
+static int gtp_debug_suspend_get(void *_data, u64 *val)
+{
+ struct goodix_ts_data *ts = _data;
+
+ mutex_lock(&ts->input_dev->mutex);
+ *val = ts->gtp_is_suspend;
+ mutex_unlock(&ts->input_dev->mutex);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(debug_suspend_fops, gtp_debug_suspend_get,
+ gtp_debug_suspend_set, "%lld\n");
+
+static int gtp_debugfs_init(struct goodix_ts_data *data)
+{
+ data->debug_base = debugfs_create_dir(GTP_DEBUGFS_DIR, NULL);
+
+ if (IS_ERR_OR_NULL(data->debug_base)) {
+ pr_err("Failed to create debugfs dir\n");
+ return -EINVAL;
+ }
+
+ if ((IS_ERR_OR_NULL(debugfs_create_file(GTP_DEBUGFS_FILE_SUSPEND,
+ S_IWUSR | S_IWGRP | S_IRUSR | S_IRGRP,
+ data->debug_base,
+ data,
+ &debug_suspend_fops)))) {
+ pr_err("Failed to create suspend file\n");
+ debugfs_remove_recursive(data->debug_base);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int goodix_ts_get_dt_coords(struct device *dev, char *name,
struct goodix_ts_platform_data *pdata)
{
@@ -1860,6 +1916,10 @@ static int goodix_ts_probe(struct i2c_client *client,
goto exit_free_irq;
}
+ ret = gtp_debugfs_init(ts);
+ if (ret != 0)
+ goto exit_remove_sysfs;
+
init_done = true;
return 0;
exit_free_irq:
@@ -1884,6 +1944,8 @@ exit_free_irq:
input_free_device(ts->input_dev);
ts->input_dev = NULL;
}
+exit_remove_sysfs:
+ sysfs_remove_group(&ts->input_dev->dev.kobj, &gtp_attr_grp);
exit_free_inputdev:
kfree(ts->config_data);
exit_power_off:
@@ -1958,6 +2020,7 @@ static int goodix_ts_remove(struct i2c_client *client)
goodix_power_deinit(ts);
i2c_set_clientdata(client, NULL);
}
+ debugfs_remove_recursive(ts->debug_base);
return 0;
}
@@ -1976,9 +2039,13 @@ static int goodix_ts_suspend(struct device *dev)
struct goodix_ts_data *ts = dev_get_drvdata(dev);
int ret = 0, i;
+ if (ts->gtp_is_suspend) {
+ dev_dbg(&ts->client->dev, "Already in suspend state\n");
+ return 0;
+ }
+
mutex_lock(&ts->lock);
#if GTP_ESD_PROTECT
- ts->gtp_is_suspend = 1;
gtp_esd_switch(ts->client, SWITCH_OFF);
#endif
@@ -1998,12 +2065,13 @@ static int goodix_ts_suspend(struct device *dev)
ret = gtp_enter_sleep(ts);
#endif
if (ret <= 0)
- dev_err(&ts->client->dev, "GTP early suspend failed.\n");
+ dev_err(&ts->client->dev, "GTP early suspend failed\n");
/* to avoid waking up while not sleeping,
* delay 48 + 10ms to ensure reliability
*/
msleep(58);
mutex_unlock(&ts->lock);
+ ts->gtp_is_suspend = 1;
return ret;
}
@@ -2021,6 +2089,11 @@ static int goodix_ts_resume(struct device *dev)
struct goodix_ts_data *ts = dev_get_drvdata(dev);
int ret = 0;
+ if (!ts->gtp_is_suspend) {
+ dev_dbg(&ts->client->dev, "Already in awake state\n");
+ return 0;
+ }
+
mutex_lock(&ts->lock);
ret = gtp_wakeup_sleep(ts);
@@ -2029,7 +2102,7 @@ static int goodix_ts_resume(struct device *dev)
#endif
if (ret <= 0)
- dev_err(&ts->client->dev, "GTP resume failed.\n");
+ dev_err(&ts->client->dev, "GTP resume failed\n");
if (ts->use_irq)
gtp_irq_enable(ts);
@@ -2038,10 +2111,10 @@ static int goodix_ts_resume(struct device *dev)
ktime_set(1, 0), HRTIMER_MODE_REL);
#if GTP_ESD_PROTECT
- ts->gtp_is_suspend = 0;
gtp_esd_switch(ts->client, SWITCH_ON);
#endif
mutex_unlock(&ts->lock);
+ ts->gtp_is_suspend = 0;
return ret;
}
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.h b/drivers/input/touchscreen/gt9xx/gt9xx.h
index 1379bd847705..a61858853742 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx.h
+++ b/drivers/input/touchscreen/gt9xx/gt9xx.h
@@ -96,6 +96,7 @@ struct goodix_ts_data {
#elif defined(CONFIG_HAS_EARLYSUSPEND)
struct early_suspend early_suspend;
#endif
+ struct dentry *debug_base;
};
extern u16 show_len;