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

Commit 70e89067 authored by Amy Maloche's avatar Amy Maloche Committed by Sudhakar Manapati
Browse files

input: synaptics_i2c_rmi4: Switch suspend control to debugfs



Move control over suspend/resume control to debugfs from
sysfs.

This patch is propagated from msm-3.4 kernel.
(commit: 986863d096dfaee949fb99dc1cbd26a35c5c2f58
input: synaptics_i2c_rmi4: Switch suspend control to debugfs)

Change-Id: I6f0e25779a8d0a47b53f3c4b41a73a731ddc0018
Signed-off-by: default avatarAmy Maloche <amaloche@codeaurora.org>
parent 51a9f39d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1327,7 +1327,7 @@ int synaptics_fw_updater(unsigned char *fw_data)
		return -ENODEV;

	fwu->rmi4_data->fw_updating = true;
	if (fwu->rmi4_data->touch_stopped == true) {
	if (fwu->rmi4_data->suspended == true) {
		fwu->rmi4_data->fw_updating = false;
		dev_err(&fwu->rmi4_data->i2c_client->dev,
			"Cannot start fw upgrade while device is in suspend\n");
+69 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@

#define DRIVER_NAME "synaptics_rmi4_i2c"
#define INPUT_PHYS_NAME "synaptics_rmi4_i2c/input0"
#define DEBUGFS_DIR_NAME "ts_debug"

#define RESET_DELAY 100

@@ -290,6 +291,30 @@ static ssize_t synaptics_rmi4_full_pm_cycle_store(struct device *dev,
	return count;
}

static int synaptics_rmi4_debug_suspend_set(void *_data, u64 val)
{
	struct synaptics_rmi4_data *rmi4_data = _data;

	if (val)
		synaptics_rmi4_suspend(&rmi4_data->input_dev->dev);
	else
		synaptics_rmi4_resume(&rmi4_data->input_dev->dev);

	return 0;
}

static ssize_t synaptics_rmi4_debug_suspend_get(void *_data, u64 *val)
{
	struct synaptics_rmi4_data *rmi4_data = _data;

	*val = rmi4_data->suspended;

	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(debug_suspend_fops, synaptics_rmi4_debug_suspend_get,
			synaptics_rmi4_debug_suspend_set, "%lld\n");

#ifdef CONFIG_FB
static void configure_sleep(struct synaptics_rmi4_data *rmi4_data)
{
@@ -1996,6 +2021,7 @@ static int synaptics_rmi4_probe(struct i2c_client *client,
	struct synaptics_rmi4_device_info *rmi;
	struct synaptics_rmi4_platform_data *platform_data =
			client->dev.platform_data;
	struct dentry *temp;

	if (!i2c_check_functionality(client->adapter,
			I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -2047,6 +2073,7 @@ static int synaptics_rmi4_probe(struct i2c_client *client,
	rmi4_data->sensor_sleep = false;
	rmi4_data->irq_enabled = false;
	rmi4_data->fw_updating = false;
	rmi4_data->suspended = false;

	rmi4_data->i2c_read = synaptics_rmi4_i2c_read;
	rmi4_data->i2c_write = synaptics_rmi4_i2c_write;
@@ -2223,6 +2250,25 @@ static int synaptics_rmi4_probe(struct i2c_client *client,
		goto err_enable_irq;
	}

	rmi4_data->dir = debugfs_create_dir(DEBUGFS_DIR_NAME, NULL);
	if (rmi4_data->dir == NULL || IS_ERR(rmi4_data->dir)) {
		dev_err(&client->dev,
			"%s: Failed to create debugfs directory, rc = %ld\n",
			__func__, PTR_ERR(rmi4_data->dir));
		retval = PTR_ERR(rmi4_data->dir);
		goto err_create_debugfs_dir;
	}

	temp = debugfs_create_file("suspend", S_IRUSR | S_IWUSR, rmi4_data->dir,
					rmi4_data, &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));
		retval = PTR_ERR(temp);
		goto err_create_debugfs_file;
	}

	for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) {
		retval = sysfs_create_file(&rmi4_data->input_dev->dev.kobj,
				&attrs[attr_count].attr);
@@ -2248,7 +2294,10 @@ err_sysfs:
		sysfs_remove_file(&rmi4_data->input_dev->dev.kobj,
				&attrs[attr_count].attr);
	}

err_create_debugfs_file:
	debugfs_remove_recursive(rmi4_data->dir);
err_create_debugfs_dir:
	free_irq(rmi4_data->irq, rmi4_data);
err_enable_irq:
	cancel_delayed_work_sync(&rmi4_data->det_work);
	flush_workqueue(rmi4_data->det_workqueue);
@@ -2303,6 +2352,7 @@ static int synaptics_rmi4_remove(struct i2c_client *client)

	rmi = &(rmi4_data->rmi4_mod_info);

	debugfs_remove_recursive(rmi4_data->dir);
	cancel_delayed_work_sync(&rmi4_data->det_work);
	flush_workqueue(rmi4_data->det_workqueue);
	destroy_workqueue(rmi4_data->det_workqueue);
@@ -2580,6 +2630,11 @@ static int synaptics_rmi4_suspend(struct device *dev)
	struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
	int retval;

	if (rmi4_data->suspended) {
		dev_info(dev, "Already in suspend state\n");
		return 0;
	}

	if (!rmi4_data->fw_updating) {
		if (!rmi4_data->sensor_sleep) {
			rmi4_data->touch_stopped = true;
@@ -2593,12 +2648,17 @@ static int synaptics_rmi4_suspend(struct device *dev)
			dev_err(dev, "failed to enter low power mode\n");
			return retval;
		}
	} else
	} else {
		dev_err(dev,
			"Firmware updating, cannot go into suspend mode\n");
		return 0;
	}

	rmi4_data->suspended = true;

	return 0;
}

 /**
 * synaptics_rmi4_resume()
 *
@@ -2614,6 +2674,11 @@ static int synaptics_rmi4_resume(struct device *dev)
	struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
	int retval;

	if (!rmi4_data->suspended) {
		dev_info(dev, "Already in awake state\n");
		return 0;
	}

	retval = synaptics_rmi4_regulator_lpm(rmi4_data, false);
	if (retval < 0) {
		dev_err(dev, "failed to enter active power mode\n");
@@ -2624,6 +2689,8 @@ static int synaptics_rmi4_resume(struct device *dev)
	rmi4_data->touch_stopped = false;
	synaptics_rmi4_irq_enable(rmi4_data, true);

	rmi4_data->suspended = false;

	return 0;
}

+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#elif defined CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include <linux/debugfs.h>

#define PDT_PROPS (0x00EF)
#define PDT_START (0x00E9)
@@ -205,6 +206,7 @@ struct synaptics_rmi4_data {
#ifdef CONFIG_HAS_EARLYSUSPEND
	struct early_suspend early_suspend;
#endif
	struct dentry *dir;
	char fw_image_name[NAME_BUFFER_SIZE];
	unsigned char current_page;
	unsigned char button_0d_enabled;
@@ -228,6 +230,7 @@ struct synaptics_rmi4_data {
	bool flip_x;
	bool flip_y;
	bool fw_updating;
	bool suspended;
	wait_queue_head_t wait;
	int (*i2c_read)(struct synaptics_rmi4_data *pdata, unsigned short addr,
			unsigned char *data, unsigned short length);