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

Commit ec57d6be authored by Sarada Prasanna Garnayak's avatar Sarada Prasanna Garnayak Committed by Stephen Boyd
Browse files

input: cyttsp-i2c-qc: Add debugfs support for suspend/resume.



Debugfs entry for touch device suspend/resume test.

Change-Id: I2d8e40059671d58bd4cfb6b74f6ba253366cb3c5
Signed-off-by: default avatarSarada Prasanna Garnayak <c_sgarna@codeaurora.org>
parent 77a88c15
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include <linux/pm_runtime.h>
#include <linux/firmware.h>
#include <linux/mutex.h>
#include <linux/debugfs.h>
#include <linux/regulator/consumer.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
@@ -76,6 +77,7 @@ struct cyttsp {
	bool cyttsp_fwloader_mode;
	bool is_suspended;
	struct regulator **vdd;
	struct dentry *dir;
	char fw_fname[FW_FNAME_LEN];
#ifdef CONFIG_HAS_EARLYSUSPEND
	struct early_suspend early_suspend;
@@ -92,6 +94,7 @@ static void cyttsp_early_suspend(struct early_suspend *handler);
static void cyttsp_late_resume(struct early_suspend *handler);
#endif /* CONFIG_HAS_EARLYSUSPEND */

#define CYTTSP_DEBUG_DIR_NAME	"ts_debug"

/* ****************************************************************************
 * Prototypes for static functions
@@ -914,6 +917,36 @@ static ssize_t cyttsp_fw_name_store(struct device *dev,
static DEVICE_ATTR(cyttsp_fw_name, 0664, cyttsp_fw_name_show,
					cyttsp_fw_name_store);

static int cyttsp_debug_suspend_set(void *_data, u64 val)
{
	struct cyttsp *ts = _data;

	mutex_lock(&ts->input->mutex);

	if (val)
		cyttsp_suspend(&ts->client->dev);
	else
		cyttsp_resume(&ts->client->dev);

	mutex_unlock(&ts->input->mutex);

	return 0;
}

static int cyttsp_debug_suspend_get(void *_data, u64 *val)
{
	struct cyttsp *ts = _data;

	mutex_lock(&ts->input->mutex);
	*val = ts->is_suspended;
	mutex_unlock(&ts->input->mutex);

	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(debug_suspend_fops, cyttsp_debug_suspend_get,
			cyttsp_debug_suspend_set, "%lld\n");

static void cyttsp_xy_handler(struct cyttsp *ts)
{
	u8 id, tilt, rev_x, rev_y;
@@ -2447,6 +2480,7 @@ error_vdd:
static int cyttsp_initialize(struct i2c_client *client, struct cyttsp *ts)
{
	struct input_dev *input_device;
	struct dentry *dir, *temp;
	int error = 0;
	int retval = CY_OK;
	u8 id;
@@ -2693,10 +2727,29 @@ static int cyttsp_initialize(struct i2c_client *client, struct cyttsp *ts)
		goto error_rm_dev_file_fupdate_fw;
	}

	dir = debugfs_create_dir(CYTTSP_DEBUG_DIR_NAME, NULL);
	if (dir == NULL || IS_ERR(dir)) {
		pr_err("debugfs_create_dir failed: rc=%ld\n", PTR_ERR(dir));
		error = PTR_ERR(dir);
		goto error_rm_dev_file_fw_name;
	}

	temp = debugfs_create_file("suspend", S_IRUSR | S_IWUSR, dir, ts,
					&debug_suspend_fops);
	if (temp == NULL || IS_ERR(temp)) {
		pr_err("debugfs_create_file failed: rc=%ld\n", PTR_ERR(temp));
		error = PTR_ERR(temp);
		goto error_rm_debug_dir;
	}

	cyttsp_info("%s: Successful registration\n", CY_I2C_NAME);

	goto success;

error_rm_debug_dir:
	debugfs_remove_recursive(ts->dir);
error_rm_dev_file_fw_name:
	device_remove_file(&client->dev, &dev_attr_cyttsp_fw_name);
error_rm_dev_file_fupdate_fw:
	device_remove_file(&client->dev, &dev_attr_cyttsp_force_update_fw);
error_rm_dev_file_update_fw:
@@ -3037,6 +3090,7 @@ static int cyttsp_remove(struct i2c_client *client)
	device_remove_file(&client->dev, &dev_attr_cyttsp_update_fw);
	device_remove_file(&client->dev, &dev_attr_cyttsp_force_update_fw);
	device_remove_file(&client->dev, &dev_attr_cyttsp_fw_name);
	debugfs_remove_recursive(ts->dir);

	/* free up timer or irq */
	if (ts->client->irq == 0) {