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

Commit ed34b168 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "input: touchscreen: power off touch panel during suspend"

parents 9933dea4 530ec79f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ Optional properties:
				min y, max x and max y values.
 - goodix,i2c-pull-up	: To specify pull up is required.
 - goodix,no-force-update	: To specify force update is allowed.
 - goodix,enable-power-off	: Power off touchscreen during suspend.
 - goodix,button-map	: Button map of key codes. The number of key codes
				depend on panel.
 - goodix,cfg-data0	: Touch screen controller config data group 0. Ask vendor
+6 −6
Original line number Diff line number Diff line
@@ -303,13 +303,13 @@ static struct gpiomux_setting goodix_ldo_en_act_cfg = {

static struct gpiomux_setting goodix_ldo_en_sus_cfg = {
	.func = GPIOMUX_FUNC_GPIO,
	.drv = GPIOMUX_DRV_6MA,
	.pull = GPIOMUX_PULL_UP,
	.drv = GPIOMUX_DRV_2MA,
	.pull = GPIOMUX_PULL_DOWN,
};

static struct gpiomux_setting goodix_int_act_cfg = {
	.func = GPIOMUX_FUNC_GPIO,
	.drv = GPIOMUX_DRV_8MA,
	.drv = GPIOMUX_DRV_6MA,
	.pull = GPIOMUX_PULL_UP,
};

@@ -321,14 +321,14 @@ static struct gpiomux_setting goodix_int_sus_cfg = {

static struct gpiomux_setting goodix_reset_act_cfg = {
	.func = GPIOMUX_FUNC_GPIO,
	.drv = GPIOMUX_DRV_8MA,
	.drv = GPIOMUX_DRV_6MA,
	.pull = GPIOMUX_PULL_UP,
};

static struct gpiomux_setting goodix_reset_sus_cfg = {
	.func = GPIOMUX_FUNC_GPIO,
	.drv = GPIOMUX_DRV_8MA,
	.pull = GPIOMUX_PULL_UP,
	.drv = GPIOMUX_DRV_2MA,
	.pull = GPIOMUX_PULL_DOWN,
};

static struct msm_gpiomux_config msm_skuf_blsp_configs[] __initdata = {
+91 −27
Original line number Diff line number Diff line
@@ -87,6 +87,8 @@ static const u16 touch_key_array[] = {KEY_MENU, KEY_HOMEPAGE, KEY_BACK};
static void gtp_reset_guitar(struct goodix_ts_data *ts, int ms);
static void gtp_int_sync(struct goodix_ts_data *ts, int ms);
static int gtp_i2c_test(struct i2c_client *client);
static int goodix_power_off(struct goodix_ts_data *ts);
static int goodix_power_on(struct goodix_ts_data *ts);

#if defined(CONFIG_FB)
static int fb_notifier_callback(struct notifier_block *self,
@@ -742,7 +744,7 @@ Input:
	ts: private data.
Output:
	Executive outcomes.
	1: succeed, otherwise failed.
	>0: succeed, otherwise failed.
*******************************************************/
static s8 gtp_enter_sleep(struct goodix_ts_data  *ts)
{
@@ -753,12 +755,28 @@ static s8 gtp_enter_sleep(struct goodix_ts_data *ts)
		(u8)GTP_REG_SLEEP, 5};

	ret = gpio_direction_output(ts->pdata->irq_gpio, 0);
	if (ret)
		dev_err(&ts->client->dev,
			"GTP sleep: Cannot reconfig gpio %d.\n",
			ts->pdata->irq_gpio);
	if (ts->pdata->enable_power_off) {
		ret = gpio_direction_output(ts->pdata->reset_gpio, 0);
		if (ret)
			dev_err(&ts->client->dev,
				"GTP sleep: Cannot reconfig gpio %d.\n",
				ts->pdata->reset_gpio);
		ret = goodix_power_off(ts);
		if (ret) {
			dev_err(&ts->client->dev, "GTP power off failed.\n");
			return 0;
		}
		return 1;
	} else {
		usleep(5000);
		while (retry++ < GTP_I2C_RETRY_5) {
			ret = gtp_i2c_write(ts->client, i2c_control_buf, 3);
		if (ret > 0) {
			dev_dbg(&ts->client->dev,
				"GTP enter sleep!");
			if (ret == 1) {
				dev_dbg(&ts->client->dev, "GTP enter sleep!");
				return ret;
			}
			msleep(20);
@@ -766,7 +784,8 @@ static s8 gtp_enter_sleep(struct goodix_ts_data *ts)
		dev_err(&ts->client->dev, "GTP send sleep cmd failed.\n");
		return ret;
	}
#endif
}
#endif /* !GTP_SLIDE_WAKEUP */

/*******************************************************
Function:
@@ -782,17 +801,36 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data *ts)
	u8 retry = 0;
	s8 ret = -1;

#if GTP_POWER_CTRL_SLEEP
	if (ts->pdata->enable_power_off) {
		ret = gpio_direction_output(ts->pdata->irq_gpio, 0);
		if (ret)
			dev_err(&ts->client->dev,
				"GTP wakeup: Cannot reconfig gpio %d.\n",
				ts->pdata->irq_gpio);
		ret = gpio_direction_output(ts->pdata->reset_gpio, 0);
		if (ret)
			dev_err(&ts->client->dev,
				"GTP wakeup: Cannot reconfig gpio %d.\n",
				ts->pdata->reset_gpio);
		ret = goodix_power_on(ts);
		if (ret) {
			dev_err(&ts->client->dev, "GTP power on failed.\n");
			return 0;
		}

		gtp_reset_guitar(ts, 20);

		ret = gtp_send_cfg(ts);
	if (ret > 0) {
		if (ret <= 0) {
			dev_err(&ts->client->dev,
				"GTP wakeup sleep failed.\n");
			return ret;
		}

		dev_dbg(&ts->client->dev,
				"Wakeup sleep send config success.");
		return 1;
	}
#else
	while (retry++ < GTP_I2C_RETRY_10) {
	} else {
err_retry:
#if GTP_SLIDE_WAKEUP
		/* wakeup not by slide */
		if (DOZE_WAKEUP != doze_status)
@@ -809,7 +847,7 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data *ts)
		}
#endif
		ret = gtp_i2c_test(ts->client);
		if (ret > 0) {
		if (ret == 2) {
			dev_dbg(&ts->client->dev, "GTP wakeup sleep.");
#if (!GTP_SLIDE_WAKEUP)
			if (chip_gt9xxs == 0) {
@@ -823,10 +861,10 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data *ts)
			return ret;
		}
		gtp_reset_guitar(ts, 20);
	}
#endif

		if (retry++ < GTP_I2C_RETRY_10)
			goto err_retry;
		dev_err(&ts->client->dev, "GTP wakeup sleep failed.\n");
	}
	return ret;
}
#endif /* !CONFIG_HAS_EARLYSUSPEND && !CONFIG_FB*/
@@ -1292,6 +1330,12 @@ static int goodix_power_on(struct goodix_ts_data *ts)
{
	int ret;

	if (ts->power_on) {
		dev_info(&ts->client->dev,
				"Device already power on\n");
		return 0;
	}

	if (!IS_ERR(ts->avdd)) {
		ret = reg_set_optimum_mode_check(ts->avdd,
			GOODIX_VDD_LOAD_MAX_UA);
@@ -1358,6 +1402,7 @@ static int goodix_power_on(struct goodix_ts_data *ts)
			}
	}

	ts->power_on = true;
	return 0;

err_enable_vcc_i2c:
@@ -1376,6 +1421,7 @@ err_set_vtg_vdd:
		regulator_disable(ts->avdd);
err_enable_avdd:
err_set_opt_avdd:
	ts->power_on = false;
	return ret;
}

@@ -1389,6 +1435,12 @@ static int goodix_power_off(struct goodix_ts_data *ts)
{
	int ret;

	if (!ts->power_on) {
		dev_info(&ts->client->dev,
				"Device already power off\n");
		return 0;
	}

	if (!IS_ERR(ts->vcc_i2c)) {
		ret = regulator_set_voltage(ts->vcc_i2c, 0,
			GOODIX_I2C_VTG_MAX_UV);
@@ -1421,6 +1473,7 @@ static int goodix_power_off(struct goodix_ts_data *ts)
				"Regulator avdd disable failed ret=%d\n", ret);
	}

	ts->power_on = false;
	return 0;
}

@@ -1580,6 +1633,9 @@ static int goodix_parse_dt(struct device *dev,

	pdata->no_force_update = of_property_read_bool(np,
						"goodix,no-force-update");

	pdata->enable_power_off = of_property_read_bool(np,
						"goodix,enable-power-off");
	/* reset, irq gpio info */
	pdata->reset_gpio = of_get_named_gpio_flags(np, "reset-gpios",
				0, &pdata->reset_gpio_flags);
@@ -1718,6 +1774,7 @@ static int goodix_ts_probe(struct i2c_client *client,
	spin_lock_init(&ts->irq_lock);
	i2c_set_clientdata(client, ts);
	ts->gtp_rawdiff_mode = 0;
	ts->power_on = false;

	ret = gtp_request_io_port(ts);
	if (ret) {
@@ -1773,6 +1830,7 @@ static int goodix_ts_probe(struct i2c_client *client,
	}
	input_set_drvdata(ts->input_dev, ts);

	mutex_init(&ts->lock);
#if defined(CONFIG_FB)
	ts->fb_notif.notifier_call = fb_notifier_callback;
	ret = fb_register_client(&ts->fb_notif);
@@ -1824,6 +1882,7 @@ static int goodix_ts_probe(struct i2c_client *client,
	init_done = true;
	return 0;
exit_free_irq:
	mutex_destroy(&ts->lock);
#if defined(CONFIG_FB)
	if (fb_unregister_client(&ts->fb_notif))
		dev_err(&client->dev,
@@ -1881,6 +1940,7 @@ static int goodix_ts_remove(struct i2c_client *client)
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	unregister_early_suspend(&ts->early_suspend);
#endif
	mutex_destroy(&ts->lock);

#if GTP_CREATE_WR_NODE
	uninit_wr_node();
@@ -1934,6 +1994,7 @@ static void goodix_ts_suspend(struct goodix_ts_data *ts)
{
	int ret = -1, i;

	mutex_lock(&ts->lock);
#if GTP_ESD_PROTECT
	ts->gtp_is_suspend = 1;
	gtp_esd_switch(ts->client, SWITCH_OFF);
@@ -1954,12 +2015,13 @@ static void goodix_ts_suspend(struct goodix_ts_data *ts)

	ret = gtp_enter_sleep(ts);
#endif
	if (ret < 0)
	if (ret <= 0)
		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);
}

/*******************************************************
@@ -1974,13 +2036,14 @@ static void goodix_ts_resume(struct goodix_ts_data *ts)
{
	int ret = -1;

	mutex_lock(&ts->lock);
	ret = gtp_wakeup_sleep(ts);

#if GTP_SLIDE_WAKEUP
	doze_status = DOZE_DISABLED;
#endif

	if (ret < 0)
	if (ret <= 0)
		dev_err(&ts->client->dev, "GTP resume failed.\n");

	if (ts->use_irq)
@@ -1993,6 +2056,7 @@ static void goodix_ts_resume(struct goodix_ts_data *ts)
	ts->gtp_is_suspend = 0;
	gtp_esd_switch(ts->client, SWITCH_ON);
#endif
	mutex_unlock(&ts->lock);
}

#if defined(CONFIG_FB)
+5 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <linux/regulator/consumer.h>
#include <linux/firmware.h>
#include <linux/debugfs.h>
#include <linux/mutex.h>

#if defined(CONFIG_FB)
#include <linux/notifier.h>
@@ -66,6 +67,7 @@ struct goodix_ts_platform_data {
	u32 panel_maxy;
	bool no_force_update;
	bool i2c_pull_up;
	bool enable_power_off;
	size_t config_data_len[GOODIX_MAX_CFG_GROUP];
	u8 *config_data[GOODIX_MAX_CFG_GROUP];
	u32 button_map[MAX_BUTTONS];
@@ -96,6 +98,8 @@ struct goodix_ts_data {
	u8  fixed_cfg;
	u8  esd_running;
	u8  fw_error;
	bool power_on;
	struct mutex lock;
	struct regulator *avdd;
	struct regulator *vdd;
	struct regulator *vcc_i2c;
@@ -114,7 +118,6 @@ extern u16 total_len;
#define GTP_CHANGE_X2Y			0
#define GTP_DRIVER_SEND_CFG		1
#define GTP_HAVE_TOUCH_KEY		1
#define GTP_POWER_CTRL_SLEEP	0

/* auto updated by .bin file as default */
#define GTP_AUTO_UPDATE			0
@@ -126,6 +129,7 @@ extern u16 total_len;
#define GTP_ESD_PROTECT			0
#define GTP_WITH_PEN			0

/* This cannot work when enable-power-off is on */
#define GTP_SLIDE_WAKEUP		0
/* double-click wakeup, function together with GTP_SLIDE_WAKEUP */
#define GTP_DBL_CLK_WAKEUP		0