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

Commit 478e5ed1 authored by James Chen's avatar James Chen Committed by Dmitry Torokhov
Browse files

Input: elants_i2c - fix wake-on-touch



When sending "SLEEP" command to the controller it ceases scanning
completely and is unable to wake the system up from sleep, so if it is
configured as a wakeup source we should simply configure interrupt for
wakeup and rely on idle logic within the controller to reduce power
consumption while it is not used.

Signed-off-by: default avatarJames Chen <james.chen@emc.com.tw>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 3eab4588
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -1316,7 +1316,13 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)

	disable_irq(client->irq);

	if (device_may_wakeup(dev) || ts->keep_power_in_suspend) {
	if (device_may_wakeup(dev)) {
		/*
		 * The device will automatically enter idle mode
		 * that has reduced power consumption.
		 */
		ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0);
	} else if (ts->keep_power_in_suspend) {
		for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
			error = elants_i2c_send(client, set_sleep_cmd,
						sizeof(set_sleep_cmd));
@@ -1326,10 +1332,6 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
			dev_err(&client->dev,
				"suspend command failed: %d\n", error);
		}

		if (device_may_wakeup(dev))
			ts->wake_irq_enabled =
					(enable_irq_wake(client->irq) == 0);
	} else {
		elants_i2c_power_off(ts);
	}
@@ -1345,10 +1347,11 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
	int retry_cnt;
	int error;

	if (device_may_wakeup(dev) && ts->wake_irq_enabled)
	if (device_may_wakeup(dev)) {
		if (ts->wake_irq_enabled)
			disable_irq_wake(client->irq);

	if (ts->keep_power_in_suspend) {
		elants_i2c_sw_reset(client);
	} else if (ts->keep_power_in_suspend) {
		for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
			error = elants_i2c_send(client, set_active_cmd,
						sizeof(set_active_cmd));