Skip to content

Commit

Permalink
Input: elants_i2c - fix wake-on-touch
Browse files Browse the repository at this point in the history
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: James Chen <james.chen@emc.com.tw>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
James Chen authored and Dmitry Torokhov committed Dec 19, 2015
1 parent 3eab458 commit 478e5ed
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions drivers/input/touchscreen/elants_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
}
Expand All @@ -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)
disable_irq_wake(client->irq);

if (ts->keep_power_in_suspend) {
if (device_may_wakeup(dev)) {
if (ts->wake_irq_enabled)
disable_irq_wake(client->irq);
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));
Expand Down

0 comments on commit 478e5ed

Please sign in to comment.